Below please find the source code and reuntime results that demonstrates the 
problem I'm having.

This is not my actual application but what I'm doing is essentially the same 
thing.

WEB SERVICE CODE
----------------
package ws.pojo.data;

public class WSDataOnlyObj
{
 public String str = "This is a data only object";
 public int    num = 1;
}



package ws.pojo.service;

import ws.pojo.data.*;

public class WS
{
 private String          str;
 private WSDataOnlyObj   objDataOnly;
 
 public String GetString( )
 {
  str = "This is a string";
  
  return str;
 }
 
 public WSDataOnlyObj GetDataOnlyObj( )
 {
  objDataOnly = new WSDataOnlyObj( );
  return objDataOnly;
 }
}



CLIENT CODE
-----------
package ws.pojo.service;

import ws.pojo.data.*;

import java.rmi.RemoteException;
import javax.xml.namespace.QName;

import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.*;
import org.apache.axis2.client.*;
import org.apache.axis2.rpc.client.*;

public class WSClient
{
 public static void main(String[] args)
 {
  try
  {
   WSStub.GetStringResponse      getStringResp;
   WSStub.GetDataOnlyObjResponse getDOObjResp;
   
   WSStub stub = new 
WSStub("http://localhost:8080/Webservice/services/WS/ws/pojo/service";);
   
   getStringResp = stub.GetString();
   getDOObjResp  = stub.GetDataOnlyObj();
   
   System.out.println("RESULT Of Call To Web Service GetSting(): " +
                                            getStringResp.get_return());
   System.out.println("RESULT Of Call To Web Service GetDataOnlyObj().getStr(): 
" +  getDOObjResp.get_return().getStr());
   System.out.println("RESULT Of Call To Web Service GetDataOnlyObj().getNum(): 
" +                   getDOObjResp.get_return().getNum());
  }
  catch(AxisFault axisEx)
  {
   System.out.println(axisEx.getMessage());
  }
  catch(RemoteException remEx)
  {
   System.out.println(remEx.getMessage());
  }
 }
}



RESULTS
-------
RESULT Of Call To Web Service GetSting(): This is a string
RESULT Of Call To Web Service GetDataOnlyObj().getStr(): null
RESULT Of Call To Web Service GetDataOnlyObj().getNum(): -2147483648

  ----- Original Message ----- 
  From: Amila Suriarachchi 
  To: [email protected] 
  Sent: Monday, February 02, 2009 1:02 AM
  Subject: Re: Passing And Returning Objects





  On Sun, Feb 1, 2009 at 9:34 PM, Michael <[email protected]> wrote:

    For the web services application I am developing I have designed my web 
services methods to accept objects and return objects.  To avoid any problems 
and follow "best practices" for web development I have designed these objects 
with only "primitives" as attributes for objects that are passed and returned.
  There is no requirement to use only primitives. you can use objects but those 
objects should be POJOs.
   


    The stub code generated by Axis2 appears to provide everything needed to 
get and set the attributed for these objects.  I have tried several of my web 
service methods from a test client using the Axis2 generated client stub.  I am 
able to set the attributes of all passed objects and retrieve the attributes of 
all returned objects, but in both cases the attributes have no values!!!!

  Can you send your wsdl and request and response message xmls? 


    I have debugged the code on both the server and client side to make sure 
the values were being set correctly going both ways, and they are.  It is as if 
when the objects are serialized and deserialized from client to server or 
server to client the attribute values of the passed and returned objects are 
being lost.

    Can anyone explain?

    Thanks,
    Mike



  -- 
  Amila Suriarachchi
  WSO2 Inc.
  blog: http://amilachinthaka.blogspot.com/



------------------------------------------------------------------------------



  No virus found in this incoming message.
  Checked by AVG - www.avg.com 
  Version: 8.0.233 / Virus Database: 270.10.16/1930 - Release Date: 02/02/09 
07:51:00

Reply via email to