Address Book - TechNotes


For a discussion of Web services, see the IBM WebSphere Web services documentation in the InfoCenter.

The AddressBook Sample illustrates Web Service access in a variety of ways. The sample includes two clients and four variations of the same AddressBook bean. The two clients are a Java 2 Standard Edition (J2SE) client and a Java 2 Enterprise Edition (J2EE) client. Each client exercises the four variations of the AddressBook bean that are deployed on the server.

Finding the source code

You can find the source code for the AddressBook sample in subdirectories of profile_root/samples/src/WebServicesSamples. The source code for each of the four AddressBook application beans is in a subdirectory named as shown in the table below. The simple J2SE client source code is in the Clients/simpleClients/samples/address directory. The J2EE application client source code is under the Clients/applicationClients/AddressBookClient.

z/OS customers: The source code tree for Samples is not provided on the z/OS platform because Sample applications are not built on the z/OS platform.

The four variations of the application beans illustrate different approaches to developing a application enabled for Web services. There are two Enterprise JavaBeans (EJBs), each built using a different approach. One approach demonstrates building a Web services bean by starting with a Web Service Definition Language (WSDL) file and uses the WSDL2Java tool to generate the Java code or bindings.

The artifacts of this EJB include "W2JE" to distinguish them from the other versions. A second enterprises bean is built by starting with an implemented EJB and using the Java2WSDL tool to generate its WSDL file. The WSDL file is used to generate the deployment descriptors. The artifacts of this enterprise bean are designated with "J2WE".

Similarly, the artifacts of the two JavaBeans contain the string "J2WB" or "W2JB" indicating the particular approach.

The following table shows how the four AddressBook beans are named.

 
Port Directory Implementation class Demonstrates
AddressBookW2JE addrEJBTopDown AddressBookSoapBindingImpl.java A Web Service enterprise bean developed by starting with a WSDL file and using the WSDL2Java tool to generate the Java code for the enterprise bean.
AddressBookJ2WE addrEJBBottomUp AddressBookBeanImpl.java A Web Service enterprise bean developed by starting with a bean and using the Java2WSDL tool to generate a WSDL file from which deployment descriptors are created.
AddressBookJ2WB addrBeanBottomUp AddressBookBean.java A Web Service JavaBean developed by starting with a bean and using the Java2WSDL tool to generate a WSDL file from which deployment descriptors are created.
AddressBookW2JB addrBeanTopDown AddressBookBean.java A Web Service JavaBean developed by starting with WSDL and using the WSDL2Java tool to generate the Java code for the bean.

You can find the directories named in the table under the directory, profile_root/samples/src/WebServicesSamples.

Each implementation of the AddressBook service supports the getAddressFromName operation. The operation returns a static response to the client. There is no database storage of addresses. The purpose of this sample is to show the relationship between a bean and a Web Service.

All the versions of the AddressBook service are in the WebServicesSamples.ear file. The unique root context and jar names enable them to deploy simultaneously. In addition, the EJB implementation classes are uniquely named and differ from the JavaBean implementation classes. This uniqueness ensures that the classloader in the server locates the proper implementation class.

Reviewing AddressBook bean relationships

The Sample includes two clients, a J2SE client and a J2EE client. Each client exercises the four variations of the AddressBook bean that are deployed on the server.

The relationship between the four beans deployed on the server can be seen in the client WSDL file, which is crafted for client access to any of the four beans. The WSDL file defines one service, AddressBookService, with four ports. The client AddressBook.wsdl is found in the Samples directory, src/WebServicesSamples/Clients/applicationClients/META-INF.