WHB

The Enterprise Java Bean

by William van den Heuvel, 2004
(last update: 2005-08-13)

 

If the client is a JAVA program it may use the supplied Enterprise Java Bean (EJB) to generate the request message and to send it to the server. The name of this EJB is WhbEjb. This same EJB also receives and parses the response message. If the server returns an exception message then the EJB raises an exception containing the text of the exception message.
   
deployment The EJB must be deployed on an Application Server such as WebLogic, Websphere, JBoss or Tomcat. It is a stateless EJB and can be called, for instance, by a Java servlet. See the EJB deployment script.
The EJB requires two env-entries: hostName and hostPort. As the name suggests, hostName specifies the name of the host (or its IP-address) on which the server is running. hostPort is the number of the port dedicated to the server.

   
TCP The EJB makes a TCP connection to the server using this host name and port number.

   
XML The request/response message, as well as the exception message are XML strings. The EJB generates the XML string of the request message and parses the XML string of the response or exception message. The layouts of these messages are shown in "Request/Response message"

   
Parameters Before calling the EJB the caller puts the data for the request message into a container. This container is instantiated from a Java class. This class (WhbMessage) is supplied along with the EJB.

Example: WhbMessage message = new WhbMessage("CTPdemo1");

The argument denotes the profile name of the application. This is the symbolic name of the destination program on the server that processes the request message (and returns the response message). The profile name will be encapsulated in the profile tag. For the above example this would be: <profile>CTPdemo1</profile> (See "Request message").

The WhbMessage class has methods that enables the caller to store parameters in a tree-like structure. Each such parameter is a node in the tree and has a name and value.
The value of a node (parameter) is set using message.node(name).setValue(value)
When the EJB is called it takes all parameters from the container and generates XML tags that have the same hierarchical structure as the parameters in the container. These XML tags will be subnodes of the message tag (See "Request message"). The name and value of each parameter become the name and value of the corresponding XML tag. This way, the caller can determine the content of the XML string that will be send to the server on the IBM mainframe.
On return, the data in the XML tags of the response message returned will be placed in the container maintaining the hierarchical structure of the XML tags.
The caller can retrieve these parameters using message.node(name).getValue().