Step to call a soap webservice

GeekayGeekay USUniversity ✭✭
edited January 2016 in Xamarin.Forms

Hi

I have been struggling to call a asmx web service using xamarin form. I added my web service in the PLC project by right click => Add => service reference. Below is the way I call it. I am using android phone for this.

`public void Register(string mobile)
{
var test = new ServiceReference.RSDSoapClient();
test.SyncFormScoreCompleted += (object sender, SyncFormScoreCompletedEventArgs e) => {
var tttt = e.Result.ToString(); //The results alwasy null.
};

       test.SyncFormScoreAsync();

}`

at EngenIBDApplication.ServiceReference.RSDSoapClient.EndSyncFormScore (IAsyncResult result) [0x00009] in c:\Projects\EngenIBDApplication\EngenIBDApplication\EngenIBDApplication\Service References\ServiceReference\Reference.cs:3387
at EngenIBDApplication.ServiceReference.RSDSoapClient.OnEndSyncFormScore (IAsyncResult result) [0x00001] in c:\Projects\EngenIBDApplication\EngenIBDApplication\EngenIBDApplication\Service References\ServiceReference\Reference.cs:3395
at System.ServiceModel.ClientBase`1+c__AnonStorey0[TChannel].<>m__0 (IAsyncResult ar) [0x00006] in /Users/builder/data/lanes/2512/d3008455/source/mono/mcs/class/System.ServiceModel/System.ServiceModel/ClientBase.cs:242

Posts

  • HunumanHunuman GBMember ✭✭✭✭

    Hi Geekay,

    I had the same problem.
    It turned out that the classes needed to support .net 2.0 style web services are not available inside the PCL.
    However these classes are available in the Android/IOS projects.

    So your options are:

    1. use WCF instead of old style .net 2.0 remote procedural calls in your PCL.
      Have a look at https://docs.xamarin.com/guides/xamarin-forms/web-services/consuming/wcf/

    or

    1. Expose the web service from the android project into the Xamarin.Forms project(s)
      Have a look at https://docs.xamarin.com/guides/xamarin-forms/web-services/consuming/asmx/

    Hope this helps,

    Tim

    PS Love the avatar picture, reminds me of my daughter.

  • GeekayGeekay USUniversity ✭✭

    Thanks for the response. I managed to do it like this. http://stackoverflow.com/questions/14336414/httpclient-soap-c/20108971#20108971

  • HunumanHunuman GBMember ✭✭✭✭

    Nice find Geekay, though personally I would not use that methodology.

    Hard coding against a service description is OK if you are certain the service description will never ever change.
    Even then I would still shy away from it, since change is more likely than not, in a commercial environment.

    Its much cleaner to simply update a service reference and amend application logic to deal with changes as needed.

    Just my 2 cents,

    Tim

  • CrosevenCroseven USMember ✭✭

    I have the exact same problem in one project, but with another project it just works and I have no idea what I did to manage it to get working

  • CrosevenCroseven USMember ✭✭
    edited April 2016

    Managed to get it working again with the web.conf

    http://codepaste.net/5jpexb

    I am not sure yet wich one it is that made it to work.

    BUT after I added these lines (Note the path of the .asmx file or wcf file) I also went to my project and updated the service reference. I will do more tests but this is exactly what I did

  • srfytjhsrfytjh USMember

    hi croseven
    your link leads no where , kindly republish

Sign In or Register to comment.