开发者

Sending an API CAll with PayPal SOAP API

Ok, so I have the service reference in my .NET project. And yes I know that you now have access to proxy classes.

But in the past, I am used to doing this via an HttpWebRequest object using NVP, but never tried using the WSDL and sending a SOAP request this way.

I'm not quite sure which object to use to send the request. Not sure where to start here. I've looked at the docs but seen no good examples out there for .NET and PayPal.

Other than a WSDL vs. sending an HttpWebRequest via a NVP API and querystring p开发者_StackOverflow中文版arams, I really do not understand if there's a difference in how you send the request. It's all just over Http so can't you use HttpWebRequest also over a SOAP API (using WSDL)?


You start by generating a service reference from the metadata: Right click on the project -> Add Service Reference and point to the WSDL url: https://www.sandbox.paypal.com/wsdl/PayPalSvc.wsdl

This will generate proxy classes to the current project which could be used to send requests:

using (var client = new PayPalAPIInterfaceClient())
{
    var credentials = new CustomSecurityHeaderType
    {
        Credentials = new UserIdPasswordType
        {
            Username = "username",
            Password = "password"
        }
    };
    var request = new AddressVerifyReq
    {
        AddressVerifyRequest = new AddressVerifyRequestType
        {
            Street = "some street",
            Zip = "12345"
        }
    };
    var response = client.AddressVerify(ref credentials, request);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