How can I get Axis2 to handle an array?

kevingreen picture kevingreen · Jul 19, 2012 · Viewed 7.1k times · Source

I'm retrieving data from a PHP NuSoap implementation, and it's returning the data like this:

<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">

<SOAP-ENV:Body>

<ns1:getHashCodeAllTablesResponse xmlns:ns1="urn:getSchemaForRhythms">

<return xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType=":[121]">

<item xsi:type="xsd:">

<md5Hash xsi:type="xsd:string">e294967afe9834bf8477252ac0c3686e</md5Hash>

<tableName xsi:type="xsd:string">SYSCONGLOMERATES</tableName>

<isView xsi:type="xsd:string">false</isView>

<viewDefinition xsi:type="xsd:string">null</viewDefinition>

</item>

I think this is the issue: <return xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType=":[121]">

When I point my Axis2 soap client at the service, I get this error:

org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException: Unsupported type http://schemas.xmlsoap.org/soap/encoding/ Array

Here's a really simple java example of what I'm trying to do:

public static void main(String[] args) {
    // TODO code application logic here
    try{
        GetSchemaForRhythmsStub stub = new GetSchemaForRhythmsStub(null,"http://test.test.com/sqlSchemaService/schemaBuilder.php" );
        GetSchemaForRhythmsStub.GetHashCodeAllTablesE response2= new GetSchemaForRhythmsStub.GetHashCodeAllTablesE();
        stub.getHashCodeAllTables(response2);
    }catch(Exception ex)
    {
       System.out.println(ex.toString());

    }
}

I can't find any documentation relating to Array data types, and Axis. Am I missing something?

Thanks,

Answer

davidfmatheson picture davidfmatheson · Jul 19, 2012

What you're missing is that SOAP Encoding Array types are really old school (i.e. what they used to use before XML Schema came along), and Axis2 doesn't like it. You could try switching the data binding from ADB (the default) to XMLBeans. How you do this depends on how you're parsing the WSDL. Here's a couple references that I found:

SOAP encoding and Axis2

Axis2's wsdl2java fails on RPC/Encoded style web services

Generally, look for "soap encoded array axis2" to find information on what you're doing.