I was finally able to resolve my issue but the resolution confuses me so I
still need some insight from anyone who can give me some.

My User class that I was trying to return from the webservice has a
constructor as follows

public User(String vFname, String vLname, String vPassword,
     String vUuid, String vLogin)
 {
   //first name
  _fname=vFname;
  _lname=vLname;
  _password=vPassword;
  _uuid=vUuid;
  _login=vLogin;
 }

My webservice method that returned me a User object is as follows

public User getObject()
 {
  return new User("John", "Doe", "doe", "111-11-1111", "jdoe")
}

Now all I did was remove the constructor from the User object and create the
user object in the webservice using its default constructor and set the
fields using the set methods and IT WORKED!

My new webservice method looks like this

public User getObject()
 {
  User user = new User();
  user.setFname("John");
  user.setLname("Doe");
  user.setPasswd("doe");
  user.setUuid("111-11-1111");
  user.setLogin("jdoe");
  return user;
 }

What does this mean? Why did this work? Does it mean that when I claim that
a class is bean like then it is not supposed to have a constructor? What was
wrong with my constructor?

I would appreciate if someone could answer these questions of mine.

Thanks
Vaishakhi
----- Original Message -----
From: "Vaishakhi Ajmera" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, April 29, 2002 11:43 AM
Subject: NullPointerException while returning an arbitrary Java object


> Hello,
> I have a webservice method that returns to me a User object which is a
bean
> like class have getters and setters for fields like firstname, lastname,
> password.
>
> My deploy.wsdd looks like this
> <deployment xmlns="http://xml.apache.org/axis/wsdd/";
>             xmlns:java="http://xml.apache.org/axis/wsdd/providers/java";>
>
>  <service name="TestWs" provider="java:RPC">
>   <parameter name="className" value="com.ardec.ebf.test.TestWebService"/>
>   <parameter name="allowedMethods" value="*"/>
>
>   <beanMapping qname="myNS:User" xmlns:myNS="urn:TestWebService"
>                languageSpecificType="java:com.ardec.ebf.usermgr.User"/>
>  </service>
>
> </deployment>
>
> and the client call is as follows
>
> String endpoint = http://localhost:8080/usermgr/services/TestWs
> Service  service = new Service();
> Call     call    = (Call) service.createCall();
>
> call.setTargetEndpointAddress( new java.net.URL(endpoint) );
> call.setOperationName( "getObject" );
>
> QName    qn      = new QName( "urn:TestWebService", "User" );
>
> call.registerTypeMapping(User.class, qn,
>                       new
> org.apache.axis.encoding.ser.BeanSerializerFactory(User.class, qn),
>                       new
> org.apache.axis.encoding.ser.BeanDeserializerFactory(User.class, qn));
>
> call.setReturnType(qn);
>
> User usr = (User) call.invoke( new Object [] {});
>
>
> Now when I run this class to call the service and get me the user object I
> get the following error
>
> - Could not convert java.lang.String to bean field 'password', type
> java.lang.String
>     [junit] - Exception:
>     [junit] java.lang.NullPointerException
>     [junit]  at
org.apache.axis.encoding.ser.BeanPropertyTarget.set(Unknown
> Source)
>     [junit]  at
> org.apache.axis.encoding.DeserializerImpl.valueComplete(Unknown Source)
>     [junit]  at
org.apache.axis.encoding.DeserializerImpl.endElement(Unknown
> Source)
>     [junit]  at
> org.apache.axis.encoding.DeserializationContextImpl.endElement(Unknown
> Source)
>     [junit]  at org.apache.axis.message.SAX2EventRecorder.replay(Unknown
> Source)
>     [junit]  at
> org.apache.axis.message.MessageElement.publishToHandler(Unknown Source)
>     [junit]  at
> org.apache.axis.encoding.DeserializerImpl.startElement(Unknown Source)
>     [junit]  at
> org.apache.axis.encoding.DeserializationContextImpl.startElement(Unknown
> Source)
>     [junit]  at org.apache.axis.message.SAX2EventRecorder.replay(Unknown
> Source)
>     [junit]  at
> org.apache.axis.message.MessageElement.publishToHandler(Unknown Source)
>     [junit]  at org.apache.axis.message.RPCElement.deserialize(Unknown
> Source)
>     [junit]  at org.apache.axis.message.RPCElement.getParams(Unknown
Source)
>     [junit]  at org.apache.axis.client.Call.invoke(Unknown Source)
>     [junit]  at org.apache.axis.client.Call.invoke(Unknown Source)
>     [junit]  at org.apache.axis.client.Call.invoke(Unknown Source)
>     [junit]  at com.ardec.ebf.test.TestWsClient.testGetObject(Unknown
> Source)
>     [junit]  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native
Method)
>     [junit]  at
>
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
> )
>     [junit]  at
>
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
> .java:25)
>     [junit]  at java.lang.reflect.Method.invoke(Method.java:324)
> .
> .
> .
> .
>
> I have tried to follow the example 5 and I know there are many of you who
> have tried to return a Java object from the webservice. Please check my
wsdd
> and client class. What am I doing wrong here. Please help me.
>
> Thanks a lot
> Vaishakhi


Reply via email to