【发布时间】:2016-08-12 04:30:45
【问题描述】:
我正在使用我无权访问且无法修改的 WSDL 访问 WCF 服务。对于其中一个请求,远程服务正在死亡,因为我们正在发送:
<Action s:mustUnderstand="1"....>
经过广泛搜索,我找不到解决问题的简单方法。所以, 在典型的消息中:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none" />
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<retrieveBooking xmlns="http://services.rccl.com/Interfaces/RetrieveBooking">
<OTA_ReadRQ TransactionActionCode="RetrievePrice" SequenceNmbr="1" Version="1" xmlns="http://www.opentravel.org/OTA/2003/05/alpha">
我想我可以删除这个节点作为消息检查器的一部分:
internal class MyMessageInspector : IClientMessageInspector
{
public object BeforeSendRequest(ref Message aRequest, IClientChannel aChannel)
{
//Get rid of mustUnderstand Action node
foreach (MessageHeaderInfo headerInfo in aRequest.Headers.UnderstoodHeaders)
{
aRequest.Headers.UnderstoodHeaders.Remove(headerInfo);
}
return null;
}
}
但是,即使在我删除所有元素后 aRequest.Headers.UnderstoodHeaders 为空,我仍然看到在 XML 中发出 Action 节点。
- 我必须做些什么才能完成这项工作?
- 如何到达 消息内容,以便我可以检查第一个节点的名称 在这种情况下,主体标签 retrieveBooking? (我只需要做 这是针对特定消息的,而不是所有消息)
【问题讨论】:
标签: c# web-services wcf soap