spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / programming / java / webservices / chap3 / 4 To page 1To page 2To page 3To page 4To page 6current page
[previous]

Professional Java Web Services

Developer News
OpenOffice 3.2 Lands Amid Critical Changes
Red Hat, IBM Firmly in KVM Virtualization Camp
Red Hat Talks Up Open Source Cloud Plans

Serialization

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:

The 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 To page 1To page 2To page 3To page 4To page 6current page
[previous]


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers

webref The latest from WebReference.com Browse >
Are Google's Language Translation Web Services Ready for Prime Time? · Installing and Using Meeplace, the Business Review CMS · Sending an HTML and Plain Text E-newsletter with ASP.NET, Part 2
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Workers Say Telework Is More Productive, Bosses Not So Sure · Kingston Debuts Power-Saving Memory Upgrades · Social Networking is King: Facebook Edges Google

Created: June 5, 2002
Revised: June 5, 2002

URL: http://webreference.com/programming/java/webservices/chap3/4/6.html