Hi all,

I am trying to make a web service that uses a complex type object as return
value. My complex object looks like

public class ComplexBean
{
    private String[] str;
    private Object[][] val;

    public String[] getStr()
    {
        return str;
    }

    public void setStr(String[] str)
    {
        this.str = str;
    }

    public Object[][] getVal()
    {
        return val;
    }

    public void setVal(Object[][] val)
    {
        this.val = val;
    }
}

I created a service with a method that returns an object of the above type.
I deployed the service. When I access the wsdl, it shows that the service is
deployed and the schema in the WSDL looks fine.

<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified"
targetNamespace="http://ws.apache.org/axis2/xsd";>
    <xs:complexType name="ComplexBean">
        <xs:sequence>
            <xs:element maxOccurs="unbounded" minOccurs="0" name="str"
nillable="true" type="xs:string"/>
            <xs:element maxOccurs="unbounded" minOccurs="0" name="val"
nillable="true" type="ax21:ArrayOfObject"/>
        </xs:sequence>
    </xs:complexType>
    <xs:complexType name="ArrayOfObject">
        <xs:sequence>
            <xs:element maxOccurs="unbounded" minOccurs="0" name="array"
nillable="true" type="xs:anyType"/>
        </xs:sequence>
    </xs:complexType>
</xs:schema>

I generated the client side for the service using WSDL2java tool. I used ADB
binding for that. I invoked the web method from the client. I could see that
method is executed and the SOAP response message is sent back to the client.

<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope";>
    <soapenv:Body>
        <ns:getBeanResponse xmlns:ns="http://test";>
            <ns:return xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
xmlns:ax21="http://test/xsd"; xsi:type="ax21:ComplexBean">
                <ax21:str>1</ax21:str>
                <ax21:str>2</ax21:str>
                <ax21:val>
                    <ax21:array>1-a</ax21:array>
                    <ax21:array>1-b</ax21:array>
                </ax21:val>
                <ax21:val>
                    <ax21:array>2-a</ax21:array>
                    <ax21:array>2-b</ax21:array>
                </ax21:val>
            </ns:return>
        </ns:getBeanResponse>
    </soapenv:Body>
</soapenv:Envelope>

But when the client parses the response, it is not able to do it. It fails
with the following exception message.

Exception in thread "main" org.apache.axis2.AxisFault:
org.apache.axis2.databinding.ADBException: Any type element type has not
been given
    at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
    at test.SimpleTestStub.fromOM(SimpleTestStub.java:2463)
    at test.SimpleTestStub.getBean(SimpleTestStub.java:189)
    at test.TestSimpleClient.main(TestSimpleClient.java:12)
Caused by: java.lang.Exception: org.apache.axis2.databinding.ADBException:
Any type element type has not been given
    at
test.SimpleTestStub$ArrayOfObject$Factory.parse(SimpleTestStub.java:2411)
    at
test.SimpleTestStub$ComplexBean$Factory.parse(SimpleTestStub.java:1729)
    at
test.SimpleTestStub$GetBeanResponse$Factory.parse(SimpleTestStub.java:870)
    at test.SimpleTestStub.fromOM(SimpleTestStub.java:2457)
    ... 2 more
Caused by: org.apache.axis2.databinding.ADBException: Any type element type
has not been given
    at
org.apache.axis2.databinding.utils.ConverterUtil.getAnyTypeObject(ConverterUtil.java:1617)
    at
test.SimpleTestStub$ArrayOfObject$Factory.parse(SimpleTestStub.java:2375)
    ... 5 more

I debugged the client side and found that, the code is expecting a mandatory
"type" attribute. But in the response returned from the server, the "type"
attribute is not present and hence the parsing fails.

Is there any workaround for this problem? If you could point me in some
direction, it will be greatly helpful. If you need any more information, I
could provide those.

Thanks in advance and hoping for a response.

Thanks & Regards,
Paul

Reply via email to