2013-11-27 77 views
3

我下載了eBay SDK以用於我們正在開發的內部應用程序。我們正在Mono上發展。當我運行在.NET上易趣的Hello World樣本,它會顯示以下輸出:eBay C#SDK無法在Mono上工作

+++++++++++++++++++++++++++++++++++++++ 
+ Welcome to eBay SDK for .Net Sample + 
+ - HelloWorld      + 
+++++++++++++++++++++++++++++++++++++++ 
Begin to call eBay API, please wait ... 
End to call eBay API, show call result: 
eBay official Time: 11/27/2013 3:02:19 PM 

當我使用Mono運行它,我得到如下:

Unhandled Exception: eBay.Service.Core.Sdk.ApiException: Exception has been thrown by the target of an invocation. 
---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. 
---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. 
---> System.InvalidOperationException: WebServiceBindingAttribute is required on proxy class 'eBay.Service.Core.Sdk.eBayAPIInterfaceService2'. 
at System.Web.Services.Protocols.SoapTypeStubInfo..ctor (System.Web.Services.Protocols.LogicalTypeInfo logicalTypeInfo) [0x00000] 
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (object,object[],System.Exception&) 
etc...etc...etc... 

我找到了一個解決辦法,並會將其張貼在下面的答案中。

+0

的是什麼版本的單? – knocte

+0

我正在使用3.2.3,但根據我在下面的答案中發佈的Novell Bugzilla報告,此錯誤自至少2.10.x起已存在。 –

+0

這個bug可能是從0.1版本開始的;)請你總是問一個關於單聲道的問題,指定你正在使用的版本 – knocte

回答

5

我搜索Xamarin的Bugzilla並沒有發現什麼,但我發現張貼在Novell的舊黑白的Bugzilla此相關的bug:https://bugzilla.novell.com/show_bug.cgi?id=693367

所以我通過eBay的SDK源挖,發現這確實是問題。 eBay.Service.Core.Sdk.eBayAPIInterfaceService2繼承自eBay.Service.Core.Sdk.eBayAPIInterfaceService,裝飾有System.Web.Services.WebServiceBindingAttribute

因此,我改變eBay.Service.Core.Sdk.eBayAPIInterfaceService2,增加[System.Web.Services.WebServiceBindingAttribute(Name = "eBayAPISoapBinding", Namespace = "urn:ebay:apis:eBLBaseComponents")],以便它現在看起來如下:

using System; 
using System.Net; 
using eBay.Service.Core.Soap; 

namespace eBay.Service.Core.Sdk { 
    /// <summary> 
    /// Enhanced eBayAPIInterfaceService with GZIP compression support. 
    /// </summary> 
    [System.Web.Services.WebServiceBindingAttribute(Name = "eBayAPISoapBinding", Namespace = "urn:ebay:apis:eBLBaseComponents")] 
    internal class eBayAPIInterfaceService2 : eBayAPIInterfaceService { 
     ... 
    } 
} 

我跟着eBay的SDK中的說明,從源頭建立,問題就解決了。


腳註:順便說一句,如果這是使用單聲道連接到HTTPS Web服務的第一次,你可能會立即運行到另一個例外。這一個看起來像這樣:

Unhandled Exception: System.Net.WebException: Error getting response stream (Write: The authentication or decryption has failed.): SendFailure ---> System.IO.IOException: The authentication or decryption has failed. ---> Mono.Security.Protocol.Tls.TlsException: Invalid certificate received from server. Error code: 0xffffffff800b010a 
at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.validateCertificates (Mono.Security.X509.X509CertificateCollection certificates) [0x00000] in <filename unknown>:0 
at Mono.Security.Protocol.Tls.Handshake.Client.TlsServerCertificate.ProcessAsTls1() [0x00000] in <filename unknown>:0 
at Mono.Security.Protocol.Tls.Handshake.HandshakeMessage.Process() [0x00000] in <filename unknown>:0 
at (wrapper remoting-invoke-with-check) Mono.Security.Protocol.Tls.Handshake.HandshakeMessage:Process() 
at Mono.Security.Protocol.Tls.ClientRecordProtocol.ProcessHandshakeMessage (Mono.Security.Protocol.Tls.TlsStream handMsg) [0x00000] in <filename unknown>:0 
at Mono.Security.Protocol.Tls.RecordProtocol.InternalReceiveRecordCallback (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
--- End of inner exception stack trace --- 
at Mono.Security.Protocol.Tls.SslStreamBase.AsyncHandshakeCallback (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
--- End of inner exception stack trace --- 
at System.Net.HttpWebRequest.EndGetResponse (IAsyncResult asyncResult) [0x00000] in <filename unknown>:0 
at System.Net.HttpWebRequest.GetResponse() [0x00000] in <filename unknown>:0 

爲了解決這個,去這裏:http://www.mono-project.com/FAQ:_Security

+0

感謝分享! – avs099

+0

在此處報告了Xamarin的錯誤:https://bugzilla.xamarin.com/show_bug.cgi?id = 16479 –