简体   繁体   中英

axis2 “unexpected subelement value”

I'm trying to use Axis2 to connect to a SOAP webservice. This was previously working in Axis 1, but 2 is causing problems. I've regenerated the Java code using wsdl2java which has generated the stubs for Axis2, but it's falling over when processing an element of the server response with "unexpected subelement value".

The fragment of the wsdl document in question is:

<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>

The response being returned looks like:

<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 " " 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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM