0

I need to consume asmx webservices from a Xamarin Forms app (ios and Android). Yes, I know asmx is outdated, but I can't do otherwise.

So I add the webservice with the add 'connected services' to the main Xamarin Forms project, since there is no "add web service" menu item there. I use the second menu item 'Microsoft WCF web service reference provider". I correctly select the asmx service, configure it and everything looks in order. Now when I consume a webservice method that has a header (TestHeader class, let's say it has a TestString in it), on the webservice the header object has default values (TestString is null).

The weird thing is that if I create a similar desktop project, do the same exact configuration steps (add connected services, etc), the Reference.cs and json code generated is the exact same, but the soapheader gets correctly passed to the webservice !

[Serializable]
public class TestHeaderClass : SoapHeader
    {
    public int TestInt { get; set; }
    public string TestString { get; set; }
    }

public TestHeaderClass TestHeader { get; set; }        

[WebMethod][SoapHeader("TestHeader")]        
public string HelloWorld()
   {
   return TestHeader.TestString;
   }
andycted
  • 812
  • 6
  • 13

0 Answers0