Reputation: 31
There is a php application which will read the result from the web service i have created. The xml response they want is like
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header />
<s:Body>
<WorkResponse xmlns="http://tempuri.org/">
<WorkResult>Name<WorkResult>
<WorkResult>Occupation<WorkResult>
</WorkResult>
</WorkResponse>
</s:Body>
But my method return like this `
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header />
<s:Body>
<WorkResponse xmlns="http://tempuri.org/">
<WorkResult xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<a:string>Name</a:string>
<a:string>Occupation</a:string>
</WorkResult>
</WorkResponse>
</s:Body>`
And below is the method I have written in the web service
public string[] Work()
{
string[] request = new String[2];
request[0] = "Name";
request[1] = "Occupation";
return request;
}
How can I do to get the result they want. Please help me to come out of this issue
Upvotes: 2
Views: 637
Reputation: 2654
If you need WorkResult
node to contain both "Name" and "Occupation" and at the same level in the xml, you can achieve it returning a List
in your WebMethod Work()
. Here is an example:
public List<String> Work()
{
public List<String> result = new List<String>();
result.Add("Name");
result.Add("Occupation");
return result;
}
Upvotes: 1