Topic
  • 8 replies
  • Latest Post - ‏2014-01-15T10:04:47Z by melda
manishpoddar
manishpoddar
4 Posts

Pinned topic Customize Soap Fault in Case Transaction

‏2012-09-07T03:33:57Z |
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?
Updated on 2012-11-09T13:14:29Z at 2012-11-09T13:14:29Z by SystemAdmin
  • manishpoddar
    manishpoddar
    4 Posts

    Re: Customize Soap Fault in case of Global Transaction

    ‏2012-09-26T20:41:22Z  
    I am getting following Soap response in case the container duing rollback if there is any issue with SQL:

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body>
    <soapenv:Fault>
    <faultcode>soapenv:Server</faultcode>
    <faultstring>javax.xml.ws.WebServiceException: com.ibm.websphere.sca.ServiceRuntimeException: javax.transaction.RollbackException: caused by: javax.transaction.RollbackException</faultstring>
    </soapenv:Fault>
    </soapenv:Body>
    </soapenv:Envelope>

    However want to send a Proper soap Response instead of SoapFault, something like:

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body>
    <out:serviceResponse>
    <SuccessInd>failed</SuccessInd>
    <Reason>Transaction roll back reason from exception object</Reason>
    </out:serviceResponse>

    </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)
  • mmalc
    mmalc
    74 Posts

    Re: Customize Soap Fault in case of Global Transaction

    ‏2012-10-07T08:53:18Z  
    I am getting following Soap response in case the container duing rollback if there is any issue with SQL:

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body>
    <soapenv:Fault>
    <faultcode>soapenv:Server</faultcode>
    <faultstring>javax.xml.ws.WebServiceException: com.ibm.websphere.sca.ServiceRuntimeException: javax.transaction.RollbackException: caused by: javax.transaction.RollbackException</faultstring>
    </soapenv:Fault>
    </soapenv:Body>
    </soapenv:Envelope>

    However want to send a Proper soap Response instead of SoapFault, something like:

    <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
    <soapenv:Body>
    <out:serviceResponse>
    <SuccessInd>failed</SuccessInd>
    <Reason>Transaction roll back reason from exception object</Reason>
    </out:serviceResponse>

    </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)
    Why not trap the exception and map that to your own fault that you send back to the client?
  • manishpoddar
    manishpoddar
    4 Posts

    Re: Customize Soap Fault in case of Global Transaction

    ‏2012-10-09T13:21:41Z  
    • mmalc
    • ‏2012-10-07T08:53:18Z
    Why not trap the exception and map that to your own fault that you send back to the client?
    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.
  • mmalc
    mmalc
    74 Posts

    Re: Customize Soap Fault in case of Global Transaction

    ‏2012-10-12T07:22:41Z  
    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.
    Can you explain a bit more of what you are trying to do?

    What sort of components do you have, how have you wired them up etc?
  • manishpoddar
    manishpoddar
    4 Posts

    Re: Customizing Soap Fault in case of Global Transaction

    ‏2012-10-16T15:21:40Z  
    • mmalc
    • ‏2012-10-12T07:22:41Z
    Can you explain a bit more of what you are trying to do?

    What sort of components do you have, how have you wired them up etc?
    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
  • SystemAdmin
    SystemAdmin
    289 Posts

    Re: Customizing Soap Fault in case of Global Transaction

    ‏2012-11-09T13:14:29Z  
    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
    Hi,
    I'm also facing similar issue fo sending rollback exception. Here is my mediation flow details.
    We we call the CICS adapter to connect to mainframes system it is giving the following response.

    Exception Class: com.ibm.websphere.sca.ServiceRuntimeException
    Exception Message: ResourceException thrown in J2CMethodBindingImpl.invoke() javax.resource.spi.CommException: CTG9631E Error occurred during interaction with CICS: ECI_ERR_NO_CICS, error code: -3

    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.

    Service Response:
    Exception Class: com.ibm.websphere.sca.ServiceRuntimeException
    Exception Message:
    javax.transaction.RollbackException
    Exception Trace: javax.transaction.RollbackException

    If anyone has idea on how to send the customized response. Please suggest.

    Thank you.
  • sreecheer
    sreecheer
    1 Post

    Re: Customizing Soap Fault in case of Global Transaction

    ‏2014-01-14T14:54:09Z  
    Hi,
    I'm also facing similar issue fo sending rollback exception. Here is my mediation flow details.
    We we call the CICS adapter to connect to mainframes system it is giving the following response.

    Exception Class: com.ibm.websphere.sca.ServiceRuntimeException
    Exception Message: ResourceException thrown in J2CMethodBindingImpl.invoke() javax.resource.spi.CommException: CTG9631E Error occurred during interaction with CICS: ECI_ERR_NO_CICS, error code: -3

    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.

    Service Response:
    Exception Class: com.ibm.websphere.sca.ServiceRuntimeException
    Exception Message:
    javax.transaction.RollbackException
    Exception Trace: javax.transaction.RollbackException

    If anyone has idea on how to send the customized response. Please suggest.

    Thank you.

    Has anyone found the solution, I am also facing the same issue. If any one has resolved this issue, please share the solution.

  • melda
    melda
    8 Posts

    Re: Customizing Soap Fault in case of Global Transaction

    ‏2014-01-15T10:04:47Z  
    • sreecheer
    • ‏2014-01-14T14:54:09Z

    Has anyone found the solution, I am also facing the same issue. If any one has resolved this issue, please share the solution.

    Hello,

    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.

    Regards, Jiri