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
-
Did you try my answer?Alejandro Montilla– Alejandro Montilla2017年08月28日 15:02:55 +00:00Commented Aug 28, 2017 at 15:02
-
I am doing it in wcf servicevithushan– vithushan2017年08月29日 05:36:11 +00:00Commented Aug 29, 2017 at 5:36
1 Answer 1
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;
}
answered Aug 28, 2017 at 14:45
-
Can you add an explanation of your code and why it solves the issue? Code only answers are often not that helpful.Zabuzard– Zabuzard2017年08月28日 17:31:38 +00:00Commented Aug 28, 2017 at 17:31
-
Thank's @Zabuza for the suggestion.Alejandro Montilla– Alejandro Montilla2017年08月28日 17:39:53 +00:00Commented Aug 28, 2017 at 17:39
-
I tried with it. But the result is same italic bold
<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>
vithushan– vithushan2017年08月29日 02:55:51 +00:00Commented Aug 29, 2017 at 2:55 -
I am doing it in wcf servicevithushan– vithushan2017年08月29日 05:31:17 +00:00Commented Aug 29, 2017 at 5:31
default