File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes Web Services Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "Web Services" Watch "Web Services" New topic
Author

Web Services

Supraja Kannaiyan
Ranch Hand

Joined: Mar 09, 2007
Posts: 41
Hi,

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: 41626
    
  55
Check out the "pojo" sample code that comes with Axis. It demonstrates how to send a JavaBean in a SOAP call.


Ping & DNS - my free Android networking tools app
Supraja Kannaiyan
Ranch Hand

Joined: Mar 09, 2007
Posts: 41
Hi,

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.

Thanks,
Supraja
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41626
    
  55
What kind of problem? TellTheDetails
Supraja Kannaiyan
Ranch Hand

Joined: Mar 09, 2007
Posts: 41
I am getting this Exception

[b]Deserializing parameter 'getAllEmployeesReturn': could not find deserializer for type {urn:mypackage}Employee[/b]

My Client COde is

package com;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import org.apache.axis.utils.Options;

import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;
import java.lang.reflect.*;
import mypackage.Employee;

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://aspose.com/file-tools
 
subject: Web Services