I am trying to develop Web services using Tomcat and Apache Axis. I would like to Know how to pass Java Bean as input and output from the web service. Please send me some source code if you have any.
Thanks in Advance,
Supraja
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35241
7
posted
0
Check out the "pojo" sample code that comes with Axis. It demonstrates how to send a JavaBean in a SOAP call.
Thanks for your Reply. But I am finding some problem when executing that code. Please provide me with some code samples for passing JavaBean as input and output from the client Program.
public class EmployeeClient
{
public static void main(String [] args)
{
try {
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress( new java.net.URL("http://localhost:8080/TestWebServices/services/EmployeeWebService") );
call.setOperationName( new QName("http://mypackage", "getAllEmployees") );
QName qn = new QName( "{urn:myPackage}Employee", "Employee" );
call.registerTypeMapping(Employee.class, qn,new org.apache.axis.encoding.ser.BeanSerializerFactory(Employee.class, qn),new org.apache.axis.encoding.ser.BeanDeserializerFactory(Employee.class,qn));
call.setReturnType( org.apache.axis.encoding.XMLType.XSD_ANYTYPE);
Employee ret = (Employee) call.invoke(new Object[]{} );
System.out.println("Length Of the Array : " + ret.name);
} catch (Exception e) {
e.printStackTrace();
}
}
}
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.