Can/should one disable namespace validation in Axis2 clients using ADB databinding?
- by RJCantrell
I have an document/literal Axis 1 service which I'm consuming with an Axis 2 client (ADB databinding, generated from WSDL2Java). It receives a valid XML response, but in parsing that XML, I get the error "Unexpected Subelement" for any type which doesn't have a namespace defined in the response. I can resolve the error by manually changing the (auto-generated by Axis2) type-validation line to only check the type name and not the namespace as well, but is there a non-manual way to skip this? This service is consumed properly by other Axis 1 clients.
Here's the response, with bits in ALL CAPS having been anonymized. Some types have namespaces, some have empty-string namespaces, and some have none at all. Can I control this via the service's WSDL, or in Axis2's WSDL2Java handling of the WSDL? Is there a fundamental mismatch between Axis 1 and Axis2? The response below looks correct, except perhaps for where that type (anonymized as TWO below) is nested within itself.
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<SERVICENAMEResponse xmlns="http://service.PROJECT.COMPANY.com">
<SERVICENAMEReturn xmlns="">
<ONE></ONE>
<TWO><TWO>
<THREE>2</THREE>
<FOUR>-10</FOUR>
<FIVE>6</FIVE>
<SIX>1</SIX>
</TWO></TWO>
<fileName></fileName>
</SERVICENAMEReturn></SERVICENAMEResponse>
</soapenv:Body></soapenv:Envelope>
I did not have to modify the validation of the "SERVICENAMEResponse" object because it has the correct namespace specified, but I have to so for all its subelements. The manual modification that I can make (one per type) to fix this is to change:
if (reader.isStartElement() && new javax.xml.namespace.QName("http://dto.PROJECT.COMPANY.com","ONE").equals(reader.getName())){
to:
if (reader.isStartElement() && new javax.xml.namespace.QName("ONE").equals(reader.getName())){