I created a web service using:
- Apache Axis 2 CodeGen Wizard v.1.6.2 (Binding: ADB)
- Eclipse Juno
- Tomcat 7
- Java 6
The Service returns a Custom Java Object (DataBean) back to the client, but I stumbled upon an exception in the client code:
org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException: Unexpected subelement {schemaTargetNs}message
From what I have researched, over n over again ... I think this is a very common problem but haven't yet got a conclusive answer as to what should be done to rectify it.
Some posts on this and other forums state that the WSDL needs to be modified (some name space), or the client stub needs modification. Some even state that there is a bug in the ADB. It was surely a bug in earlier versions of Axis but there are many posts in the mail-archives stating that the bug was fixed. Those mailing-archives were related to earlier versions of Axis2.
Now my questions are:
- Is it still a bug ?
- What exactly needs to be changed in the WSDL or the Client stub ?
What is worth mentioning is that I created a similar web service which returns a "String" back to the client. It works fine ! So, it fails when a complex data type is involved.
There was some information on Apache's website, under the heading "Known Limitations"...
It reads: "ADB is meant to be a 'Simple' databinding framework and was not meant to compile all types of schemas. The following limitations are the most highlighted.
- Complex Type Extensions and Restrictions."
Is that the problem ?
The following is the snippet from the WSDL file which might be of some interest to you...
<wsdl:types>
<xs:schema xmlns:ax26="http://mywebservice/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="schemaTargetNs">
<xs:import namespace="http://mywebservice/xsd"/>
<xs:element name="getMsg">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="reqData" nillable="true" type="ax25:DataBean"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getMsgResponse">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="ax25:DataBean"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://mywebservice/xsd">
<xs:complexType name="DataBean">
<xs:sequence>
<xs:element minOccurs="0" name="message" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
</wsdl:types>
Now how do I fix the problem ? Should I include some other code snippets here?