| home / programming / java / webservices / chap3 / 4 | [previous] |
|
Apache SOAP provides serializers for all the default types discussed earlier. We can also provide
our own serializers. However, Apache SOAP provides a serializer for JavaBeans. It can be used to
serialize and deserialize classes that conform to the JavaBean specification. The serializer is
realized in the org.apache.soap.encoding.soapenc.BeanSerializer class.
The BeanSerializer class can handle serialization as long as the class that implements
the type complies with a subset of the rules defined by the JavaBean specification. Not all the rules
for JavaBeans apply here as the specification covers all types of JavaBeans including GUI beans, which
our data type classes are not. Below is list of those rules that apply taken from the Apache SOAP web
site:
setXXX/getXXX methods) are [called] inThe Resume type used in the Job Resumé Repository Service conforms to the
JavaBean specification, with all of the attributes being serializable. So, we don't have to worry
about serializaton, the BeanSerializer will handle it. Let's look at the
Resume class to illustrate how it conforms to the JavaBean specification, which is
located in Resume.java:
package com.wrox.jobresume.common;
public class Resume extends Object {
private String firstName;
private String middleName;
private String lastName;
private String uid; //Unique identifier
private String address;
private String city;
private String state;
private String zipcode;
private String phoneNumber;
private String education;
private String workHistory;
private String references;
public Resume() { }
public Resume(String firstName, String middleName, String lastName,
String address, String city, String state,
String zipcode, String phoneNumber, String education,
String workHistory, String references) {
this.firstName = firstName;
this.middleName = middleName;
this.lastName = lastName;
this.address = address;
this.city = city;
this.state = state;
this.zipcode = zipcode;
this.phoneNumber = phoneNumber;
this.education = education;
this.workHistory = workHistory;
this.references = references;
}
// accessor/mutators removed for brevity's sake
public String toString() {
return "UID: " + uid + "\n" +
"First Name: " + firstName + "\n" +
"Middle Name: " + middleName + "\n" +
"Last Name: " + lastName + "\n" +
"Address: " + address + "\n" +
"City:" + city + "\n" +
"State:" + state + "\n" +
"Zipcode:" + zipcode + "\n" +
"Phone Number:" + phoneNumber + "\n" +
"Education:" + education + "\n" +
"Work History" + workHistory + "\n" +
"References" + references + "\n";
}
}
Note that the Resume class contains a no-argument constructor:
public Resume() { }
Also note that the state is exposed through properties:
public class Resume extends Object {
private String firstName;
private String middleName;
private String lastName;
private String uid; //Unique identifier
private String address;
private String city;
private String state;
private String zipcode;
private String phoneNumber;
private String education;
private String workHistory;
private String references;
...
}
Lastly, each one of the above properties is accessible via accessor/mutator methods. The
accessor and mutator methods for uid is below:
public String getUid() {
return uid
}
public void setUid(String uid) {
this.ssn = uid
}
The uid property is how each Resume is uniquely identified.
| home / programming / java / webservices / chap3 / 4 | [previous] |
Created: June 5, 2002
Revised: June 5, 2002
URL: http://webreference.com/programming/java/webservices/chap3/4/6.html