3 Replies Latest reply on Mar 28, 2006 2:39 AM by Thomas Diesler

    A handler that needs to be called before the EJB transaction

    Ivan Neto Newbie

      As far as I know, JBossWS handlers are run in the following order on the server-side: pre-handler chain (standard-jbossws-endpoint-config.xml/jbossws-endpoint-config.xml), handlers in webservices.xml, and then the post-handler chain (also in standard-jbossws-endpoint-config.xml/jbossws-endpoint-config.xml). In the case of an EJB 2.1 WS, these handlers are called using a 'HandlerCallback', and this callback is called only after the EJB transaction interceptor (in fact it's called after the TxInterceptorCMT/BMP and CallValidation interceptors). This complies with the JAXRPC 1.1 spec.

      I have a WS-AtomicTransaction handler that needs to be called _before_ the EJB transaction interceptor. I need this to be able to import the transaction context propagated with the SOAP request and bind it to the 'Invocation' that will pass through the EJB interceptor chain. The best place for this kind of handler to run is before the 'Invocation' instance is created, what is done at ServiceEndpointInvokerEJB21.invokeServiceEndpoint(). I've done an ad hoc solution, simply placing a hard-coded call to my handler before the creation of the 'Invocation'; something like:

      ServiceEndpointInvokerEJB21.invokeServiceEndpoint() {
       SOAPMessageContextImpl msgContext = MessageContextAssociation.peekMessageContext();
       TxServerHandler.handleInbound(msgContext); // My handler
       // Create the invocation and send it through the MBean server

      I wish there was a better way to do so. Is there in JBossWS any handler chain that runs before the EJB transaction interceptor? Any suggestions on how to achieve this?