com.ibm.websphere.samples.webservices.addr
Class AddressBookClient

java.lang.Object
  extended by com.ibm.websphere.samples.webservices.addr.AddressBookClient

public class AddressBookClient
extends java.lang.Object

Web Services J2EE client for AddressBook.


Field Summary
protected static java.lang.String[] portVers
          Port identifiers for the ports available on the AddressBookService.
protected static boolean useJNDI
          A flag to determine how to get the port.
 
Constructor Summary
AddressBookClient()
           
 
Method Summary
protected static AddressBook getPortFromFactory(java.lang.String portVer)
          Get a port or interface using a Service obtained from a ServiceFactory.
protected static AddressBook getPortFromJNDI(java.lang.String portVer)
          Get a port or interface using a Service obtained from a JNDI lookup.
static void main(java.lang.String[] args)
           
protected static void printAddress(Address anAddress)
          Print the contents of an Address object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

useJNDI

protected static final boolean useJNDI
A flag to determine how to get the port. If true, use JNDI lookup to get a Service. To use a ServiceFactory to obtain a Service, set useJNDI false. If useJNDI is true, the client must be run in a J2EE client container.

See Also:
Constant Field Values

portVers

protected static java.lang.String[] portVers
Port identifiers for the ports available on the AddressBookService. This is a four letter string such as "W2JE", indicating the port.

Constructor Detail

AddressBookClient

public AddressBookClient()
Method Detail

printAddress

protected static void printAddress(Address anAddress)
Print the contents of an Address object

Parameters:
anAddress - - the Address to print

getPortFromFactory

protected static AddressBook getPortFromFactory(java.lang.String portVer)
                                         throws javax.xml.rpc.ServiceException,
                                                java.net.MalformedURLException
Get a port or interface using a Service obtained from a ServiceFactory. A generic AddressBookService is obtained from the factory. The port is obtained by calling getPort with a port QName and the class on the Service.

Parameters:
portVer - - the port identifier
Returns:
an object implementing AddressBook
Throws:
javax.xml.rpc.ServiceException - if accessing the service or port fails.
java.net.MalformedURLException - if an invalid URL is obtained.

getPortFromJNDI

protected static AddressBook getPortFromJNDI(java.lang.String portVer)
                                      throws javax.xml.rpc.ServiceException,
                                             javax.naming.NamingException,
                                             java.lang.NoSuchMethodException,
                                             java.lang.IllegalAccessException,
                                             java.lang.reflect.InvocationTargetException
Get a port or interface using a Service obtained from a JNDI lookup. A generic AddressBookService is obtained from JNDI. A particular port is obtained from it by calling get*port*, where *port* is particular port name, like "AddressBookJ2EB". A JNDI lookup will work only if the client is running in a J2EE client container.

Parameters:
portVer - - the port identifier
Returns:
an object implementing AddressBook
Throws:
javax.xml.rpc.ServiceException - if accessing the service or port fails.
javax.naming.NamingException - if the JNDI lookup fails.
java.lang.NoSuchMethodException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception