I downloaded the eBay SDK for use in an internal application we are developing. The catch is we are developing on Mono. When I run the eBay Hello World sample on .NET, it displays the following output:
+++++++++++++++++++++++++++++++++++++++
+ 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
When I run it with Mono, I get the following:
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...
I found a workaround and will post it in an answer below.
I searched Xamarin's Bugzilla and found nothing, but I found this relevant bug posted in Novell's old Mono Bugzilla: https://bugzilla.novell.com/show_bug.cgi?id=693367
So I dug through the eBay SDK source and found that this was indeed the issue.
eBay.Service.Core.Sdk.eBayAPIInterfaceService2
inherits fromeBay.Service.Core.Sdk.eBayAPIInterfaceService
, which is decorated with aSystem.Web.Services.WebServiceBindingAttribute
.So I changed
eBay.Service.Core.Sdk.eBayAPIInterfaceService2
, adding[System.Web.Services.WebServiceBindingAttribute(Name = "eBayAPISoapBinding", Namespace = "urn:ebay:apis:eBLBaseComponents")]
so that it now looks like the following:I followed the instructions in the eBay SDK for building from the sources and the problem was solved.
Footnote: Incidentally, if this is your first time using Mono to connect to an HTTPS web service, you will likely immediately run into another exception. That one will look like this:
For the solution to that, go here: http://www.mono-project.com/FAQ:_Security