简体   繁体   English

C# WCF SOAP 对消息“SendEcho”指定的操作与 HttpRequestMessageSendEcho 上指定的操作不匹配,

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

The header is added via message inspector which implements IClientMessageInspector in method 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;
            }

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'.消息“SendEcho”上指定的 SOAP 操作与 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?这个 header 是否有可能应该以其他方式添加,这样它就不会像字符串一样被双引号包围? If yes then how?如果是,那怎么办?

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. 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. BasicHttpBinding 使用 SOAP 1.1,但 WSHttpBinding 使用 SOAP 1.2 和 WS-Addressing 1.0。
You can read: SOAPAction HTTP header field specification and this thread您可以阅读: SOAPAction HTTP header 字段规范此线程
You also can try to define your own custom binding:您还可以尝试定义自己的自定义绑定:
How to add a custom HTTP header to every WCF call? 如何将自定义 HTTP header 添加到每个 WCF 调用?
Adding Http Header in an existing WCF SOAP Service is not working 在现有 WCF Z4DE91F0FCB9CD3A20B6B1D64610A0A3D 中添加 Http Header Z4DE91F0FCB9CD3A20B6B1D64610A0A3D

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM