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 Sam <sa...@yahoo.com> on 2004/02/10 07:47:40 UTC

How to return a Vector

Hi,
 
I am writing a web service (in Java) that has a method returning a Vector. Can anyone let me know how this can be handled in the client? 
Specifically, how do I call the call.setReturnType() method? Also, does it matter what the Vector has? (I think it does not, but just to confirm). And do we need to do anything extra in the deploy.wsdd file for this?
 
 
Thanks,
Sam


---------------------------------
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online

XML Encoding for a void type?

Posted by Sam <sa...@yahoo.com>.
 Hi,
 
I need to invoke a web service that takes in a void type and returns a Vector. Thanks to Venkatesh Kancherla, I am able to do the Vector part fine. But I am now stuck with the void thing. (I am using Java)
what do I need to do in the client if I have a service that takes in a void?

Here's my situation:
I have 2 services: 
One takes in Order class (custom, used the beanSerializer and it works fine) and returns a void. For this, in the client, I called addParameter() with my custom Qname that I created with the beanSerializer, but didnot specify anything fo the return type. (Did not call setReturnType() at all)
This works fine.
 
Another service takes in a void and returns a Vector. Now, I have to call setReturnType() with a QName for Vector, that I created. It is fine. But if I dont call call.addParameter(), it throws an AxisFault, saying "addParameter() should be called along with setReturnType()". So my question is, how should I call addParameter() for this? 
 
I am giving my code fragment below
 
Thanks a lot,
Sam

 
------ 
Vector retVector = new Vector(); 
String serviceURL = http://localhost:8080/axis/services/SamService; 
    
   Service  service = new Service(); 
   Call     call    = (Call) service.createCall(); 
   call.setTargetEndpointAddress( new java.net.URL(serviceURL) ); 
   call.setOperationName( new QName("SamService", "serviceMethod") ); 

// HOW SHOULD THIS BE???    
  // QName qVoid=new QName("samNS","void"); 
    //        call.addParameter( "arg1", qVoid, ParameterMode.IN); 

   QName qVec=new QName("samNS","Vector"); 
   call.setReturnType( qVec ); 
   retVector = (Vector) call.invoke(); 
  
------ 
  
My corresponding deploy.wsdd file is 
------ 
<deployment xmlns="http://xml.apache.org/axis/wsdd/" 
            xmlns:java="http://xml.apache.org/axis/wsdd/providers/java"> 
 <service name="SamService" provider="java:RPC"> 
  <parameter name="className" value="myPackage.SamClass"/> 
  <parameter name="allowedMethods" value="*"/> 
  <beanMapping qname="samNS:Order" xmlns:samNS="urn:OrderService" languageSpecificType="myPackage.Order"/> 
 </service> 
</deployment> 
----- 






---------------------------------
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online

Re: How to return a Vector - and more

Posted by Sam <sa...@yahoo.com>.
Thanks for the info, Venkatesh. 
I have another question now. About a void. 
The service method I am writing takes in a void and returns a Vector. I want to know how this is handled in the client. (I mean, what should the addParameter() and setReturnType() be, exactly?). 
I read somewhere that these two calls need not be explicitly called before call.invoke() if the data types are specified. Can anyone tell me where I should do it, if not in the client?
 
I am giving my code fragment here, for ease:
 
Thanks a lot!
Sam
------
Vector retVector = new Vector();
   
   String serviceURL = http://localhost:8080/axis/services/SamService;
   
   Service  service = new Service();
   Call     call    = (Call) service.createCall();
   call.setTargetEndpointAddress( new java.net.URL(serviceURL) );
   call.setOperationName( new QName("SamService", "serviceMethod") );

// HOW SHOULD THIS BE???   
  // QName qVoid=new QName("samNS","void");
    //        call.addParameter( "arg1", qVoid, ParameterMode.IN);

   QName qVec=new QName("samNS","Vector");
   call.setReturnType( qVec );
            retVector = (Vector) call.invoke();
 
------
 
My corresponding deploy.wsdd file is
------
<deployment xmlns="http://xml.apache.org/axis/wsdd/"
            xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
 <service name="SamService" provider="java:RPC">
  <parameter name="className" value="myPackage.SamClass"/>
  <parameter name="allowedMethods" value="*"/>
  <beanMapping qname="samNS:Order" xmlns:samNS="urn:OrderService" languageSpecificType="myPackage.Order"/>
 </service>
</deployment>
/* I have another method that takes in an Order object that I have provided to the BeanSerializer, and it works fine. */
-----
Venkatesh Kancharla <ve...@strandgenomics.com> wrote:
Create QName for Vector and set return type as that..

Add these 2 statements in the client 
QName qVec=new QName("somenamespace","Vector");
call.setReturnType(qVec);

regards
-------------------
Venkatesh Kancharla
---------------------------------------------------------------------
If Necessity Is the Mother of Invention,
then frustration Is Its Father
-unknown
---------------------------------------------------------------------

On Mon, 9 Feb 2004, Sam wrote:

> Hi,
> 
> I am writing a web service (in Java) that has a method returning a Vector. Can anyone let me know how this can be handled in the client? 
> Specifically, how do I call the call.setReturnType() method? Also, does it matter what the Vector has? (I think it does not, but just to confirm). And do we need to do anything extra in the deploy.wsdd file for this?
> 
> 
> Thanks,
> Sam
> 
> 
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Finance: Get your refund fast by filing online



---------------------------------
Do you Yahoo!?
Yahoo! Finance: Get your refund fast by filing online

Re: How to return a Vector

Posted by Venkatesh Kancharla <ve...@strandgenomics.com>.
Create QName for Vector and set return type as that..

Add these 2 statements in the client 
QName qVec=new QName("somenamespace","Vector");
call.setReturnType(qVec);

regards
-------------------
Venkatesh Kancharla
---------------------------------------------------------------------
      If Necessity Is the Mother of Invention,
         then frustration Is Its Father
                                        -unknown
---------------------------------------------------------------------

On Mon, 9 Feb 2004, Sam wrote:

> Hi,
>  
> I am writing a web service (in Java) that has a method returning a Vector. Can anyone let me know how this can be handled in the client? 
> Specifically, how do I call the call.setReturnType() method? Also, does it matter what the Vector has? (I think it does not, but just to confirm). And do we need to do anything extra in the deploy.wsdd file for this?
>  
>  
> Thanks,
> Sam
> 
> 
> ---------------------------------
> Do you Yahoo!?
> Yahoo! Finance: Get your refund fast by filing online