How to I control parameter type tag in ASP.NET web service? I get < xml>string< /xml> in one web application and < data>string< /data> in other… Is there a way to control this?
[WebMethod]
public bool TestFunction(string xml)
{
//DO SOMETHING
return true;
}
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<TestFunction xmlns="http://tempuri.org/">
<xml>string</xml> //<data>string</data>
</TestFunction>
</soap:Body>
</soap:Envelope>
edit: I forgot to rename function
Any method is exposed using the parameter names you specify. If you change your method to
public bool TestFunction(string FooBar), then the string will be in a<FooBar>string</FooBar>tag in the resulting XML.When you are using WCF you can change this behavior using Message Contracts or applying a MessageParameter to instruct the serializer to use an alternate name:
However, I don’t know whether this also applies to ASP.Net web services.