Java client fails with "org.apache.axis2.databinding.ADBException: Unexpected subelement" when my service returns an empty array
I'm setting up a webservice using the WSO2 WSF/php module. The service uses automatic WSDL generation from php code. One of the operations returns an array of objects, which normally works fine. However, when I return an empty array, my client in Java (using Axis2 with ADB) fails with the following error:
org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException: Unexpected subelement getRecentChangesResponse
When I look at the xml response using soapUI, this seems ok:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"> <soapenv:Header/> <soapenv:Body> <ns1:getRecentChangesResponse xmlns:ns1="http://www.wso2.org/php/xsd"/> </soapenv:Body> </soapenv:Envelope>
However, it doesn't validate against the definition in the wsdl:
<xsd:element name="getRecentChangesResponse"> <xsd:complexType> <xsd:sequence> <xsd:element name="pathways" maxOccurs="unbounded" type="ns1:WSPathwayInfo"/> </xsd:sequence> </xsd:complexType> </xsd:element>
When I add minOccurs="0" to the wsdl, my client in Java works fine and the response validates in soapUI. Is there a way to add this during wsdl generation?
Thanks!
Thomas
PS. I found this bug report while googling this problem:
https://wso2.org/jira/browse/WSAS-627, could this be the same problem?
| Attachment | Size |
|---|---|
| test.wsdl | 10.63 KB |
- Login or register to post comments
- Printer friendly version
- 924 reads











As you figured out the
As you figured out the problem is there is no way to specify minOccurs=0 in the wsdl generation. I think they main reason it is not there is with these new option the annotation synax will be very complex. Anyway since you have this requirement we can try implement such thing for the next release. Can you please raise a jira for this, https://wso2.org/jira/browse/WSFPHP
I raised a jira issue:
I raised a jira issue: https://wso2.org/jira/browse/WSFPHP-306.
Instead of extending the annotation syntax with new options, wouldn't it be better to set minOccurs=0 as default? Since an array can be empty it would make sense to have such a default and this way you don't have to extend the annotation syntax. Or are there cases when minOccurs shouldn't be 0?
Another possible solution could be to provide programmatic access to the DOM or SimpleXML representation of the WSDL after it's generated and just before it's written to the output buffer. This way scripts can modify it directly and you don't have to extend the annotation syntax. Would that be hard to implement?
In case any other users have
In case any other users have the same problem, I posted a patch that resolves this issue in the bug report:
https://wso2.org/jira/browse/WSFPHP-306