Using a web service or web service link

This applies specifically to .NET. And I decided to use the link to the web service instead of the web service ... I think, although my questions below are valid for any situation, and I want to try to get a general idea about this.

So, here is the problem for me. Let me first explain where I come from. One of the past projects, I already spoke with several APIs, creating manual classes such as GetPicturesRequest.cs and GetPicturesResponse.cs, for example, which will have state for me. I will have a base class called Request.cs, which performed the actual dispatch of the api call:

Stream requestStream;
Stream responseStream;
XmlDocument doc = new XmlDocument();
doc = CreateRequestXML();

// Determins if API call needs to use a session based URI
string requestURI = UseAuthURI == true ? _requestURIAuthBased + JSessionID : _requestURI;

byte[] data = XmlUtil.DocumentToBytes(doc);

// Create the atual Request instance
HttpWebRequest request = CreateWebRequest(requestURI, data.Length);
request.ContentLength = data.Length;
request.KeepAlive = false;
request.Timeout = 30000;

// Send the Request
requestStream = request.GetRequestStream();
requestStream.Write(data, 0, data.Length);
requestStream.Close();

-. https://www.sandbox.paypal.com/wsdl/PayPalSvc.wsdl VS 2008. -.

-, , - , API:

1) ? , API , (), sessionID, , , API. - -?

2) / , -/? , ?

3). , - API -/?

4) , , -/ WSDL?... -, , , ? , VS, - WSDL? , API, SOAP? , API WSDL, ?

+2
3

. , , !

WSE . .

"-" - ASMX. Microsoft "" . , .

OP " ". , .


, :

  • ?

    , - , . , RefundTransactionRequest RequesterCredentials, CustomSecurityHeaderType. . , RefundTransactionRequest, , , .

  • /?

    , . . .

  • , Proxy ?

    . - . , , .

  • , , -/ WSDL?

    , . . , , " ".


:

using (var svc = new PayPalAPIAAInterfaceClient())
{
    var paypal = (PayPalAPIInterface) svc;
    var credentials = new CustomSecurityHeaderType
                          {
                              Credentials =
                                  new UserIdPasswordType
                                      {
                                          AppId = "",
                                          Username = "John",
                                          Password = "John"
                                      }
                          };
    var request = new RefundTransactionRequestType
                      {
                          Amount =
                              new BasicAmountType
                                  {
                                      currencyID = CurrencyCodeType.USD,
                                      Value = "100.00"
                                  },
                          Memo = "I want my money back",
                          RefundType = RefundType.Full,
                          RefundTypeSpecified = true
                      };
    var refundRequest = new RefundTransactionReq
                            {RefundTransactionRequest = request};
    var result =
        paypal.RefundTransaction(
            new RefundTransactionRequest(credentials, refundRequest));
    var response = result.RefundTransactionResponse1;
    var returnedCredentials = result.RequesterCredentials;
}
+9

, -. - , ..NET . - .

- - PayPal Visual Studio -, reference.cs, - ( VS 2008 - " ", ).

, PayPal SOAP . CustomSecurityHeaderType UserIdPasswordType. , PayPal.:)

, - :

    PayPalAPISoapBinding payPal = new PayPalAPISoapBinding();

    CustomSecurityHeaderType customSecurity = new CustomSecurityHeaderType();
    customSecurity.eBayAuthToken = "The Auth Token";

    UserIdPasswordType userId = new UserIdPasswordType();
    userId.Password = "PWD";
    userId.Username = "JIMMY";

    customSecurity.Credentials = userId;

    payPal.RequesterCredentials = customSecurity;

    RefundTransactionReq request = new RefundTransactionReq();

    RefundTransactionResponseType response = payPal.RefundTransaction(request); 

PayPal, , .

+2

1) , . WSE 3.0, VS .

2) WSE. , .

3) . WSE SOAP WS- *. WCF TCP, Pipes MSMQ SOAP. WSDL, .

-2
source

All Articles