2017-05-31 48 views
-1

我開發我的第一個WCF web服務,我需要將傳入的SOAP消息加載到xml dom中進行處理,但我無法找到如何執行此操作。 我想:c#如何將傳入的soap1.2消息加載到xml dom

namespace acdCM 
{ 

    [ServiceContract] 
    public interface IResNotif 
    { 
     [OperationContract] 
     [XmlSerializerFormat] 
     XmlDocument OTA_HotelResNotifRQ(); 
    } 
} 

namespace acdCM 
{ 

    public class ResNotif : IResNotif 
    { 
     public XmlDocument OTA_HotelResNotifRQ() 
     { 
      XmlDocument doc = new XmlDocument(); 
      doc.LoadXml(System.Web.Services.Protocols.SoapMessage.ToString()); 

      ....... 
     } 
    } 
} 

這是因爲的SOAPMessage不能用來作爲一個字符串完全不工作。

我的問題是,我無法找到如何從傳入的SoapMessage中創建一個字符串,以便我可以將它加載到XmlDocument中。

+0

請仔細閱讀[問]並解釋「根本不起作用」的意思。 – CodeCaster

+0

您是否在使用/撥打肥皂服務?或者你正在創建一個主機服務?在服務契約上,返回類型XmlDocument沒有意義。 – loopedcode

+0

@CodeCaster - 嗨,感謝您的期待。我有點編輯我的文章 - 我希望我的困境現在解釋得更清楚。 – Craig

回答

0

所以,現在我可以回答我自己的問題。

要獲得傳入的SOAP消息中,我使用

字符串RQ = System.ServiceModel.OperationContext.Current.RequestContext.RequestMessage.ToString();

然後將其加載到這樣一個如下:

XmlDocument的DOC =新的XmlDocument();

doc.LoadXml(rq);