接受SOAP输入作为web服务中的参数

问题描述:

我有一个web服务方法,它需要接受SOAP作为输入参数。我在.NET客户端之间工作过webservices,但我从未使用过原始SOAP,所以我不知道该怎么做。输入格式如下:接受SOAP输入作为web服务中的参数

<?xml version="1.0" encoding="utf-8"?> 
<S:Envelope xmlns:S = "http://schemas.xmlsoap.org/soap/envelope/"> 
    <S:Body> 
     <ns2:RemoteService xmlns:ns2 = "some.ns.url"> 
      <RemoteServiceInput> 
       <param1>123</param1> 
       <param2>Asd Qwe</param2> 
       <param3 xsi:nil = "true" xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"/> 
      </RemoteServiceInput> 
     </ns2:RemoteService > 
    </S:Body> 
</S:Envelope> 

我的方法输入应该如何接受这个SOAP作为参数?

我正在使用ASP.NET Web服务而不是WCF。

您可以创建一个接受的XElement作为参数,一个WebMethod(在一天结束SOAP是XML):

[WebMethod] 
public mySoapMethod(XElement soapMessage) 
{ 
    //here you can parse your soap message 
}