JAX-RPC Web services |
|
|
![]() |
|
Configure and run | Technotes | Javadoc | Build with Ant |
Configuring the Sample |
Running the Sample |
There are two AddressBook clients, a Java 2 Standard Edition (J2SE) version and a Java 2 Enterprise Edition (J2EE) container-managed version. If you want the full benefit of J2EE container services run the J2EE version.
To complete the configuration of this Sample, deploy the JAX-RPC Web services Sample application on the server. If the sample application is not already deployed refer to the instructions for Rebuilding and deploying the WebServicesSamples.ear file.
Verify that the server has started before running the clients.
There are two AddressBook clients, a J2SE external version and a Java 2 Enterprise Edition (J2EE) container-managed version. Each client exercises the four variations of the AddressBook Web Service bean deployed in the server. The AddressBook Web Service beans return a fixed value and do not require an Internet connection to run.
Running the J2SE simple AddressBook client |
Running the J2EE application AddressBook client |
The J2SE AddressBook client demonstrates querying the Web Service AddressBook bean to get an address from the Web Service. You can find its source in the profile_root/samples/src/WebServicesSamples/Clients/simpleClients/samples/address directory.
The AddressBook.wsdl file must be in the current directory when you run the AddressBookClient. Unzip the AddressBook.wsdl file from the simpleClients.jar file and put it in the directory where you plan to run the Sample. You can find the simpleClients.jar file in the install_root/samples/lib/WebServicesSamples directory.
The J2SE client loops twice through each of the AddressBook Web Service beans deployed on the server. During the first loop, the client calls getPort method to obtain a unique port for each bean of the Sample application. The client calls the getAddressFromName method on each port. The second loop arbitrarily starts with one of the ports, then loops through, setting its endpoint address to each of the four possible endpoints. The client calls the getAddressFromName method on each port.
For more general instructions on invoking a WebSphere client, refer to the topic about developing thin application client code in the Info Center.
To run the J2SE simple AddressBook client from a WebSphere Application Server,
perform the following steps, based on your operating system:
C:\>"%JAVA_HOME%\bin\java" %WAS_LOGGING% -classpath "%WAS_CLASSPATH%;%WAS_HOME%\samples\lib\WebServicesSamples\simpleClients.jar;%WAS_HOME%\runtimes\com.ibm.ws.webservices.thinclient_7.0.0.jar" samples.address.AddressBookClient >> Querying address for 'Purdue Boilermaker' using port AddressBookW2JE >> Response is: 1 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 >> Querying address for 'Purdue Boilermaker' using port AddressBookJ2WE >> Response is: 2 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 >> Querying address for 'Purdue Boilermaker' using port AddressBookJ2WB >> Response is: 3 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 >> Querying address for 'Purdue Boilermaker' using port AddressBookW2JB >> Response is: 4 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 >> >> Get port AddressBookJ2WB >> Set port AddressBookJ2WB's endpoint to http://localhost:9080/AddressBookW2JE/services/AddressBook >> Querying address for 'Purdue Boilermaker' >> Response is: 1 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 >> Set port AddressBookJ2WB's endpoint to http://localhost:9080/AddressBookJ2WE/services/AddressBook >> Querying address for 'Purdue Boilermaker' >> Response is: 2 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 >> Set port AddressBookJ2WB's endpoint to http://localhost:9080/AddressBookJ2WB/services/AddressBook >> Querying address for 'Purdue Boilermaker' >> Response is: 3 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 >> Set port AddressBookJ2WB's endpoint to http://localhost:9080/AddressBookW2JB/services/AddressBook >> Querying address for 'Purdue Boilermaker' >> Response is: 4 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 |
The J2EE application AddressBook client is similar to the J2SE simple AddressBook client. It accesses the same AddressBook Web services beans, but does so from a J2EE application client container using the launchClient command.
The J2EE client loops through each of the AddressBook Web Service beans deployed on the server. This client uses a Java Naming and Directory Interface (JNDI) lookup command to locate the AddressBook service and makes get port calls to obtain unique ports for each of the four AddressBook beans. The client calls the getAddressFromName method on each port.
In the following steps, the variable install_root refers to the WebSphere installation root.
To run the J2EE application AddressBook client from a WebSphere Application Server,
perform the following steps, based on your operating system:
C:\WebSphere\AppServer\samples>\WebSphere\AppServer\bin\launchClient \WebSphere\AppServer\samples\lib\WebServicesSamples\ApplicationClients.ear -CCjar=AddressBookClient.jar IBM WebSphere Application Server, Release 7.0 J2EE Application Client Tool Copyright IBM Corp., 1997-2008 WSCL0012I: Processing command line arguments. WSCL0013I: Initializing the J2EE Application Client Environment. [3/29/06 14:47:51:062 CST] 0000000a W UOW=null source=com.ibm.ws.ssl.config.SSLConfig org=IBM prod=WebSphere component=Application Server thread=[P=269328:O=0:CT] CWPKI0041W: One or more key stores are using the default password. WSCL0035I: Initialization of the J2EE Application Client Environment has completed. WSCL0014I: Invoking the Application Client class com.ibm.websphere.samples.webservices.addr.AddressBookClient >> Querying address for 'Purdue Boilermaker' using port AddressBookW2JE >> Response is: 1 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 >> Querying address for 'Purdue Boilermaker' using port AddressBookJ2WE >> Response is: 2 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 >> Querying address for 'Purdue Boilermaker' using port AddressBookJ2WB >> Response is: 3 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 >> Querying address for 'Purdue Boilermaker' using port AddressBookW2JB >> Response is: 4 University Drive West Lafayette, IN 47907 Phone: (765) 555-4900 |
You can learn more about how the client and the application work by referring to the Address Book tech notes and viewing the Java source code.