I have to implement a SOAP 1.1 web service in ASP.NET. I am given request and response examples and a glitchy wsdl spec that, when fed to the wsdl-->code wizard, doesn't produce code that gives correct response. So I am stuck with manual fixing of the auto-generated C# code.
Here is the response one of the methods must produce:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sws="http://something/WebService">
<soapenv:Header/>
<soapenv:Body>
<sws:MyActionResponse>
<sws:returnVariableOne>?</sws:returnVariableOne>
<sws:returnVariableTwo>?</sws:returnVariableTwo>
<sws:returnVariableThree>?</sws:returnVariableThree>
</sws:MyActionResponse>
</soapenv:Body>
</soapenv:Envelope>
I can't find a way how to make the <sws:MyActionResponse>
contain several elements, in the specified order.
I have this code that produces only one child under the <sws:MyActionResponse>
element:
[System.Web.Services.WebMethodAttribute()]
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://something/WebService/MyAction", RequestElementName="MyActionRequest", RequestNamespace="http://something/WebService", ResponseNamespace="http://something/WebService", ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped, Use=System.Web.Services.Description.SoapBindingUse.Literal)]
[return: System.Xml.Serialization.XmlElementAttribute("returnVariableOne")]
public override string MyAction(string inputVariable)
{
return "Value of variable #1";
}
The response xml from it looks like this:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<MyActionResponse xmlns="http://something/WebService">
<returnVariableOne>Value of variable #1</returnVariableOne>
</MyActionResponse>
</soap:Body>
</soap:Envelope>
Well, I need three child elements there, so I am looking for the C# syntax that causes the WebMethod to return sequence of several elements in prescribed order. I am aware that I could return one complex element with complex data structures inside it, but that doesn't help because I have to match the xml response sample I am given in the spec.