Consume soap service with Xamarin.Forms

tinglitingli USUniversity ✭✭

Hello,

I am trying to use soap service.

In a MVC project, I can generate the proxy and use methods, which is fine.

In a Xamarin.Form project, I can use same wsdl to successfully generate the proxy, but some methods don't exist.

Anybody got an idea?

Thanks

Ting

Answers

  • rene_ruppertrene_ruppert DEXamarin Team, University, XamUProfessors Xamurai

    Hi @tingli ! Is the service public so I can give it a try?

  • tinglitingli USUniversity ✭✭

    Hi @rene_ruppert

    Unfortunately, it is not public, it has to be accessed via a vpn. Or if you can give me your email, I'll send you the accessing information.

    I uploaded three file, please have a look if it is possible.
    one is wsdl file, and another two are proxy files from Xamarin PCL project and MVC respectively.

    Could you please have a look at proxy files, and find out why they are different for me, please?

    For example, in WebServiceSchoolsSoapClient class, there is a method call mLogon,

    in the MVC genereated proxy, this method takes two parameters,
    public WebApplication1.ServiceReference1.mLogonResponse mLogon(ref WebApplication1.ServiceReference1.JadeSessionHeader JadeSessionHeader, WebApplication1.ServiceReference1.mLogon mLogon1)

    // JadeSessionHeader is very important as it contains session Id

    in the Xamarin PCL generated proxy, this method only takes ONE parameter,
    public void mLogonAsync(MyApp.ServiceProxy.mLogon mLogon)

    So this has been confusing me for really a long time, as I don't know how to do with it.

    I do really appreciate if you can give any help.

    Thanks

    Ting

  • rene_ruppertrene_ruppert DEXamarin Team, University, XamUProfessors Xamurai

    I do not know why the proxies are different. However: why don't you simply add the working proxy *.cs to you Xamarin project? It's really all you need. Add it and see if you can build your project. Once that works, go ahead, configure the required parameters in your client and use it.

    I gave it a quick try and was able to add it to an iOS project and build it after adding the System.ServiceModel assembly. It won't work in a PCL though because of the missing System.SerializableAttribute.

    Your service reference is really big. Generally, it is not recommended (anymore) to use SOAP/WCF based services in mobile apps. If you have to use them, my recommendation is to create a REST based proxy server which relays your calls. The mobile app would contact the REST API and the Server can use the full WCF stack to talk to the original service.

  • tinglitingli USUniversity ✭✭

    Thanks @rene_ruppert

    I will look into if I can add the working proxy to my project.

Sign In or Register to comment.