簡體   English   中英

使用WebHttpBinding的傳出消息上的SOAPAction標頭

[英]SOAPAction header on Outgoing message with WebHttpBinding

我試圖發出一個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");
        }

測試此代碼時,標頭Test在請求中,而SOAPAction沒有。 我嘗試了使用IClientMessageInspector,但是它也不起作用。 我不能使用其他綁定(基本綁定或更多Soap專用綁定)。

據我所知,SOAPAction字段是HTTP標頭默認字段,用於指示服務器服務使用非webhttp綁定時正在調用的操作方法。
我不認為可以通過截取消息/操作上下文來任意指定它。 在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM