2017-03-09 6 views
3

메시지의 WS-Addressing 헤더를 수정하는 IDispatchMessageInspectorBeforeSendReply 메서드가있는 WCF 서비스가 있습니다. 이는 WSA를 제외하고 모든 헤더 작동 : 응답에서 제거되고있는,에 ...WCF가 내 답장 메시지의 wsa : To 헤더를 제거한 이유는 무엇입니까?

public void BeforeSendReply(ref Message reply, object correlationState) 
{ 
    reply.Headers.To = new Uri("urn:something:something:something"); // Why won't this show up in the response? 

    reply.Headers.From = new EndpointAddress("urn:blabla:blabla"); 
    reply.Headers.MessageId = MessageIDHelper.CreateNew(); 
    reply.Headers.ReplyTo = new EndpointAddress(Definitions.WSA_REPLYTO_ANONYMOUS); 
    reply.Headers.Action = Definitions.WSA_ACTION_SOMETHING_SOMETHING; 
} 

이 결과 :

<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope"> 
    <s:Header> 
    <a:Action s:mustUnderstand="1">http://xxx.xx/xxx/Messages/1/Send</a:Action> 
    <a:RelatesTo>SOME_ID_WHATEVER</a:RelatesTo> 
    <a:From> 
     <a:Address>urn:xxx.xx:xxx:xxx</a:Address> 
    </a:From> 
    <a:MessageID>urn:uuid:083b5fb7-ff45-4944-b881-b4c590577408</a:MessageID> 
    <a:ReplyTo> 
     <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address> 
    </a:ReplyTo> 
    </s:Header> 
    ... 
</s:Envelope> 

비록 result.ToString() (결과 = Message 유형) 제공 나 :

<s:Envelope xmlns:a="http://www.w3.org/2005/08/addressing" xmlns:s="http://www.w3.org/2003/05/soap-envelope"> 
    <s:Header> 
    <a:Action s:mustUnderstand="1">http://xxx.xx/xxx/Messages/1/Send</a:Action> 
    <a:RelatesTo>SOME_ID_WHATEVER</a:RelatesTo> 
    <a:To s:mustUnderstand="1">urn:xxx.xx:xxx:xxx<a:To> 
    <a:From> 
     <a:Address>urn:xxx.xx:xxx:xxx</a:Address> 
    </a:From> 
    <a:MessageID>urn:uuid:083b5fb7-ff45-4944-b881-b4c590577408</a:MessageID> 
    <a:ReplyTo> 
     <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address> 
    </a:ReplyTo> 
    </s:Header> 
    ... 
</s:Envelope> 

그래서 ... wsa:To 헤더가 내 답장에서 삭제 되었습니까?

답변

1

TransportBindingElement.ManualAddressing 속성의 설명서는 주소 지정 동작에 대한 몇 가지 정보를 제공합니다. 나는. ManuelAddressing의 값이 false로 설정된 경우 보내는 채널은 To :로 구성된 EndpointAddress를 채널의받는 사람을 보내는 메시지에 적용합니다. 이것은 채널에 To : 헤더의 값에 say가 있음을 의미합니다.

이제 BeforeSendReply()은 전송할 채널로 넘겨 받기 전에 서비스 수준에서 메시지의 내용을 수정합니다. 따라서 ManuelAddressing의 값이 false 인 경우 채널은 메시지 헤더에 자체 To : 값을 설정합니다.

ManuelAddressing의 값이 true로 설정 될 때마다 채널은 메시지가 이미 처리 된 것으로 간주하고 추가 정보를 추가하지 않습니다. ManuelAddressing을 True로 설정하려면 web.config 파일에 사용자 정의 바인딩을 만들 수 있습니다.

<customBinding> 
    <binding name="customBinding_manualAddressingEnabled"> 
    <textMessageEncoding /> 
    <httpTransport manualAddressing="true"/> 
    </binding> 
</customBinding>