【问题标题】:SoapUI giving error as Malformed Request when Request is valid当请求有效时,SoapUI 将错误作为格式错误的请求
【发布时间】:2018-01-11 20:28:59
【问题描述】:

这是我的 .net 代码生成的 xml 的 sn-p,发送到第三方肥皂服务端点。

<?xml version="1.0" encoding="utf-16"?>
  <ProgramInterface 
   xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">  
    <vnsState_request xmlns="http://www.statewide.Request.com">
.....
....
...

这通过代码工作,但是当我提出与我在 SoapUI 中的调试断点中提取的完全相同的请求并将其发送到相同的服务时,它返回 XML 格式错误的错误,如下所示

<faultcode>SOAP-ENV:Client</faultcode>
<faultstring>Malformed SOAP message</faultstring>

当我为同一操作生成示例请求时,我在生成的请求 XML 中看到了这种差异

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:vns="http://www.statewide.Request.com">
   <soapenv:Header/>
   <soapenv:Body>
      <vns:VNSSTATEOperation>
         <vns:vnsState_request>

为什么 SoapUI 需要这些额外的标签,为什么它不能使用我的 .Net 代码生成的请求?为什么它需要vns: 预先添加到每个元素以及这些新元素?

<soapenv:Envelope >
   <soapenv:Header/>
   <soapenv:Body>

【问题讨论】:

    标签: xml wcf soap soapui xml-namespaces


    【解决方案1】:
    1. 关于额外标签:如果您从任何客户端访问 SOAP 服务,则需要 SOAP 标头。您可以找到更多详细信息here
    2. 关于前缀: 如果使用默认的 namespace 则不需要,即 .net 的情况。在 SoapUI 中,它使用显式 namespace,因此使用了 prefix。您可以找到有关 命名空间 here 的更多详细信息。

    例如,以您的为例。下面两者都是一样的。

    <vnsState_request xmlns="http://www.statewide.Request.com">
    <!--the above one is using default namespace -->
    

    <ns:vnsState_request xmlns:ns="http://www.statewide.Request.com">
    <!--using explicit namespace "ns", hence the same is prefixed for the tag -->
    

    如果你看一下 SoapUI 中的那个,它在第一行本身就添加了命名空间。所以,它就像你所展示的那样使用。

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 2012-03-19
      • 2021-11-22
      • 2017-12-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-09-12
      • 1970-01-01
      相关资源
      最近更新 更多