C# WCF 消息“"SendEcho"”上指定的 SOAP 操作与 HttpRequestMessageProperty 'SendEcho' 上指定的操作不匹配

C# WCF The SOAP action specified on the message, '"SendEcho"', does not match the action specified on the HttpRequestMessageProperty, 'SendEcho'

header 是通过在方法

中实现 IClientMessageInspector 的消息检查器添加的
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;
            }

但它仍然是 returns 这个奇怪的消息:

The SOAP action specified on the message, '"SendEcho"', does not match the action specified on the HttpRequestMessageProperty, 'SendEcho'.

是否可以用其他方式添加这个 header,这样它就不会像字符串一样被双引号括起来?如果是那么怎么办?

SOAPAction HTTP header 是 SOAP 1.1 通信所必需的,但 SOAP 1.2 不需要 communication.WCF 遵循此规范,并且仅在使用 SOAP 1.1 时包含此 header。
您使用什么绑定? BasicHttpBinding 使用 SOAP 1.1,但 WSHttpBinding 使用 SOAP 1.2 和 WS-Addressing 1.0。
您可以阅读: 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