从处理Web方法获取Web服务请求的POST XML

时间:2016-06-15 12:44:58

标签: c# asp.net web-services soap asmx

(我是网络服务的新手,所以我可能会在这里混淆一​​些术语。)

我在visual studio中使用一个带有大量参数的方法(带有属性WebMethod)制作了一个asmx Web服务。在服务器端,这应该用参数做东西并将它们存储在数据库中。

由于存在大量参数(数十个)并且通常不会使用它们中的大多数,因此只有一些参数存储在单独的列中,其余参数应该存储为XML,可能是相同的XML Web服务接收参数 - SOAP POST,就像服务在本地主机上运行时显示的样本一样。

但是XML会自动解压缩到参数中,我不知道如何找到原始XML。访问该XML的最简单/最快的方法是什么?最好只更新处理方法。

上下文的示例C#代码:

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
public class WebService_blip : System.Web.Services.WebService
{

    [WebMethod]
    public string Blip(int param1, int param2, string param3, /*... , */ string param40)
    {
        // code using parameters
        string requestXml = "blip"; // todo: where do I get relevant XML?
        // updating database
    }
}

XML我试图将字符串放入:

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <Blip xmlns="http://tempuri.org/">
      <param1>int</param1>
      <param2>int</param2>
      <param3>string</param3>
      <!--...-->
      <param3>string</param3>
    </Blip>
  </soap:Body>
</soap:Envelope>

0 个答案:

没有答案