简体   繁体   English

使用PayPal SOAP API发送API CAll

[英]Sending an API CAll with PayPal SOAP API

Ok, so I have the service reference in my .NET project. 好的,所以我的.NET项目中有服务引用。 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. 但是在过去,我习惯通过使用NVP的HttpWebRequest对象来做这件事,但从未尝试过使用WSDL并以这种方式发送SOAP请求。

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. 我看过这些文档,但看不到.NET和PayPal的好例子。

Other than a WSDL vs. sending an HttpWebRequest via a NVP API and querystring params, I really do not understand if there's a difference in how you send the request. 除了WSDL与通过NVP API和查询字符串params发送HttpWebRequest之外,我真的不明白你发送请求的方式是否有所不同。 It's all just over Http so can't you use HttpWebRequest also over a SOAP API (using WSDL)? 它只是在Http上,所以你不能在SOAP API上使用HttpWebRequest(使用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 首先从元数据生成服务引用:右键单击项目 - >添加服务引用并指向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);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM