I'm calling a soap web service that is very strict on the request from inside an asp.net core API. by overriding OnWriteStartBody,OnWriteBodyContents,OnWriteStartEnvelope methods in the System.ServiceModel.Channels.Message class. my XML
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://POWebservice/">
<soapenv:Body>
<ns1:myaction
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<trantype>purchase</trantype>
<tranamount>94999.23</tranamount>
</ns1:myaction>
</soapenv:Body>
</soapenv:Envelope>
what they expect :
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://POWebservice/">
<soapenv:Body>
<ns1:myaction>
<trantype>purchase</trantype>
<tranamount>94999.23</tranamount>
</ns1:myaction>
</soapenv:Body>
</soapenv:Envelope>
i want to get rid of xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" I have been able to modify some of the payload using
protected override void OnWriteStartEnvelope(XmlDictionaryWriter writer)
{
writer.WriteStartElement("soapenv", "Envelope", "http://schemas.xmlsoap.org/soap/envelope/");
}
i have also attempted to implement the IClientMessageInspector but the intercepted message in BeforeSendRequest had only the header and not the body. plus it had too many hacks .