The header is added via message inspector which implements IClientMessageInspector in method
public object BeforeSendRequest(ref Message request, IClientChannel channel)
{
var reqMsgProperty = new HttpRequestMessageProperty();
reqMsgProperty.Headers.Add("SOAPAction", "SendEcho");
reqMsgProperty.Headers.Add("Content-Type", "text/xml;charset=UTF-8");
request.Properties[HttpRequestMessageProperty.Name] = reqMsgProperty;
//...
return null;
}
But still it returns this weird message:
The SOAP action specified on the message, '"SendEcho"', does not match the action specified on the HttpRequestMessageProperty, 'SendEcho'.
Is it possible that this header should be added in some other way so it wouldn't have the double quotes surrounding it like a string? If yes then how?
CodePudding user response:
The SOAPAction HTTP header is required for SOAP 1.1 communication, but not required for SOAP 1.2 communication.WCF follows this specification and only includes this header when using SOAP 1.1.
What binding do you use? BasicHttpBinding uses SOAP 1.1, but WSHttpBinding uses SOAP 1.2 and WS-Addressing 1.0.
You can read:
SOAPAction HTTP header field specification and this thread
You also can try to define your own custom binding:
How to add a custom HTTP header to every WCF call?
Adding Http Header in an existing WCF SOAP Service is not working