我正在尝试通过Paypal使用SOAP接口启动Adaptive Payments。 向https://svcs.sandbox.paypal.com/AdaptivePayments?WSDL添加服务引用时,Visual Studio会显示以下警告:
自定义工具警告:无法导入wsdl:binding 详细信息:名为AdaptivePaymentsSOAP11Binding的WSDL绑定无效,因为在相应的portType定义中找不到操作CancelPreapproval的匹配项。 XPath到错误源://wsdl:definitions[@targetNamespace='http://svcs.paypal.com/services']/wsdl:binding[@name='AdaptivePaymentsSOAP11Binding'] C:\ cproj \ daemon \ Service References \ PaypalSandboxApi \ Reference.svcmap 1 1守护进程
放弃此消息,成功添加了引用。 为了执行事务,我尝试创建客户端:
var client = new PaypalSandboxApi.AdaptivePaymentsPortTypeClient()
抛出InvalidOperationException:
无法在ServiceModel客户端配置部分中找到引用合同“PaypalSandboxApi.AdaptivePaymentsPortType”的默认端点元素。这可能是因为没有为您的应用程序找到配置文件,或者因为在客户端元素中找不到与此合同匹配的端点元素。
我错过了什么吗?
我应该使用丢失的AdaptivePaymentsSOAP11Binding
而不是AdaptivePaymentsPortTypeClient
吗?
答案 0 :(得分:1)
看起来导入此WSDL不会生成servicemodel配置。我像这样把一个人弄得一团糟(并更新了相关的类名以匹配你的,所以你可以复制/粘贴):
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="PaypalAdaptivePayBinding" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="1048576" maxBufferPoolSize="1048576" maxReceivedMessageSize="1048576" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="65536" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="https://svcs.sandbox.paypal.com/AdaptivePayments"
binding="basicHttpBinding" bindingConfiguration="PaypalAdaptivePayBinding"
contract="PaypalSandboxApi.AdaptivePaymentsPortType"
name="PaypalAdaptivePay" />
</client>