2011-02-10 69 views
0

我想通過PayPal使用SOAP接口開始自適應付款。 當添加服務引用https://svcs.sandbox.paypal.com/AdaptivePayments?WSDL以下警告由Visual Studio所示:在C#中使用Paypal自適應付款開始SOAP

自定義工具警告:無法導入WSDL:結合 詳細信息:WSDL綁定命名AdaptivePaymentsSOAP11Binding是無效的,因爲鬥不過操作CancelPreapproval被發現在相應的portType定義中。 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異常:

找不到引用合同「PaypalSandboxApi.AdaptivePaymentsPortType」在ServiceModel客戶端的默認終結點元素配置部分。這可能是因爲沒有找到適用於您的應用程序的配置文件,或者因爲在客戶端元素中找不到匹配此合同的端點元素。

我錯過了什麼嗎?

我應該使用缺少的AdaptivePaymentsSOAP11Binding而不是AdaptivePaymentsPortTypeClient

回答

1

它看起來像導入此WSDL不會生成servicemodel配置。我kludged一個這樣在一起(和更新相關的類名來匹配你的,所以你可以複製/粘貼):

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

+0

謝謝。從那以後,我切換到簡單的XML並解決了這個問題。 – UrK 2011-06-29 08:08:24

相關問題