Forum Cross Platform with Xamarin

Calling a SOAP webservice methods in common code of cross-platform app.

SaadAli.9309SaadAli.9309 USMember


I need help implementing SOAP webservice in cross-platform app. I managed to add a WebReference of the service in "ProjectName.Android" part of the project and successfully called the webservice from the common code (platform independent) using the below code

ProjectName.Android.WifiService.Service service = new SelfCare.Android.WifiService.Service();
var response = service.MethodName (paramters);
It is working on android. Project hasn't been tested on iOS and I think if I just add the same WebRefernce to iOS and apply "
OnPlatform" case statement to initialize the corresponding webservice object (ProjectName.iOS.WifiService.Service service**) and keep rest of the code same, I should be able to run it on iOS aswell.

But my problem is that, the project was created a few months ago and giving many obsolete warnings now. And if I create a new project now, the whole project default structure has changed and now it shows common References, Packages and Properties too. I have attached screenshots for comparison.

And if I add a WebReference to Android part of the project, I cannot reference it from any of the common-code cs files using ProjectName.Droid.Service. Noth VS2013 and Xamarin Studio won't allow me to add a WebReference to the SOAP service. Instead it allows ServiceReference which does not work for SOAP service. And although it allows adding WebReference to individual projects (android,iOS) I cannot reference them from common code.

Please if anyone has any experience in consuming SOAP services let me know.

Thank You.


  • soonfayyeesoonfayyee CAMember

    I had try both Service reference and web reference for SOAP service, the reason I tried both is because windows doesn't support web reference whereas IOS and Android do support. Unfortunately, web reference can't be refer to common-code files perhaps because window app doesn't support web reference and Xamarin studio can't create the compatibility. Here is a sample of service reference by using async task:

    public static Task<List<string>> CheckIfBooked(string ID, string bookingdate)
                TaskCompletionSource<List<string>> completionSource = new TaskCompletionSource<List<string>>();
                MyService.WebServiceSoapClient list = new MyService.WebServiceSoapClient();
                EventHandler<Mb_Check_if_bookedCompletedEventArgs> booked = null;
                List<string> Appdetail = new List<string>();
                booked = (sender, e) =>
                    list.Mb_Check_if_bookedCompleted -= booked;
                  list.Mb_Check_if_bookedCompleted += booked;
                  list.Mb_Check_if_bookedAsync(ID, bookingdate);
                return completionSource.Task;

    However, I did try the same way on xamarin cross platform but I wasn't able to get any result and I cant even update the service reference directly from Xamarin Studio. This code didn't give me error when I build but whenever I click it, it crash without reason, I tried to debug it and all I get is i get a break point at Completed event but no error message popup Example of cross platform service reference:

                        myserv.CustomerLoginCompleted+= (object sender, CustomerLoginCompletedEventArgs e) => {
                                Navigation.PushModalAsync(new Startup());

    No one was able to answer my problem either, I am thinking it's a bug. If someone has successful experience in calling SOAP in cross platform, please share your experiences.

Sign In or Register to comment.