Using Web Service or Web Service Reference

前端 未结 3 902
面向向阳花
面向向阳花 2021-01-01 06:45

This relates specifically to .NET. And I\'ve decided to use the Web service Reference instead of Web Service...I think though my questions below really are for either situa

3条回答
  •  长发绾君心
    2021-01-01 07:36

    I'm assuming you are using a web reference for this. For the most part, using the web service should be as easy as using a local object. .NET handles all of the plumbing under the covers. Sometimes this works very nicely -- other times not so much.

    When you add a web reference to the PayPal web service Visual Studio will create a file in a sub-folder of Web References called reference.cs which is the proxy class (by default VS 2008 hides it -- you have to "show all files" to see it).

    For your specific case, it looks like PayPal is using custom SOAP headers to transmit all of the security context information. Take a look at the CustomSecurityHeaderType and the UserIdPasswordType types for more details. Also, some documentation from PayPal might help. :)

    To use the service you will have to do something like this:

        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); 
    

    I'm not familiar with the PayPal service but I think this is how it should work.

提交回复
热议问题