• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to return back an object ?  RSS feed

tejaswini vasist
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have used Tomcat4.0, Axis(i dont remember the version), Jdk1.4, MYSql database
I am implementing web services which takes an object & returns another object.

Problem is that I am unable to retrieve the return object properly. It is not even giving any errors.
I have 5 files. I have attached the files & I think that the problem is either in the file ProjectClient or in deploy.wsdd

It is giving details about the items in the database properly in Admin.java (the one that is shown in output document).But when it receives the object in a variable named result, it is printing null values.
Can you please tell me where I am going wrong.

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import org.apache.axis.AxisFault;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.utils.Options;
import java.io.*;
import java.lang.*;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
public class ProjectClient
public static void main(String [] args) throws Exception
DataInputStream in = new DataInputStream(System.in);
String username=new String();
String password = new String();
Options options = new Options(args);
Admin admin = new Admin();
DisplayItems result = new DisplayItems();
System.out.print("Enter admin username : ");
username = in.readLine();
System.out.print("\nEnter admin password : ");
password = in.readLine();

Service service = new Service();
Call call = (Call) service.createCall();
QName qn = new QName( "urn:BeanService", "Admin" );
QName qn1 = new QName( "urn:BeanService1", "DisplayItems" );
call.registerTypeMapping(Admin.class, qn,
new org.apache.axis.encoding.ser.BeanSerializerFactory(Admin.class, qn),
new org.apache.axis.encoding.ser.BeanDeserializerFactory(Admin.class, qn));
call.registerTypeMapping(DisplayItems.class, qn1,
new org.apache.axis.encoding.ser.BeanSerializerFactory(DisplayItems.class, qn1),
new org.apache.axis.encoding.ser.BeanDeserializerFactory(DisplayItems.class, qn1));
call.setTargetEndpointAddress( new java.net.URL(options.getURL()) );
call.setOperationName( new QName("OrderProject", "processProject") );
call.addParameter( "arg1", qn, ParameterMode.IN );
call.setReturnType( qn1 );
result = (DisplayItems) call.invoke( new Object[] { admin } );
catch (Exception e)
System.out.println("Error : " + e.getMessage());
for(int i=0;i<5; i++)
System.out.println(result.ItemName[i]+" "+result.ThresholdQuantity[i]+" "+result.QuantityRemaining[i]+" " +result.WholesalerID[i]);

<deployment xmlns="http://xml.apache.org/axis/wsdd/"

<service name="OrderProject" provider="java:RPC">

<parameter name="className" value="ProjectBeanService"/>
<parameter name="allowedMethods" value="*"/>

<beanMapping qname="myNS:Admin" xmlns:myNS="urn:BeanService"
<beanMapping qname="myNS isplayItems" xmlns:myNS="urn:BeanService1"
languageSpecificType="java isplayItems"/>
JeanLouis Marechaux
Ranch Hand
Posts: 906
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like you receive an object (result), that this object is compatible with the Bean specification (as you have only registred BeanSerializers) 'cause you don't receive any errors.
But this object is empty...
Have you tried to sniff the messages with TCPMon ?
[ April 29, 2004: Message edited by: Jean-Louis Marechaux ]
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!