Using Soap in Shared Mono Library for WP 7 and Android

梦想与她 提交于 2019-12-07 21:15:24

问题


I'm currently working on an shared library based on mono, where I want to put as much business logic of my app as possible. I used this helpful tutorial. I managed putting the whole logic for rest-requests in this shared library, but now I'm stuck with soap.

I used the wsdl command of mono to generate Client Stubcode from my wsdl (as described here http://www.mono-project.com/Web_Services). When I put the generated class to my C# library, which is the root project of my shared library, there is a warning that the Reference to System.Web.Services cannot be found. So I included the System.Web.Services.dll manually. For the Android Library Project I added a Reference to ...\Reference Assemblies\Microsoft\Framework\MonoAndroid\v1.0\System.Web.Services.dll. It compiles without warnings.

But now it comes to the Windows Phone Library Project. There is no System.Web.Services.dll for WP 7.5, right? I tried with the Mono-Touch dll but it gives me a lot compilation Errors.

Someone knows how I can get out of this?


回答1:


I actually had some issues with the generated WSDL myself. Turns out that the classes that were generated through the "Create Web Reference" piece of Visual Studio inside of a Mono for Android project ended up causing some big issues when connected to a WCF Web Service. Not sure where I ran into this information, but this is what I ended up doing.

What you need to do is manually create a Service Reference using the SILVERLIGHT SVCUtil.

On my development system it was located here:

C:\Program Files (x86)\Microsoft SDKs\Silverlight\v3.0\Tools

I called it with the below command line:

slsvcutil.exe http://localhost/<path to WCF service endpoint>/service.svc /directory:"<temp directory to store generated cs file>" /noConfig /namespace:"*,<Full namespace of the generated class>"

That will actually generate a CS file that is saved into the path specified by the /directory tag above. Copy that generated cs file to your project directory and then include it in the project.

The problem that I was having that forced me to look for another option was that I was able to pull the data properly using the WSDL generated through the "Add Web Reference" option in Visual Studio, but as soon as I tried to pass the data back up the wire to the web service, everything blew up. Using the Service Reference generated by the Silverlight Service Util actually generated all the code properly for Async operations and after learning how to properly manage those Async operations everything works like a dream.

Since you are generating this new WSDL using the Silverlight Utility, it should work just fine through Windows Phone 7. I believe that the DLL to reference for all of this is the System.ServiceModel dll.

I wish I could remember where I ran across this information, as I would like to give the original author credit, but unfortunately, I don't recall that.

Hope that helps out!

Chaitanya Marvici



来源:https://stackoverflow.com/questions/10332967/using-soap-in-shared-mono-library-for-wp-7-and-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!