1

I have a webservice, which returns an object which includes an array. The Bean classes I have generated by wsdl4j. If I call the service, the object returns always the correct fields but the array has always only one entry. The webservice response has two entries, but somewhere in Axis the second entry will be lost. The service seems to be fine, only the processing within the Axis code seems to be wrong.

This is the content of the response body

[<projectDataReturn xsi:type="ns4:ProjectDataResult" xmlns:ns4="http://results.ws.appserver.secutrial.de" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <errorCode xsi:type="xsd:int">0</errorCode>
    <message xsi:type="soapenc:string" xsi:nil="true" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"/>
    <statusCode xsi:type="xsd:int">1</statusCode>
    <project xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">HAHA</project>
    <centres xsi:type="ns5:CentreBean" xmlns:ns5="http://beans.eo.secutrial.de"><name xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">Center1</name></centres>
    <centres xsi:type="ns6:CentreBean" xmlns:ns6="http://beans.eo.secutrial.de"><name xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">Center2</name></centres>
</projectDataReturn>]

So at the end I only get "Center2" in the CentreBean array of the ProjectDataResult. I have tried single step debugging, but no success.

I found the method RPCElement.publishToHandler() after which the parameters of the RPCElement are wrong. The method replays some SAX events (org.apache.axis.message.SAX2EventRecorder), both CentreBeans are processed, but only the last one will be part of the result.

Did anyone fix this?

witchi
  • 345
  • 3
  • 16

1 Answers1

1

I guess the problem is with how the webservice is designed.

the Centres should be a complex type which can send multiple Centre data. (arraytype)

So ideally the web service should have been returning

[<projectDataReturn xsi:type="ns4:ProjectDataResult" xmlns:ns4="http://results.ws.appserver.secutrial.de" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<errorCode xsi:type="xsd:int">0</errorCode>
<message xsi:type="soapenc:string" xsi:nil="true" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"/>
<statusCode xsi:type="xsd:int">1</statusCode>
<project xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">HAHA</project>
<centres xsi:type="ns5:CentreBean" xmlns:ns5="http://beans.eo.secutrial.de">
    <centre>
        <name xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">Center1</name>
    </centre>
    <centre>
        <name xsi:type="soapenc:string" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/">Center1</name>
    </centre>
</centres>

]

So what I'm trying to say here is, the "Centres" should be a bean that has an array type of "Centre" beans and each Centre will have the string type name.

If the webservice is designed this way to return data, the axis would generate stubs as i mentioned above and you'll be able to fetch Centres as an array.

Now what's happening is it runs through both the Centres and as its not a array type the Centre1 value will get overridden by Centre2 when it reads the second value.