I have a WCF service with an IDispatchMessageInspector
and a BeforeSendReply
method which modifies the message's WS-Addressing headers. This works for all headers, except for wsa:To, which is being stripped from the reply...
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;
}
This results in:
<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>
Even though result.ToString()
(result = Message
type) gives me:
<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>
So... Why is the wsa:To
header stripped from my reply?