シナリオは次のとおりです。SOAPメッセージを仲介ルータサービスに送信しようとしています。そのサービスは自分のSOAPメッセージヘッダーだけを気にし、WS-AddressingTo
ヘッダーを使用してメッセージに転送します。MessageHeaders.Toフィールドの設定が上書きされる
:私は問題なくCustom Behaviorsを使用してルーティング・サービスが必要で、他のカスタムヘッダーを設定することができ、現在よ
POST http://gatewayRouter/routingService HTTP/1.1
Content-Type: application/soap+xml; charset=utf-8
Host: gatewayRouter
Content-Length: 8786
Expect: 100-continue
Connection: Keep-Alive
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope"
xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header> <!-- ... -->
<a:To s:mustUnderstand="1">http://actualDestination</a:To>
</s:Header> <!-- ... body, /envelope, etc --->
を:
public object BeforeSendRequest(ref Message request, IClientChannel channel)
{
MessageBuffer buffer = request.CreateBufferedCopy(Int32.MaxValue);
request = buffer.CreateMessage();
request.Headers.To = new Uri("http://actualDestination");
request.Headers.Add(new CustomHeader());
return null;
}
上記のコードは、CustomHeaderをメッセージに追加するのにうまく動作しますが、発信WS-Addressing To
フィールドを変更できません。常にHTTP POST値と同じURIに設定されます。実際、.NET Reflectorを使用して、このフィールドが設定されたときにデバッグしました。十分に上書きされています(screenshot of the stack trace and breakpoint)。
私が正しく理解していないTo
SOAPヘッダーを変更する他の方法はありますか?