为什么一个wsdl有不同的请求定义

时间:2018-08-20 08:46:29

标签: soap wsdl

在项目开始时,客户端为我提供了WSDL,最终我使用SOAP UI为给定的WSDL创建了一个请求和响应对象,其中请求对象如下所示,

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:def="http://DefaultNamespace">
   <soapenv:Header/>
   <soapenv:Body>
      <def:someOperation soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <in0 xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">SOME_DATA</in0>
      </def:someOperation>
   </soapenv:Body>
</soapenv:Envelope>

但是当来自生产环境的同一wsdl的实际请求是,

<?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>
    <someOperation xmlns="urn:SOMEService">
    <in0>SOME_DATA</in0>
    </someOperation>
</soap:Body>
</soap:Envelope>

如果您观察到名称空间相同,但是名称确实有所不同,例如在xml的每个节点中,第一个请求的名称<soapenv:Envelope和第二个请求的名称相同<soap:Envelope,在第一个请求中,操作也不同,

<def:someOperation soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
         <in0 xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">SOME_DATA</in0>
      </def:someOperation>

第二个是

<someOperation xmlns="urn:SOMEService">
    <in0>SOME_DATA</in0>
    </someOperation>

我不知道为什么解释会有所不同,并且必须从第一更改为第二是安全的。 在这两种情况下,实际操作都很好,我对此没有任何问题,只是无法找出差异的原因。

有人可以帮助我解决这个问题吗?或者可以指导我澄清任何疑问的文档的任何指导。

1 个答案:

答案 0 :(得分:1)

  

对于第一个请求的名称<soapenv:Envelope确实有区别,而第二个请求的名称在xml的每个节点中都是<soap:Envelope

这里soapenvsoaplocal prefix names中的namespace=http://schemas.xmlsoap.org/soap/envelope/。因此,从逻辑上讲,两者是相同的,没有区别。

  

1st v / s 2nd

中的请求中,操作的定义也不同

如果为1,则def:someOperation XML节点属于命名空间= xmlns:def="http://DefaultNamespace"

在第二种情况下,名称空间“ urn:SOMEService”是直接用XML Nodes定义的 如果DefaultNamespaceSOMEService完全相同,则表示两个XML Operation XML都相同。

因此, 您的情况下,soapenv v / s肥皂是一样的。

操作,您可以根据SOMEService v / s DefaultNamespace的实际值得出结论。

希望有帮助。