9
我打了一個使用WSDL的WCF服務我無權訪問並且無法修改。對於因爲我們發送的遠程服務是死於請求之一:使用IClientMessageInspector從WCF肥皂請求中刪除操作節點mustUnderstand
<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爲空後,我刪除所有元素,我仍然看到Action節點在XML中發出。
- 我該做些什麼來完成這項工作?
- 如何獲取 消息內容,以便我可以檢查第一個節點的名稱 正文標籤retrieveBooking在這種情況下? (我只需要做 這是針對一個特定的消息,不是全部)