当请求有效时,SoapUI 给出错误作为格式错误的请求

SoapUI giving error as Malformed Request when Request is valid

这是我的 .net 代码生成的 xml 片段,它被发送到第三方 soap 服务端点。

<?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 中的调试断点中提取的完全相同的请求并将其发送到相同的服务时,它 returns 出现 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>
  1. 关于额外标签: 如果您从任何客户端访问 SOAP 服务,则需要 SOAP headers。您可能会找到更多详细信息 here.
  2. 关于前缀: 如果使用默认的 namespace 则不需要,在您 .net 的情况下。在 SoapUI 中,它使用显式 命名空间 ,因此使用 prefix。您可以找到有关 命名空间 here.
  3. 的更多详细信息

比如,以你为例。下面都是一样的

<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 中的那个,它会在第一行本身添加名称空间。所以,它按照你所展示的那样使用。

希望对您有所帮助。