无法在 apache 轴上反序列化复杂类型 - “anytype”问题
我被迫使用看起来非常旧的 wsdl 来生成 Web 服务客户端。事实上太旧了,jdk 的 wsimport 拒绝解析它。然而,Axis 1.4 成功生成了一个在很大程度上可以正常工作的 Web 服务客户端。有一个烦人的问题,它无法处理用“anyType”描述的连续复杂类型
这是原始堆栈跟踪:
java.lang.RuntimeException: org.xml.sax.SAXException: No deserializer for {http://www.w3.org/2001/XMLSchema}anyType
Caused by: org.xml.sax.SAXException: No deserializer for {http://www.w3.org/2001/XMLSchema}anyType
at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
at org.apache.axis.client.Call.invoke(Call.java:2470)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
我认为我可以通过注册一个尝试映射
添加了代码...
_call.registerTypeMapping(VoipAccountSubscriberRead.class, new QName("http://www.w3.org/2001/XMLSchema", "anyType"), null, new BeanDeserializerFactory(VoipAccountSubscriberRead.class, new QName("http://www.w3.org/2001/XMLSchema", "anyType")));
...结果堆栈跟踪:
j
Caused by: java.lang.IllegalArgumentException: argument type mismatch
at org.apache.axis.encoding.ser.BeanPropertyTarget.set(BeanPropertyTarget.java:157)
at org.apache.axis.encoding.DeserializerImpl.valueComplete(DeserializerImpl.java:249)
at org.apache.axis.encoding.ser.ArrayDeserializer.valueComplete(ArrayDeserializer.java:583)
at org.apache.axis.encoding.DeserializerImpl.endElement(DeserializerImpl.java:509)
这是因为 xml 具有多个由 anytype[ 描述的嵌套复杂类型1] 和 anytype[0] 还是我离目标太远了?我是一个 SOAP 新手,对 xml 有基本的了解,但对 xsd 的了解不够,所以可能离题太远了:)
这是传入的 xml:
<?xml version="1.0"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<get_voip_account_by_external_idResponse xmlns="urn:/SOAP/Provisioning">
<data>
<create_timestamp xsi:type="xsd:string">2011-08-04 13:55:58</create_timestamp>
<status xsi:type="xsd:string">active</status>
<billing_profile xsi:type="xsd:string">default</billing_profile>
<terminate_timestamp xsi:nil="true" xsi:type="xsd:string"/>
<activate_timestamp xsi:type="xsd:string">2011-08-04 13:55:58</activate_timestamp>
<modify_timestamp xsi:type="xsd:string">2011-08-04 13:55:58</modify_timestamp>
<external_id xsi:type="xsd:string">CID_472486001</external_id>
<id xsi:type="xsd:int">121</id>
<subscribers soapenc:arrayType="xsd:anyType[1]" xsi:type="soapenc:Array">
<item>
<admin xsi:type="xsd:boolean">false</admin>
<alias_numbers soapenc:arrayType="xsd:anyType[0]" xsi:type="soapenc:Array"/>
<webpassword xsi:nil="true" xsi:type="xsd:string"/>
<status xsi:type="xsd:string">active</status>
<ac xsi:nil="true" xsi:type="xsd:int"/>
<webusername xsi:nil="true" xsi:type="xsd:string"/>
<uuid xsi:type="xsd:string">5cad2cac-cc03-45bd-9ea9-189e22fdd406</uuid>
<account_id xsi:nil="true" xsi:type="xsd:int"/>
<username xsi:type="xsd:string">c734106b8e563edebc3098a991402566</username>
<domain xsi:type="xsd:string">labzip-snc01.somedomain.com</domain>
<password xsi:type="xsd:string">4daac6c07b33c76c2d5ff9bb710f4ab7</password>
<external_id xsi:type="xsd:string">CID_472486001</external_id>
<cc xsi:nil="true" xsi:type="xsd:int"/>
<subscriber_id xsi:type="xsd:int">127</subscriber_id>
<sn xsi:nil="true" xsi:type="xsd:string"/>
</item>
</subscribers>
</data>
</get_voip_account_by_external_idResponse>
</soap:Body>
</soap:Envelope>
非常感谢任何帮助!!!! (即使它本身不是答案。请为我指出正确的方向)
I am forced to use what looks to be a very old wsdl to generate web service clients. So old in fact that the jdk's wsimport refuses to parse it. Axis 1.4 however succedes in generating a web-service client that for the most part works. There is one annoying problem, it cannot handle consecutive complex types described with "anyType"
Here is the original stack trace:
java.lang.RuntimeException: org.xml.sax.SAXException: No deserializer for {http://www.w3.org/2001/XMLSchema}anyType
Caused by: org.xml.sax.SAXException: No deserializer for {http://www.w3.org/2001/XMLSchema}anyType
at org.apache.axis.AxisFault.makeFault(AxisFault.java:101)
at org.apache.axis.client.Call.invoke(Call.java:2470)
at org.apache.axis.client.Call.invoke(Call.java:2366)
at org.apache.axis.client.Call.invoke(Call.java:1812)
I thought I could solve this by registering a TypeMapping that attempts to map the <item> element (see xml below) to its associated class but this does not work:
code added...
_call.registerTypeMapping(VoipAccountSubscriberRead.class, new QName("http://www.w3.org/2001/XMLSchema", "anyType"), null, new BeanDeserializerFactory(VoipAccountSubscriberRead.class, new QName("http://www.w3.org/2001/XMLSchema", "anyType")));
...resulting stack-trace:
j
Caused by: java.lang.IllegalArgumentException: argument type mismatch
at org.apache.axis.encoding.ser.BeanPropertyTarget.set(BeanPropertyTarget.java:157)
at org.apache.axis.encoding.DeserializerImpl.valueComplete(DeserializerImpl.java:249)
at org.apache.axis.encoding.ser.ArrayDeserializer.valueComplete(ArrayDeserializer.java:583)
at org.apache.axis.encoding.DeserializerImpl.endElement(DeserializerImpl.java:509)
Is this due to the fact that the xml has more than one nested complex type described by anytype[1] and anytype[0] or am I just way off the mark? I am a SOAP newbie, with a basic understanding of xml and an inadequate understanding of xsd so probably am way off the mark :)
Here is the incoming xml:
<?xml version="1.0"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<get_voip_account_by_external_idResponse xmlns="urn:/SOAP/Provisioning">
<data>
<create_timestamp xsi:type="xsd:string">2011-08-04 13:55:58</create_timestamp>
<status xsi:type="xsd:string">active</status>
<billing_profile xsi:type="xsd:string">default</billing_profile>
<terminate_timestamp xsi:nil="true" xsi:type="xsd:string"/>
<activate_timestamp xsi:type="xsd:string">2011-08-04 13:55:58</activate_timestamp>
<modify_timestamp xsi:type="xsd:string">2011-08-04 13:55:58</modify_timestamp>
<external_id xsi:type="xsd:string">CID_472486001</external_id>
<id xsi:type="xsd:int">121</id>
<subscribers soapenc:arrayType="xsd:anyType[1]" xsi:type="soapenc:Array">
<item>
<admin xsi:type="xsd:boolean">false</admin>
<alias_numbers soapenc:arrayType="xsd:anyType[0]" xsi:type="soapenc:Array"/>
<webpassword xsi:nil="true" xsi:type="xsd:string"/>
<status xsi:type="xsd:string">active</status>
<ac xsi:nil="true" xsi:type="xsd:int"/>
<webusername xsi:nil="true" xsi:type="xsd:string"/>
<uuid xsi:type="xsd:string">5cad2cac-cc03-45bd-9ea9-189e22fdd406</uuid>
<account_id xsi:nil="true" xsi:type="xsd:int"/>
<username xsi:type="xsd:string">c734106b8e563edebc3098a991402566</username>
<domain xsi:type="xsd:string">labzip-snc01.somedomain.com</domain>
<password xsi:type="xsd:string">4daac6c07b33c76c2d5ff9bb710f4ab7</password>
<external_id xsi:type="xsd:string">CID_472486001</external_id>
<cc xsi:nil="true" xsi:type="xsd:int"/>
<subscriber_id xsi:type="xsd:int">127</subscriber_id>
<sn xsi:nil="true" xsi:type="xsd:string"/>
</item>
</subscribers>
</data>
</get_voip_account_by_external_idResponse>
</soap:Body>
</soap:Envelope>
ANY HELP GREATLY APPRECIATED !!!! (even if its not an answer per se. Just point me in the right direction)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论