简体   繁体   English

使用WebHttpBinding的传出消息上的SOAPAction标头

[英]SOAPAction header on Outgoing message with WebHttpBinding

I tried to emit an http header but somehow wcf filters it. 我试图发出一个http标头,但是wcf却以某种方式对其进行了过滤。

[ServiceContract()]
public interface IHelloWorld
{
    [OperationContract(Action = "*", IsOneWay = false, ReplyAction = "*")]
    void Hello(string text);
}

        var channel = new ChannelFactory<IHelloWorld>(new WebHttpBinding(), "http://some.where");
        channel.Endpoint.Behaviors.Add(new WebHttpBehavior());
        var proxy = channel.CreateChannel();
        using (OperationContextScope scope = new OperationContextScope((IContextChannel)proxy))
        {
            MessageProperties messageProperties = OperationContext.Current.OutgoingMessageProperties;

            var requestMessageProperty = new HttpRequestMessageProperty();
            messageProperties.Add(HttpRequestMessageProperty.Name, requestMessageProperty);

            requestMessageProperty.Headers.Add("SOAPAction", "test");
            requestMessageProperty.Headers.Add("Test", "test2");

            proxy.Hello("test");
        }

When testing this code, the header Test is in the request but SOAPAction is not. 测试此代码时,标头Test在请求中,而SOAPAction没有。 I tried with a IClientMessageInspector but it doesn't work either. 我尝试了使用IClientMessageInspector,但是它也不起作用。 I cannot use another binding (Basic or a more Soap dedicated one). 我不能使用其他绑定(基本绑定或更多Soap专用绑定)。

As far as I know the SOAPAction field is the HTTP header default field and is used to indicate that the action method being invoked when server service uses a non-webhttpbinding. 据我所知,SOAPAction字段是HTTP标头默认字段,用于指示服务器服务使用非webhttp绑定时正在调用的操作方法。
I don't think it could be arbitrarily specified by intercepting the message/operation context. 我不认为可以通过截取消息/操作上下文来任意指定它。 在此处输入图片说明

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

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