Thursday, November 24, 2011

Webservice with Bean class

Feel free to pass object to client through web-service.If you are using on axis frame wrok you have to keep in mind below manifest function.

Here is EmployeeManager service class

package mypackage;

/**

* User: aruna
* Date: Feb 3, 2011
* Time: 10:46:23 AM

*/
public class EmployeeManager {
/**
* Get all employees
* @return object of Employee
*/
public Employee getAllEmployees(Employee employees) {


return employees;
}

/**
* Save employees
* @param employees Employee objects
*/


}

Here is Employee bean class
package mypackage;


public class Employee {
private String name;
private double salary;
private String designation;

/**
* @return Returns the name.
*/
public String getName() {
return name;
}
/**
* @param name The name to set.
*/
public void setName(String name) {
this.name = name;
}
/**
* @return Returns the salary.
*/
public double getSalary() {
return salary;
}
/**
* @param salary The salary to set.
*/
public void setSalary(double salary) {
this.salary = salary;
}
/**
* @return Returns the designation.
*/
public String getDesignation() {
return designation;
}
/**
* @param designation The designation to set.
*/
public void setDesignation(String designation) {
this.designation = designation;
}
}

Here is server-config.wsdd configuration.






http://mypackage
languageSpecificType="java:mypackage.Employee"
serializer="org.apache.axis.encoding.ser.BeanSerializerFactory" deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>

No comments:

Post a Comment