我正在开发我的第一个WCF Web服务,我需要将传入的Soap消息加载到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 :(得分:0)
所以,现在我可以回答我自己的问题了。
要获取传入的肥皂消息,我使用了
String rq = System.ServiceModel.OperationContext.Current.RequestContext.RequestMessage.ToString();
然后将它加载到XmlDocument中,如下所示:
XmlDocument doc = new XmlDocument();
doc.LoadXml(RQ);