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 Nicolas BESSON <ni...@wimba.com> on 2002/08/05 11:13:10 UTC

Returning array of Bean ...

I'hve got a deployed service with a method returning array of beans.
public SoapBean[] getBeans (int start, int end);

How can i call this method from my axis client application ?


Nicolas


RE: Returning array of Bean ...

Posted by Nicolas BESSON <ni...@wimba.com>.
Thank Simon,

After more investigation i have found a solution:

My deployed service methode doesn't changed.
public SoapBean[] getBeans (int start, int end);

My client call is :

-------------------------------------
 int start = 0;
 int end = 12;

 Service  service = new Service();
 Call     call    = (Call) service.createCall();
 QName    qn_bean  = new QName( "urn:Myservice", "SoapBean" );

 call.registerTypeMapping(SoapBean.class, qn_bean,
               new
org.apache.axis.encoding.ser.BeanSerializerFactory(SoapBean.class, qn_bean),
               new
org.apache.axis.encoding.ser.BeanDeserializerFactory(SoapBean.class,
qn_bean));

 Bean[] result;
 try {

     call.setTargetEndpointAddress( new java.net.URL(options.getURL()) );
     call.setOperationName( new QName("MyService", "getBeans") );
     call.addParameter( "arg1", XMLType.XSD_INT, ParameterMode.IN);
     call.addParameter( "arg2", XMLType.XSD_INT, ParameterMode.IN);
     call.setReturnType( new QName(XMLType.ATTR_ARRAY_TYPE) );

     result = (Bean []) call.invoke( new Object[] { new Integer(start), new
Integer (end) } );

 } catch (AxisFault fault) {
     System.out.println ( "Error : " + fault.toString());
 }
 ......
-------------------------------------

So i don't need Vector ....


Nicolas





RE: Returning array of Bean ...

Posted by Nicolas BESSON <ni...@wimba.com>.
>
> Nicolas BESSON wrote:
>
> >I'hve got a deployed service with a method returning array of beans.
> >public SoapBean[] getBeans (int start, int end);
> >
> >How can i call this method from my axis client application ?
> >
>
> Simon wrote:
>
> I did it something like this to return a single instance of SoapBean.
>
>         Service  service = new Service();
>         Call     call    = (Call) service.createCall();
>         QName    qn      = new QName( "urn:MyService", "SoapBean" );
>         call.registerTypeMapping(SoapBean.class, qn,
>                  new
> org.apache.axis.encoding.ser.BeanSerializerFactory(SoapBean.class,
> qn),
>                  new
> org.apache.axis.encoding.ser.BeanDeserializerFactory(SoapBean.class, qn));
>         call.setTargetEndpointAddress( new
> java.net.URL(options.getURL()) );
>         call.setOperationName( new QName("MyService", "getBeans") );
>         call.addParameter( "arg1",
> org.apache.axis.encoding.XMLType.XSD_INTEGER, ParameterMode.IN );
>         call.setReturnType( qn );
>     Object o=call.invoke( new Object[] { new Integer(start), new
> Integer(end) } );
>
> Also used "public SoapBean getBean(BigInteger start,BigInteger end)" on
> the service side, couldn't get it to match on a primitive type i.e. int.

I have'nt got problems with returning single instance of SoapBean. But,
can't we get an array of SoapBean by setting an appropriate return type for
the "call" request ?

> You can register multiple type mappings for different beans and then
> contain vectors of beans within a bean.
>
> void setBeans(Vector beans)
>
> Vector getBeans()
>
> Which should be serialized transaparently without any trouble.

I don't want to use Vector, because the soap must be compatible with my c++
client. I don't think there is an equivalent java Vector class in c++.

>
> Any help?
>
> Simon...



Re: Returning array of Bean ...

Posted by Simon Hargreaves <si...@openthought.com>.
Nicolas BESSON wrote:

>I'hve got a deployed service with a method returning array of beans.
>public SoapBean[] getBeans (int start, int end);
>
>How can i call this method from my axis client application ?
>
I did it something like this to return a single instance of SoapBean.

        Service  service = new Service();
        Call     call    = (Call) service.createCall();
        QName    qn      = new QName( "urn:MyService", "SoapBean" );
        call.registerTypeMapping(SoapBean.class, qn,
                 new 
org.apache.axis.encoding.ser.BeanSerializerFactory(SoapBean.class, 
qn),       
                 new 
org.apache.axis.encoding.ser.BeanDeserializerFactory(SoapBean.class, qn));
        call.setTargetEndpointAddress( new java.net.URL(options.getURL()) );
        call.setOperationName( new QName("MyService", "getBeans") );
        call.addParameter( "arg1", 
org.apache.axis.encoding.XMLType.XSD_INTEGER, ParameterMode.IN );
        call.setReturnType( qn );
    Object o=call.invoke( new Object[] { new Integer(start), new 
Integer(end) } );

Also used "public SoapBean getBean(BigInteger start,BigInteger end)" on 
the service side, couldn't get it to match on a primitive type i.e. int.

You can register multiple type mappings for different beans and then 
contain vectors of beans within a bean.

void setBeans(Vector beans)

Vector getBeans()

Which should be serialized transaparently without any trouble.

Any help?

Simon...


-- 
---------------------------
http://www.openhistory.net
  free the information
---------------------------