2016-08-12 8 views
9

का उपयोग कर डब्ल्यूसीएफ साबुन अनुरोध से हटाना चाहिए मैं डब्लूएसडीएल का उपयोग कर डब्लूसीएफ सेवा पर टक्कर मार रहा हूं, मेरे पास पहुंच नहीं है और संशोधित नहीं किया जा सकता है। अनुरोध दूरस्थ सेवा है क्योंकि हम भेज रहे हैं मर रहा है में से एक के लिए:एक्शन नोड को निकालें ICientMessageInspector

<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 हालांकि रिक्त है के बाद मैं सब को दूर तत्व, मैं अभी भी एक्सएमएल में एक्शन नोड उत्सर्जित कर रहा हूं।

  1. मुझे यह काम करने के लिए क्या करना है?
  2. मैं संदेश सामग्री पर कैसे मिलता है, ताकि मैं बॉडी टैग इस मामले में retrieveBooking के पहले नोड के नाम का निरीक्षण कर सकते हैं? (मुझे केवल को एक विशिष्ट संदेश के लिए यह करने की आवश्यकता है, उन सभी में नहीं)

उत्तर

1

और उत्तर अंत में बहुत सरल हो रहा है।

public object BeforeSendRequest(ref Message aRequest, IClientChannel aChannel) 
{ 
    //For the CabinDetail message the API provider has requested that we REMOVE the XML action node from the header as it causes their end to fail 
    //<s:Header> 
    //<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none" /> 
    //</s:Header> 
    if (aRequest.ToString().Contains("CabinDetail")) 
    { 
     int headerIndexOfAction = aRequest.Headers.FindHeader("Action", "http://schemas.microsoft.com/ws/2005/05/addressing/none"); 
     aRequest.Headers.RemoveAt(headerIndexOfAction); 
    } 

    return null; 
} 
संबंधित मुद्दे