org.osesb.test.echomessageservice.ejb20
Class EchoMessageWSBean

java.lang.Object
  extended by org.osesb.test.echomessageservice.ejb20.EchoMessageWSBean
All Implemented Interfaces:
java.io.Serializable, javax.ejb.EnterpriseBean, javax.ejb.SessionBean

public class EchoMessageWSBean
extends java.lang.Object
implements javax.ejb.SessionBean

EchoMessageWSBean stateless session bean is configured as a test web service with the following methods:

Since:
Version .9
See Also:
Serialized Form

Field Summary
protected  java.text.SimpleDateFormat sdf
           
 
Constructor Summary
EchoMessageWSBean()
           
 
Method Summary
 void consumeMessage(java.lang.String xmlMessageText)
          Consume a message - no reply.
 java.lang.String echoMessage(java.lang.String xmlMessageText)
          Echo message to the caller.
 java.lang.String echoMessageWithAttachments(java.lang.String xmlMessageText)
          Echo message and attachments to the caller.
 java.lang.String echoMessageWithSecurity(java.lang.String xmlMessageText)
          Echo message to the caller.
 void echoMessageWithWSAddressingReplyTo(java.lang.String xmlMessageText)
          Send the received message to a web service identified by a ReplyTo, ws-addresssing, EndpointReference in the SOAPHeader.
 void ejbActivate()
           
 void ejbCreate()
          ejbCreate().
 void ejbPassivate()
           
 void ejbRemove()
           
 javax.ejb.SessionContext getSessionContext()
           
 void receiveWSReplyMessage(java.lang.String xmlMessageText)
          receiveWSReplyMessage() is exposed as a web service to receive the message sent by echoMessageWithWSAddressingReplyTo().
 void setSessionContext(javax.ejb.SessionContext sessionContext)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sdf

protected java.text.SimpleDateFormat sdf
Constructor Detail

EchoMessageWSBean

public EchoMessageWSBean()
Method Detail

echoMessage

public java.lang.String echoMessage(java.lang.String xmlMessageText)
                             throws java.lang.Exception
Echo message to the caller.

Parameters:
xmlMessageText - The received XML message.
Returns:
the unmodified xmlMessageText.
Throws:
java.lang.Exception - if called with empty messageText.

consumeMessage

public void consumeMessage(java.lang.String xmlMessageText)
                    throws java.lang.Exception
Consume a message - no reply.

Parameters:
xmlMessageText - The received XML message.
Throws:
java.lang.Exception - if called with empty messageText.

echoMessageWithSecurity

public java.lang.String echoMessageWithSecurity(java.lang.String xmlMessageText)
                                         throws java.lang.Exception
Echo message to the caller.

echoMessageWithSecurity() assumes that a JAXRPCServerSecurityHandler is configured in the handler chain and that the handler has set the ThreadLocal variable, securityProfile, to an instance of org.osesb.connectors.jaxrpc.security.WSSSecurityProfile that is populated with security info. The service appends the username in the securityProfile to the XML that is returned to the caller.

Parameters:
xmlMessageText - The received XML message.
Returns:
the xmlMessageText with a element added as a child of thr root element.
Throws:
java.lang.Exception - if called with empty xmlMessageText or if there is an error during the security processing.

echoMessageWithWSAddressingReplyTo

public void echoMessageWithWSAddressingReplyTo(java.lang.String xmlMessageText)
                                        throws java.lang.Exception
Send the received message to a web service identified by a ReplyTo, ws-addresssing, EndpointReference in the SOAPHeader.

echoMessageWithWSAddressingReplyTo() assumes that a JAXRPCServerAddressingHandler is configured in the handler chain and that the handler has set the ThreadLocal variable, jaxrpcWSAddressingConfiguration, to an instance of org.osesb.connectors.jaxrpc.addressing.configuration.JAXRPCWSAddressingConfiguration that is populated with ws-addressing info. Instead of echoing the XML message to the caller, the XML message is sent to the web service identified by the <ReplyTo EndpointReference that is part of the jaxrpcWSAddressingConfiguration.

