2

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,

kevingreen
  • 1,541
  • 2
  • 18
  • 40

2 Answers2

5

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.

Community
  • 1
  • 1
davidfmatheson
  • 3,539
  • 19
  • 27
  • Thanks, I'll check those links. Would it be simpler at this point to change my nusoap to not use arrays? I was hoping to avoid that since PHP is my weaker language, but if it's handling it poorly I'd hate to have it stick around. – kevingreen Jul 19 '12 at 13:51
  • 1
    PHP is not my first language either, but I would probably invest the time into figuring out how to make NuSOAP spit out nicer WSDL, especially if this is not the only client that will be consuming the service. – davidfmatheson Jul 20 '12 at 13:49
  • Thanks for the articles, I ended up rewriting the nuSoap client to spit out regular XML instead of an array. Now off to make Axis2 work. – kevingreen Jul 20 '12 at 15:03
1

I faced the same issue, the generated code did not had set method on the XMLBean representing the array. To get around this problem, I directly used the XMLBean API's on the generated class.

Following code snippet demonstrates adding elements to the generated array class. In my case I had to return a string array containing two values.

    ArrayOfXsdString strArray = syncResponse.addNewProcessSyncReturn();

             /* set the size of the array */
    strArray.setArrayType("soapenc:string[2]");

            /* get the XMLCursor object and go to the end of the XML represented by this bean */   
    XmlCursor cur = strArray.newCursor();
    cur.toEndToken();

            /* processSyncReturn is the XML element name of the array */        
    cur.toChild("processSyncReturn");
    cur.insertElementWithText("processSyncReturn","this is array element 1");
    cur.insertElementWithText("processSyncReturn","this is array element 2");

The following gets generated in the response SOAP message

<processSyncReturn soapenc:arrayType="soapenc:string[2]">
<processSyncReturn>this is array element 1</processSyncReturn>
<processSyncReturn>this is array element 2</processSyncReturn>
</processSyncReturn>

Hussain

http://nsinfra.blogspot.in

Hussain Pirosha
  • 1,358
  • 1
  • 11
  • 19