0

我正在尝试使用 Axis2 连接到 SOAP Web 服务。这以前在轴 1 中工作,但 2 导致问题。我已经重新生成了 Java 代码,使用wsdl2java它为 Axis2 生成了存根,但是在处理具有“意外子元素值”的服务器响应元素时,它崩溃了。

有问题的 wsdl 文档的片段是:

<complexType name="A">
<sequence>
<element name="a" type="xsd:base64Binary" minOccurs="1" maxOccurs="1" nillable="false" />
<element name="b" type="xsd:string" minOccurs="1" maxOccurs="1" />
<element name="c" type="xsd:string" minOccurs="1" maxOccurs="1" />
<element name="d" type="xsd:string" minOccurs="1" maxOccurs="1" />
<element name="e" type="xsd:string" minOccurs="1" maxOccurs="1" />
<element name="f" type="xsd:string" minOccurs="1" maxOccurs="1" />
</sequence>
</complexType>

返回的响应如下所示:

<stuff>
<a>dsfusdbifsdisuibvuidnfuisndfvl\sbvuidn</a>
<b>string</b>
<c>string</c>
<d>string</d>
<e>string</e>
<f>string</f>
</stuff>
<stuff>
<a>dsfusdbifsdisdfsfsdfsdfuibvuidnfuisndfvl\dfgd</a>
<b>string</b>
<c>string</c>
<d>string</d>
<e>string</e>
<f>string</f>
</stuff>
<stuff>
<a>dsfusdbifsdisuibvuidnfuisndfvl\sdfsdfvv</a>
<b>string</b>
<c>string</c>
<d>string</d>
<e>string</e>
<f>string</f>
</stuff>
<stuff>
<a>wwasdfgfbdfb\sbv==uidn</a>
<b>string</b>
<c>string</c>
<d>string</d>
<e>string</e>
<f>string</f>
</stuff>

sort of thing. Most of these <stuff> blocks process fine, but the last one fails on <b> with the above error. Debugging the code, it fails because reader.isStartElement() returns false and new javax.xml.namespace.QName("","b").equals(reader.getName()) is false - reader.getName() returns "a". Debugging further, reader.currentElement reports "string" instead of the wrapped object type it usually returns. I have tried this with Axiom 1.2.7 and 1.2.8 - both seem to suffer from the same problem. Is this a known bug, or can anybody shed light on what might be going on?

4

1 回答 1

0

Seems like this was a problem with the SAX binding generator. Switching in the JAXB bindings has fixed the problem.

于 2010-09-06T14:02:05.050 回答