Pinned topicCustomize Soap Fault in Case Transaction

‏2012-09-07T03:33:57Z
|Tags:

Answered question
This question has been answered.

Unanswered question
This question has not been answered yet.

We had implemented transaction using QoS and JPA CMT transaction and its all working as expected.
Transaction is getting rollback in case of exception. However service consumer is getting a SoapFault stating Transaction been rollback.
We have requirement to send a customize message along with more detail on reason for rollback as service consumer will use information to send email to support team. I could see the complete trace in system out and reason behind rollback but don't know way to include the same in Soap response?

</soapenv:Body>
</soapenv:Envelope>
I could see the reason for rollback in System.out but want to pass the same to service consumer.

Following is the exception trace in System.out

at org.apache.openjpa.kernel.BrokerImpl.newFlushException(BrokerImpl.java:2302)
at org.apache.openjpa.kernel.BrokerImpl.flush(BrokerImpl.java:2139)
at org.apache.openjpa.kernel.BrokerImpl.flushSafe(BrokerImpl.java:2037)
at org.apache.openjpa.kernel.BrokerImpl.beforeCompletion(BrokerImpl.java:1955)
at com.ibm.ws.uow.ComponentContextSynchronizationWrapper.beforeCompletion(ComponentContextSynchronizationWrapper.java:65)
at com.ibm.tx.jta.RegisteredSyncs.coreDistributeBefore(RegisteredSyncs.java:289)
at com.ibm.ws.tx.jta.RegisteredSyncs.distributeBefore(RegisteredSyncs.java:150)
at com.ibm.ws.tx.jta.TransactionImpl.prePrepare(TransactionImpl.java:2322)
at com.ibm.ws.tx.jta.TransactionImpl.stage1CommitProcessing(TransactionImpl.java:540)
at com.ibm.tx.jta.TransactionImpl.processCommit(TransactionImpl.java:985)
at com.ibm.tx.jta.TransactionImpl.commit(TransactionImpl.java:919)
at com.ibm.ws.tx.jta.TranManagerImpl.commit(TranManagerImpl.java:436)
at com.ibm.tx.jta.TranManagerSet.commit(TranManagerSet.java:161)
at com.ibm.ws.sca.uow.handler.UOWNativeWASStrategyImpl.endGlobalTx(UOWNativeWASStrategyImpl.java:1631)
at com.ibm.ws.sca.uow.handler.UOWNativeWASStrategyImpl.transactionGlobalActivitySessionAny(UOWNativeWASStrategyImpl.java:859)
at com.ibm.ws.sca.uow.handler.JoinUOWNativeHandler.processMessage(JoinUOWNativeHandler.java:212)
at com.ibm.ws.sca.internal.message.impl.MessageDispatcherImpl.processMessageWithPCI(MessageDispatcherImpl.java:766)
at com.ibm.ws.sca.internal.message.impl.MessageDispatcherImpl.processMessage(MessageDispatcherImpl.java:1607)
at com.ibm.ws.sca.internal.message.impl.ManagedMessageImpl.process(ManagedMessageImpl.java:990)
at com.ibm.ws.sca.internal.jaxws.handler.JaxWsExportHandler.processManagedInvoke(JaxWsExportHandler.java:717)
at com.ibm.ws.sca.internal.jaxws.handler.JaxWsExportHandler.processMessage(JaxWsExportHandler.java:414)
at com.ibm.wsspi.sca.jaxws.service.WsExtensionProvider.invoke(WsExtensionProvider.java:131)
at com.ibm.wsspi.sca.jaxws.service.GenericJaxWsExportProvider.invoke(GenericJaxWsExportProvider.java:94)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at org.apache.axis2.jaxws.server.dispatcher.JavaDispatcher.invokeTargetOperation(JavaDispatcher.java:82)
at org.apache.axis2.jaxws.server.dispatcher.ProviderDispatcher.invoke(ProviderDispatcher.java:136)
at org.apache.axis2.jaxws.server.EndpointController.invoke(EndpointController.java:111)
at org.apache.axis2.jaxws.server.JAXWSMessageReceiver.receive(JAXWSMessageReceiver.java:161)
at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:189)
at org.apache.axis2.transport.http.HTTPTransportUtils.processHTTPPostRequest(HTTPTransportUtils.java:275)
at com.ibm.ws.websvcs.transport.http.WASAxis2Servlet.doPost(WASAxis2Servlet.java:1380)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:738)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:831)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1657)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:939)
at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:502)
at com.ibm.ws.webcontainer.servlet.ServletWrapperImpl.handleRequest(ServletWrapperImpl.java:179)
at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3935)
at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:276)
at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:931)
at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1583)
at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:186)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:452)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:511)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:305)
at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:276)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.sendToDiscriminators(NewConnectionInitialReadCallback.java:214)
at com.ibm.ws.tcp.channel.impl.NewConnectionInitialReadCallback.complete(NewConnectionInitialReadCallback.java:113)
at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:165)
at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1604)

Re: Customize Soap Fault in case of Global Transaction

That's what I want. But I am not able to get the exception object.
As the container doing the rollback and exception is throw after mediation flow.
Not sure where I could catch this exception as my code is not doing commit and rollback, container is doing commit/rollback for me.

Re: Customizing Soap Fault in case of Global Transaction

We had defined XA JTA datasource for DB.
We had written JPA to connect to DB.
WESB services request is transform to JPA data object through mediation.
We had also defined WS-Transaction policy set and attached that to fine grained services.
At JPA end we had used entityManager.joinTransaction() and not handle transaction explicitly.
At coarse grained services level we had define QoS.
All is working fine.
Transaction had been rollback in case of SQL issue by container.

However I am getting Soap fault in case the container doing the rollback. We have requirement to send a customize error message in case the container doing the rollback.

I am not able to process the rollback exception, as this been thrown outside of mediation flow.

Not sure is there any way I could catch rollback exception and customize

As we connected the timeout and fail terminals for service Invoker, it is routing through fail terminal and going through the normal fail path and replying with customized error message. After the fail path, container(outside the mediation flow) again calling the rollback mechanism and sending the Service Exception instead of cusotomised error response.

Re: Customizing Soap Fault in case of Global Transaction

i had the chance to solve similar issue with DataPower as WebService intermediary. Here i checked the returned message in the response processing rule and i had the chance to decide, how to convert/transform such "strange" technical message to the required form. So my basic idea is to place some mediation in front of your current service and have transformation for selected returned messages. In WESB you can use XSD anyType for the "technical" message in your technical interface. Later in the flow you can use Java or Type filter or Message Filter to select the right processing of your message. It is not that effective and elegant like the solution with DataPower (DP box did some other things for me like schema validation, SLA management, SSO and audit), but it can be done somehow.

I'm missing real exception catch in the mediations or on ESB service level. On BPEL level, there is the possibility to process exceptions much better.