使用 PayPal SOAP API 发送 API CAll

发布于 2024-08-18 09:37:11 字数 332 浏览 6 评论 0原文

好的,我的 .NET 项目中有服务引用。是的,我知道您现在可以访问代理类。

但在过去,我习惯于使用 NVP 通过 HttpWebRequest 对象执行此操作,但从未尝试过使用 WSDL 并以这种方式发送 SOAP 请求。

我不太确定使用哪个对象来发送请求。不知道从哪里开始。我查看了文档,但没有看到 .NET 和 PayPal 的好的示例。

除了 WSDL 与通过 NVP API 和查询字符串参数发送 HttpWebRequest 之外,我真的不明白发送请求的方式是否存在差异。这一切都通过 Http 进行,所以您不能通过 SOAP API(使用 WSDL)使用 HttpWebRequest 吗?

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 params, 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)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

后eg是否自 2024-08-25 09:37:12

首先从元数据生成服务引用:右键单击项目 ->添加服务引用并指向 WSDL url:https://www.sandbox.paypal.com /wsdl/PayPalSvc.wsdl

这将为当前项目生成可用于发送请求的代理类:

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

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);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文