You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Uppili Srinivasan <us...@questerra.com> on 2005/09/01 00:54:00 UTC

RE: Return type for complex types

In case anyone is interested, I found a solution for this problem. 

 

If I modify my client to call "call.setReturnType(new QName("urn:myNS",
"myBean", ArrayList.class)", I am able to run the client without any
exceptions and access the returned array of objects.

 

IToo bad there are not enough examples or documentation on this.

 

Uppili

  _____  

From: Uppili Srinivasan 
Sent: Wednesday, August 31, 2005 11:07 AM
To: 'axis-user@ws.apache.org'
Subject: RE: Return type for complex types

 

Hi Rogério,

 

Thanks for your response. Your example uses RPC-style of service. I got
that working as well but for interoperability reasons and other reasons
we have switched to

"wrapped" and that is where I am having the problem in parsing the
response which contain an array of objects. Please let me know if you or
others have had any success with it.

 

 

Uppili

  _____  

From: Rogério Luz [mailto:rogeriosantosluz@gmail.com] 
Sent: Wednesday, August 31, 2005 8:08 AM
To: axis-user@ws.apache.org
Subject: Re: Return type for complex types

 

Hi Uppili

  Try to create a wsdd like this:

<deployment xmlns=" http://xml.apache.org/axis/wsdd/" xmlns:java="
http://xml.apache.org/axis/wsdd/providers/java"
<http://xml.apache.org/axis/wsdd/providers/java> >
    <service name="YourWebServiceName" provider="java:RPC">
        <parameter name="className" value="your.package.ClassName"/> 
        <parameter name="allowedMethods" value="*"/>
        <beanMapping qname="myNS:YourBean" xmlns:myNS="urn:ClassName"
languageSpecificType="java:your.package.YourBean"/>
    </service>
</deployment>

  Deploy it then try this in your client code:

  QName qnYourBeanName = new QName("urn:ClassName", "YourBean");
  QName qnYourBeanArr = new QName("urn:ClassName", "ArrayOf_ClassName");
  call.registerTypeMapping(YourBean.class, qnYourBeanName ,  
                    new
org.apache.axis.encoding.ser.BeanSerializerFactory(YourBean.class,
qnYourBeanName ),  
                    new
org.apache.axis.encoding.ser.BeanDeserializerFactory(YourBean.class,
qnYourBeanName )); 
 
   call.registerTypeMapping(YourBean[].class, qnYourBeanNameArr , 
                    new
org.apache.axis.encoding.ser.ArraySerializerFactory(), 
                    new
org.apache.axis.encoding.ser.ArrayDeserializerFactory());

   YourBean[] yba = (YourBean[]) call.invoke( new Object[] {});

  This should work.
  Any problem let me know.

Best Regards,

Rogério Luz

On 8/30/05, Uppili Srinivasan < usrinivasan@questerra.com
<ma...@questerra.com> > wrote:

Hi everyone,



I searched the recent archives for an answer to the problem I am having
but could not find one. Any help would be greatly appreciated.=20



I have a wrapped service which returns TestObject[] where TestObject is 
a bean with a just a String property.



The WSDD entry for that is



<service name=3D"Test" style=3D"wrapped">



  <parameter name=3D"className" = 

value=3D"com.questerra.webservices.Test"/>



  <parameter name=3D"allowedMethods" value=3D"*"/>



  <beanMapping qname=3D"myNS:TestObject" 

xmlns:myNS=3D" http://webservices.questerra.com"

languageSpecificType=3D"java:com.questerra.webservices.TestObject"/>



</service> 





I don't have any problems in calling the service but am having problems
in parsing the response. If the service returns only one object in the
array and



if I do the following in my client, I don't get any exceptions 



      QName    qnArr         =3D new QName("
http://webservices.questerra.com < http://webservices.questerra.com/> ",
"doTestResponse" ); 

      call.setOperationStyle("wrapped");

      call.registerTypeMapping(TestObject[].class, qnArr,

                    new
org.apache.axis.encoding.ser.ArraySerializerFactory(),

                    new 
org.apache.axis.encoding.ser.ArrayDeserializerFactory());

      call.setOperationName( "doTest" );

      call.setReturnType(qnArr);





But if the service returns more than one object, I am getting an AXIS 
fault as follows:



faultCode:

{ http://schemas.xmlsoap.org/soap/envelope/}Server.userException
<http://schemas.xmlsoap.org/soap/envelope/%7dServer.userException> 
< http://schemas.xmlsoap.org/soap/envelope/%7dServer.userException
<http://schemas.xmlsoap.org/soap/envelope/%7dServer.userException> >



faultSubcode:



faultString: java.lang.ArrayStoreException



faultActor:



faultNode:



faultDetail:





{ http://xml.apache.org/axis/}stackTrace:java.lang.ArrayStoreException
<http://xml.apache.org/axis/%7dstackTrace:java.lang.ArrayStoreException>

< http://xml.apache.org/axis/%7dstackTrace:java.lang.ArrayStoreException
<http://xml.apache.org/axis/%7dstackTrace:java.lang.ArrayStoreException>
>




            at

org.apache.axis.utils.JavaUtils.convert(JavaUtils.java:472)



            at org.apache.axis.client.Call.invoke (Call.java:2580)



            at org.apache.axis.client.Call.invoke(Call.java:2347)



            at org.apache.axis.client.Call.invoke(Call.java:1804)





Thanks much in advance for any help in resolving this issue[Uppili 
Srinivasan] .



Uppili