【问题标题】:The parameter value of webmethod is having null valuewebmethod 的参数值为空值
【发布时间】:2023-04-04 23:44:01
【问题描述】:

我从 wsdl 开发了一个 .net Web 服务。预期的肥皂输入具有肥皂正文(取自浏览器)为

<soap:Body>
    <InsertRequest xmlns="http://www.xyz.com/MainType/">
      <InsertRequest>
        <context xmlns="">
          ...
        </context>
        <request xmlns="">
          ...
        </request>
      </InsertRequest>
    </InsertRequest>
  </soap:Body>

我的客户正在发送一个带有肥皂主体的肥皂请求,如下所示

<soap:Body>
    <InsertRequest xmlns="http://www.xyz.com/MainType/">
      <InsertRequest xmlns="">
        <context>
          ...
        </context>
        <request>
          ...
        </request>
      </InsertRequest>
    </InsertRequest>
  </soap:Body>

我编写了一个虚拟应用程序,它对 .net 网络服务进行 HttpWebRequest 调用。如果我通过具有如下肥皂体的肥皂信封,它就可以工作

    <soap:Body>
    <InsertRequest xmlns="http://www.xyz.com/MainType/">
      <InsertRequest>
        <context xmlns="">
          ...
        </context>
        <request xmlns="">
          ...
        </request>
      </InsertRequest>
    </InsertRequest>
  </soap:Body>

但是我的客户给了他们寄来的肥皂信封,它的肥皂盒是

    <soap:Body>
    <InsertRequest xmlns="http://www.xyz.com/MainType/">
      <InsertRequest xmlns="">
        <context>
          ...
        </context>
        <request>
          ...
        </request>
      </InsertRequest>
    </InsertRequest>
  </soap:Body>

当我在虚拟应用程序中使用这个肥皂体时,我的 web 方法 InsertRequest(InsertRequest insertRequest) 中的参数值为 NULL。 任何人都可以让我知道为什么在上述肥皂体的情况下参数会获得 NULL 值吗?另外,为什么两个肥皂消息之间的肥皂正文的 xmlns='' 出现不同?

提前致谢, 哈里什

【问题讨论】:

    标签: .net soap service


    【解决方案1】:

    null 参数通常表示传入的 SOAP 无法序列化为该类型。

    当您从 WSDL 创建服务时,您是手动完成的还是使用了工具?

    尝试使用此工具从 WSDL 创建服务存根: http://www.thinktecture.com/resourcearchive/tools-and-software/wscf 并查看您的实现中的数据协定/骨架类是否有任何差异。然后,您可以将实现代码放入框架中,并尝试使用提供的 SOAP XML 调用它来测试互操作性。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-12-14
      • 2020-06-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多