我在 C# 客户端中创建的 SOAP 标头有问题。服务器正在发回错误
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<s:Header xmlns:s="http://www.w3.org/2003/05/soap-envelope" />
<soap:Body>
<soap:Fault>
<soap:Code>
<soap:Value>soap:MustUnderstand</soap:Value>
</soap:Code>
<soap:Reason>
<soap:Text xml:lang="en">MustUnderstand headers: [{http://www.w3.org/2005/08/addressing}To] are not understood.</soap:Text>
</soap:Reason>
</soap:Fault>
</soap:Body>
</soap:Envelope>
Run Code Online (Sandbox Code Playgroud)
我的印象是我已经使用以下代码删除了所有 SOAP 标头。
internal class CustomMessageInspector : IEndpointBehavior, IClientMessageInspector
{
public object BeforeSendRequest( ref Message request, IClientChannel channel )
{
request.Headers.Clear();
return null;
}
...
}
Run Code Online (Sandbox Code Playgroud)
但是,在 app.config 中激活 System.ServiceModel.MessageLogging 后(WCF - 检查正在发送/接收的消息?),我看到服务器是正确的 - 你瞧,有一个带有“mustUnderstand”的“To”标头设置为 1 :
<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">https://ws-single-transactions-int-bp.nmvs.eu:8443/WS_SINGLE_TRANSACTIONS_V1/SinglePackServiceV30</a:To>
</s:Header>
Run Code Online (Sandbox Code Playgroud)
有什么想法可以阻止添加此标头吗?
非常感谢。