There are two ways to construct and send a message to the <wsa:ReplyTo> destination, depending on the entries in the <MetaData> tag of the <wsa:ReplyTo> EndpointReference:

  1. Use the <MetaData> tag of the <wsa:ReplyTo> EndpointReference to carry JAXRPCConfiguration, which is used to construct a JAXRPCDynamicClient to send the reply. The problem with this approach is that JAXRPCDynamicClient sets properties on the jax-rpc Call object and some SOAP engines, like WLS 8.1.x, do not support programmer-defined Call object properties. So in order to use this approach in WLS 8.1.x, Axis has to be configured as the SOAP client and this involves the adding Axis jars to the front of the class path that WLS is loaded with. This effects all applications in that server instance and is unacceptable solution for WLS 8.1.x. The advantages to this approach are 1) the WSDL of the target end point is used to send the reply, 2) JAXRPCDynamicClient(s) can be pooled and 3) the jax-rpc client pool configurations can include jax-rpc handlers.
  2. Use <operationName> and <targetNamespace> elements in the <wsa:MetaData> tag of the <wsa:ReplyTo> content model to construct the reply SOAPMessage using rpc-style invocation. Then use a SOAPConnectionFactory to create a SOAPConnection and invoke the call() method passing the address and the reply SOAPMessage. The advantage to this approach is that it does not require any special features and should be universally supported by SOAP engines.

Parameters:
xmlMessageText - The received XML message.
Throws:
java.lang.Exception - if called with empty xmlMessageText or if there is an error during the ws-addressing processing.

receiveWSReplyMessage

public void receiveWSReplyMessage(java.lang.String xmlMessageText)
                           throws java.lang.Exception
receiveWSReplyMessage() is exposed as a web service to receive the message sent by echoMessageWithWSAddressingReplyTo(). The EchoMessageReplyReceiver service is configured as the ReplyTo EndpointReference for the echoMessageWithWSAddressingReplyTo service.

receiveWSReplyMessage() assumes that a JAXRPCServerAddressingHandler is configured in the handler chain and that the handler has set the ThreadLocal variable, jaxrpcWSAddressingConfiguration, to an instance of org.osesb.connectors.jaxrpc.addressing.configuration.JAXRPCWSAddressingConfiguration that is populated with ws-addressing info that includes:

Parameters:
xmlMessageText - The received XML message.
Throws:
java.lang.Exception - if called with empty xmlMessageText.

echoMessageWithAttachments

public java.lang.String echoMessageWithAttachments(java.lang.String xmlMessageText)
                                            throws java.lang.Exception
Echo message and attachments to the caller.

echoMessageWithAttachments() assumes that a JAXRPCServerAttachmentHandler is configured in the handler chain.

On the request side, JAXRPCServerAttachmentHandler#handleRequest() sets the ThreadLocal variable, requestAttachmentList, to a List of AttachmentDescriptors that encapsulate the attachments extracted from the request message.

echoMessageWithAttachments() processes the attachments and populates the ThreadLocal variable, responseAttachmentList, with the attachments that were extracted from the request message.

In the response flow, JAXRPCServerAttachmentHandler#handleResponse() adds the attachments to the response message.

Parameters:
xmlMessageText - The received XML message.
Returns:
the unmodified xmlMessageText.
Throws:
java.lang.Exception - if called with empty xmlMessageText or if there is an error during attachment processing.

ejbCreate

public void ejbCreate()
               throws javax.ejb.CreateException
ejbCreate().

Throws:
javax.ejb.CreateException

ejbRemove

public void ejbRemove()
Specified by:
ejbRemove in interface javax.ejb.SessionBean

ejbActivate

public void ejbActivate()
Specified by:
ejbActivate in interface javax.ejb.SessionBean

ejbPassivate

public void ejbPassivate()
Specified by:
ejbPassivate in interface javax.ejb.SessionBean

getSessionContext

public javax.ejb.SessionContext getSessionContext()

setSessionContext

public void setSessionContext(javax.ejb.SessionContext sessionContext)
Specified by:
setSessionContext in interface javax.ejb.SessionBean