【发布时间】:2019-09-16 15:11:29
【问题描述】:
我们正在整合来自第三方的服务。他们最近升级了他们的服务,现在有了新的 wsdl,我不断收到“元素的非法请求格式”。
根据我的调查,问题似乎在于添加到主要元素上的 xmlns。如果我使用 SOAPUI 并从主元素中删除 xmlns,它可以工作,但是 Visual Studio 会根据 wsdl 中定义的内容自动添加它。
有趣的是,在他们以前的 wsdl 中,该服务可以与包含的 xmlns 一起使用,只有新的 wsdl 才会引发异常。
就 wsdl 而言,我所知道的是他们使用 JD 12 并手动创建了 wsdl,但经过比较,它看起来与旧版本相似,唯一不同的是 xmlns 中的名称。
这是视觉工作室创建的请求:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<extractacccategElement xmlns="http://gna160ws/Management.wsdl/types/">
<xSecurity>
<timekey></timekey>
<authkey></authkey>
<publkey></publkey>
<version>1.x</version>
</xSecurity>
<xRequest1>
<supplierno></supplierno>
</xRequest1>
</extractacccategElement>
</s:Body>
</s:Envelope>
由于“xmlns="http://gna160ws/Management.wsdl/types/"” 导致了问题。
回复:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Header/>
<env:Body>
<srvc:extractacccategElementResponse xmlns="http://gna160ws/Management" xmlns:srvc="http://gna160ws/Management">
<srvc:result>
<response1Out>
<origin>gna160.extractacccategElement</origin>
<invsql>1200</invsql>
<message>Illegal Request format for extractacccategElement.</message>
</response1Out>
</srvc:result>
</srvc:extractacccategElementResponse>
</env:Body>
</env:Envelope>
当提交相同的请求,但没有 xmlns,我得到一个有效的响应。示例:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<extractacccategElement>
<xSecurity>
<timekey></timekey>
<authkey></authkey>
<publkey></publkey>
<version>1.x</version>
</xSecurity>
<xRequest1>
<supplierno></supplierno>
</xRequest1>
</extractacccategElement>
</s:Body>
</s:Envelope>
回复:
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<env:Body>
<ns0:extractacccategElementResponse xmlns="http://gna160ws/Management" xmlns:srvc="http://gna160ws/Management">
<ns0:result>
<ns0:acccategOut>
<ns0:invsql>0</ns0:invsql>
<ns0:message>Success</ns0:message>
<ns0:origin>gna160pkg.ExtractAccCateg</ns0:origin>
<ns0:stage>1</ns0:stage>
<ns0:acccategcode>A</ns0:acccategcode>
<ns0:acccategname>AAA</ns0:acccategname>
</ns0:acccategOut>
</ns0:result>
</ns0:extractacccategElementResponse>
</env:Body>
</env:Envelope>
此外,如果我在 xmlns 之后添加一个限定符,那么它也可以工作?? 示例:
xmlns:hello="http://gna160ws/Management.wsdl/types/"
我一直在与他们这边的开发人员合作,但我们还没有发现问题。
如果有人可以帮助或指出正确的方向,将不胜感激。
【问题讨论】: