Python 在生成的WSDL中修改ladonized web服务方法的返回类型定义
我已经使用ladon web服务编写了一个python web服务,我想使用Java和Axis2访问SOAP接口 我已经使用python和SUDS客户端库成功地测试了WS 在转换返回类型之前,调用远程服务方法一直有效。ladon生成的WSDL包含以下类型定义:Python 在生成的WSDL中修改ladonized web服务方法的返回类型定义,python,soap,ladon,Python,Soap,Ladon,我已经使用ladon web服务编写了一个python web服务,我想使用Java和Axis2访问SOAP接口 我已经使用python和SUDS客户端库成功地测试了WS 在转换返回类型之前,调用远程服务方法一直有效。ladon生成的WSDL包含以下类型定义: <xsd:complexType name="Sensor"> <xsd:sequence> <xsd:element maxOccurs="1" minOccurs="1" name
<xsd:complexType name="Sensor">
<xsd:sequence>
<xsd:element maxOccurs="1" minOccurs="1" name="description" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="1" name="host" type="xsd:string"/>
<xsd:element maxOccurs="1" minOccurs="1" name="sensorId" type="xsd:long"/>
<xsd:element maxOccurs="1" minOccurs="1" name="service" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
相应的答复是:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns="urn:SensorService" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<ns:createResponse>
<result>
<sensorId>16</sensorId>
<host>testHost</host>
<description>testDescription</description>
<service>testService</service>
</result>
</ns:createResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
基本上,问题在于结果类型中元素的顺序。xsd描述要求
描述
主办
传感器
服务
但是响应与此序列不匹配,因此导致Axis2 ADBEException:意外的子元素sensorId。当我
手动下载WSDL文件并
更改返回类型的类型定义以匹配响应中实际返回的序列,以及
使用修改后的文件中的Maven插件重新生成服务存根。
服务存根是使用maven插件自动生成的,随后作为依赖项包含在项目中
我想避免这个手动步骤。是否可以在服务器端修改导出顺序
类型定义似乎以字典顺序列出元素,但响应是另一个不同的顺序
首先,WSDL响应类型遵循原始python返回类型定义中定义属性的顺序。我已更改了此顺序,但没有任何效果。在安装更新包之前,我已停止服务器
多谢各位
bvfnbk您能解决这个问题吗?我面临着类似的问题:不,不幸的是没有。最后,我被要求完全改变我的计划,所以我甚至不能推荐替代方案。
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns="urn:SensorService" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<ns:createResponse>
<result>
<sensorId>16</sensorId>
<host>testHost</host>
<description>testDescription</description>
<service>testService</service>
</result>
</ns:createResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>