I have been searching the web for the last 2-3 days and remain unable to figure this one out - so now I come to you guys in the hopes that you know a solution.
I am trying to make a mocked SOAP service for a client and have made a SOAP service in visual studio. The following is the code for the SOAP action that needs to be mocked.
[WebService(Namespace = "http://mynamespace.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class MyServiceStub1 : System.Web.Services.WebService, MyServiceBindingSoap
{
[WebMethod]
[SoapDocumentMethod(Action = "http://mynamespace.com/MySoapAction",
ParameterStyle = SoapParameterStyle.Bare)]
[return: System.Xml.Serialization.XmlElementAttribute("SomeWrapperXML")]
public MyActualResponseType MyServiceRequest(
[XmlElement(ElementName = "MyRequestName")] MyServiceRequestType myServiceRequest)
{
return new MyActualResponseType();
}
And I get the following response
<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>
<SomeWrapperXML">
<MyActualResponseType>
</MyActualResponseType>
</SomeWrapperXML>
</soap:Body>
</soap:Envelope>
However, my clients expect the response to look like this
<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>
<MyActualResponseType>
</MyActualResponseType>
</soap:Body>
</soap:Envelope>
And since I cannot change the code on my clients side, I have to fix this from my side. Is there any way I can avoid getting the XML tag "SomeWrapperXML" in my response?
Setting XmlElementAttribute("") did not help and avoiding it altogether will just make it default to something else. I have also looked at the MSDN post for altering the SOAP message, but that solution seems a bit hacky.