'Problem with .NET web service accepting an xmlnode as a webmethod parameter
I have a web service (asmx) web method defined like this :
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class CisalWebServ : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld(string secretkey, XmlNode terajob)
{
return "pending...";
}
}
When I send the request via postman this is the xml that I'm sending..
<?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>
<HelloWorld xmlns="http://tempuri.org/">
<passcode>mypasscode</passcode>
<terajob>
<teraId>1</teraId>
<kustama>2</kustama>
<soyani>job2</soyani>
</terajob>
</HelloWorld>
</soap:Body>
</soap:Envelope>
However, when I check the XmlNode teraJob's innerXML .. it only shows one element (teraId). I was expecting it to show all the element's inside of 'terajob'
Is this not the case?
If i change the xml to :
<?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>
<HelloWorld xmlns="http://tempuri.org/">
<passcode>mypasscode</passcode>
<terajob>
<terajob>
<teraId>1</teraId>
<kustama>2</kustama>
<soyani>job2</soyani>
</terajob>
</terajob>
</HelloWorld>
</soap:Body>
</soap:Envelope>
I get all three elements.
<teraId>,<kustama> and <soyani>
Why is this? Why do i have to add the xml element terajob twice?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
