-
Please read the Spring Web Services documentation.
http://static.springsource.org/sprin...ption-resolver
You can provide a custom
Code:
EndpointExceptionResolver
There are several standard resolvers including one that maps Exception types to faultCode, faultString.
For more sophistication, provide your own implementation of
Code:
resolveException(MessageContext, endpoint, Exception)
Take a look at one of the standard implementations to see how to build the response from the exception and message context.
-
You can also subclass SimpleSoapExceptionResolver and implement
Code:
customizeFault(MessageContext messageContext, Object endpoint, Exception ex, SoapFault fault)
That way, you can simply add the faultDetail you want to the fault.
-
I also saw JAXB generate @WebFault like:
@WebFault(name = "ServiceException", targetNamespace = "http://example.com/ess/schema")
public class ServiceExceptionMsg
How does that WebFault fits into the picture ?
Thanks
-
I am not familiar with it, but there's nothing stopping you from using it in your custom exception resolver.
-
When I turn off the log message to Error I still receive this error in log
Code:
[2/22/13 15:30:08:640 EST] 0000002a SystemErr R java.lang.RuntimeException: Sucessful throw soapfault ....
[2/22/13 15:30:08:641 EST] 0000002a SystemErr R at com.example.service.ProviderSearchServiceActivator.performSearch(ProviderSearchServiceActivator.java:158)
[2/22/13 15:30:08:641 EST] 0000002a SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[2/22/13 15:30:08:641 EST] 0000002a SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
[2/22/13 15:30:08:641 EST] 0000002a SystemErr R at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[2/22/13 15:30:08:641 EST] 0000002a SystemErr R at java.lang.reflect.Method.invoke(Method.java:619)
[2/22/13 15:30:08:641 EST] 0000002a SystemErr R at org.springframework.expression.spel.support.ReflectiveMethodExecutor.execute(ReflectiveMethodExecutor.java:69)
[2/22/13 15:30:08:641 EST] 0000002a SystemErr R at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:84)
[2/22/13 15:30:08:641 EST] 0000002a SystemErr R at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:57)
[2/22/13 15:30:08:642 EST] 0000002a SystemErr R at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:102)
[2/22/13 15:30:08:642 EST] 0000002a SystemErr R at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:102)
[2/22/13 15:30:08:642 EST] 0000002a SystemErr R at org.springframework.integration.util.AbstractExpressionEvaluator.evaluateExpression(AbstractExpressionEvaluator.java:126)
[2/22/13 15:30:08:642 EST] 0000002a SystemErr R at org.springframework.integration.util.MessagingMethodInvokerHelper.processInternal(MessagingMethodInvokerHelper.java:225)
[2/22/13 15:30:08:642 EST] 0000002a SystemErr R at org.springframework.integration.util.MessagingMethodInvokerHelper.process(MessagingMethodInvokerHelper.java:125)
[2/22/13 15:30:08:642 EST] 0000002a SystemErr R at org.springframework.integration.handler.MethodInvokingMessageProcessor.processMessage(MethodInvokingMessageProcessor.java:73)
[2/22/13 15:30:08:642 EST] 0000002a SystemErr R at org.springframework.integration.handler.ServiceActivatingHandler.handleRequestMessage(ServiceActivatingHandler.java:67)
[2/22/13 15:30:08:642 EST] 0000002a SystemErr R at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:97)
[2/22/13 15:30:08:642 EST] 0000002a SystemErr R at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73)
[2/22/13 15:30:08:643 EST] 0000002a SystemErr R at org.springframework.integration.handler.MessageHandlerChain.handleMessageInternal(MessageHandlerChain.java:137)
[2/22/13 15:30:08:643 EST] 0000002a SystemErr R at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73)
[2/22/13 15:30:08:643 EST] 0000002a SystemErr R at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:115)
[2/22/13 15:30:08:643 EST] 0000002a SystemErr R at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:102)
[2/22/13 15:30:08:643 EST] 0000002a SystemErr R at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)
[2/22/13 15:30:08:643 EST] 0000002a SystemErr R at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:157)
[2/22/13 15:30:08:643 EST] 0000002a SystemErr R at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:128)
[2/22/13 15:30:08:643 EST] 0000002a SystemErr R at org.springframework.integration.core.MessagingTemplate.doSend(MessagingTemplate.java:288)
[2/22/13 15:30:08:643 EST] 0000002a SystemErr R at org.springframework.integration.core.MessagingTemplate.send(MessagingTemplate.java:149)
[2/22/13 15:30:08:643 EST] 0000002a SystemErr R at org.springframework.integration.router.AbstractMessageRouter.handleMessageInternal(AbstractMessageRouter.java:128)
[2/22/13 15:30:08:644 EST] 0000002a SystemErr R at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73)
[2/22/13 15:30:08:644 EST] 0000002a SystemErr R at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:115)
[2/22/13 15:30:08:644 EST] 0000002a SystemErr R at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:102)
[2/22/13 15:30:08:644 EST] 0000002a SystemErr R at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)
[2/22/13 15:30:08:644 EST] 0000002a SystemErr R at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:157)
[2/22/13 15:30:08:644 EST] 0000002a SystemErr R at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:128)
[2/22/13 15:30:08:644 EST] 0000002a SystemErr R at org.springframework.integration.core.MessagingTemplate.doSend(MessagingTemplate.java:288)
[2/22/13 15:30:08:644 EST] 0000002a SystemErr R at org.springframework.integration.core.MessagingTemplate.send(MessagingTemplate.java:149)
[2/22/13 15:30:08:644 EST] 0000002a SystemErr R at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.sendMessage(AbstractReplyProducingMessageHandler.java:175)
[2/22/13 15:30:08:644 EST] 0000002a SystemErr R at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.sendReplyMessage(AbstractReplyProducingMessageHandler.java:159)
[2/22/13 15:30:08:644 EST] 0000002a SystemErr R at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.produceReply(AbstractReplyProducingMessageHandler.java:124)
[2/22/13 15:30:08:645 EST] 0000002a SystemErr R at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleResult(AbstractReplyProducingMessageHandler.java:114)
[2/22/13 15:30:08:645 EST] 0000002a SystemErr R at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:100)
[2/22/13 15:30:08:645 EST] 0000002a SystemErr R at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73)
[2/22/13 15:30:08:645 EST] 0000002a SystemErr R at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:115)
[2/22/13 15:30:08:645 EST] 0000002a SystemErr R at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:102)
[2/22/13 15:30:08:645 EST] 0000002a SystemErr R at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)
[2/22/13 15:30:08:645 EST] 0000002a SystemErr R at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:157)
[2/22/13 15:30:08:645 EST] 0000002a SystemErr R at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:128)
[2/22/13 15:30:08:645 EST] 0000002a SystemErr R at org.springframework.integration.core.MessagingTemplate.doSend(MessagingTemplate.java:288)
[2/22/13 15:30:08:645 EST] 0000002a SystemErr R at org.springframework.integration.core.MessagingTemplate.send(MessagingTemplate.java:149)
[2/22/13 15:30:08:646 EST] 0000002a SystemErr R at org.springframework.integration.router.AbstractMessageRouter.handleMessageInternal(AbstractMessageRouter.java:128)
[2/22/13 15:30:08:646 EST] 0000002a SystemErr R at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73)
[2/22/13 15:30:08:646 EST] 0000002a SystemErr R at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:115)
[2/22/13 15:30:08:646 EST] 0000002a SystemErr R at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:102)
[2/22/13 15:30:08:646 EST] 0000002a SystemErr R at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)
[2/22/13 15:30:08:646 EST] 0000002a SystemErr R at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:157)
[2/22/13 15:30:08:646 EST] 0000002a SystemErr R at org.springframework.integration.core.MessagingTemplate.doSend(MessagingTemplate.java:288)
[2/22/13 15:30:08:646 EST] 0000002a SystemErr R at org.springframework.integration.core.MessagingTemplate.doSendAndReceive(MessagingTemplate.java:318)
[2/22/13 15:30:08:646 EST] 0000002a SystemErr R at org.springframework.integration.core.MessagingTemplate.sendAndReceive(MessagingTemplate.java:239)
[2/22/13 15:30:08:647 EST] 0000002a SystemErr R at
And the SOAP FAULT I receive is not the message I throwed: Sucessful throw soapfault
-
Yes, an exception in any component will result in a SOAP fault.
-
Hello Gary,
In the diagram above, let's say I throw runtimeException in the serviceActivator of the InboundGateway, is it continue moving the flow to aggregation and create the soapfault to return to the client ?
I tried to throw RUntimeException in ServiceActivator and the flow didn't stop right a way. In the log, I receive the error as follow:
Code:
[2/22/13 15:30:08:640 EST] 0000002a SystemErr R java.lang.RuntimeException: Sucessful throw soapfault ....
[2/22/13 15:30:08:641 EST] 0000002a SystemErr R at com.example.service.ProviderSearchServiceActivator.performSearch(ProviderSearchServiceActivator.java:158)
[2/22/13 15:30:08:641 EST] 0000002a SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[2/22/13 15:30:08:641 EST] 0000002a SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79)
[2/22/13 15:30:08:641 EST] 0000002a SystemErr R at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[2/22/13 15:30:08:641 EST] 0000002a SystemErr R at java.lang.reflect.Method.invoke(Method.java:619)
[2/22/13 15:30:08:641 EST] 0000002a SystemErr R at org.springframework.expression.spel.support.ReflectiveMethodExecutor.execute(ReflectiveMethodExecutor.java:69)
[2/22/13 15:30:08:641 EST] 0000002a SystemErr R at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:84)
[2/22/13 15:30:08:641 EST] 0000002a SystemErr R at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:57)
[2/22/13 15:30:08:642 EST] 0000002a SystemErr R at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:102)
[2/22/13 15:30:08:642 EST] 0000002a SystemErr R at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:102)
[2/22/13 15:30:08:642 EST] 0000002a SystemErr R at org.springframework.integration.util.AbstractExpressionEvaluator.evaluateExpression(AbstractExpressionEvaluator.java:126)
[2/22/13 15:30:08:642 EST] 0000002a SystemErr R at org.springframework.integration.util.MessagingMethodInvokerHelper.processInternal(MessagingMethodInvokerHelper.java:225)
[2/22/13 15:30:08:642 EST] 0000002a SystemErr R at org.springframework.integration.util.MessagingMethodInvokerHelper.process(MessagingMethodInvokerHelper.java:125)
[2/22/13 15:30:08:642 EST] 0000002a SystemErr R at org.springframework.integration.handler.MethodInvokingMessageProcessor.processMessage(MethodInvokingMessageProcessor.java:73)
[2/22/13 15:30:08:642 EST] 0000002a SystemErr R at org.springframework.integration.handler.ServiceActivatingHandler.handleRequestMessage(ServiceActivatingHandler.java:67)
[2/22/13 15:30:08:642 EST] 0000002a SystemErr R at org.springframework.integration.handler.AbstractReplyProducingMessageHandler.handleMessageInternal(AbstractReplyProducingMessageHandler.java:97)
[2/22/13 15:30:08:642 EST] 0000002a SystemErr R at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73)
[2/22/13 15:30:08:643 EST] 0000002a SystemErr R at org.springframework.integration.handler.MessageHandlerChain.handleMessageInternal(MessageHandlerChain.java:137)
[2/22/13 15:30:08:643 EST] 0000002a SystemErr R at org.springframework.integration.handler.AbstractMessageHandler.handleMessage(AbstractMessageHandler.java:73)
[2/22/13 15:30:08:643 EST] 0000002a SystemErr R at org.springframework.integration.dispatcher.UnicastingDispatcher.doDispatch(UnicastingDispatcher.java:115)
[2/22/13 15:30:08:643 EST] 0000002a SystemErr R at org.springframework.integration.dispatcher.UnicastingDispatcher.dispatch(UnicastingDispatcher.java:102)
[2/22/13 15:30:08:643 EST] 0000002a SystemErr R at org.springframework.integration.channel.AbstractSubscribableChannel.doSend(AbstractSubscribableChannel.java:77)
[2/22/13 15:30:08:643 EST] 0000002a SystemErr R at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:157)
[2/22/13 15:30:08:643 EST] 0000002a SystemErr R at org.springframework.integration.channel.AbstractMessageChannel.send(AbstractMessageChannel.java:128)
[2/22/13 15:30:08:643 EST] 0000002a SystemErr R at org.springframework.integration.core.MessagingTemplate.doSend(MessagingTemplate.java:288)
[2/22/13 15:30:08:643 EST] 0000002a SystemErr R at org.springframework.integration.core.MessagingTemplate.send(MessagingTemplate.java:149)
And it continued to aggregation module. Do you know why I can't throw RuntimeException in the serviceActivator ? I just doing this in Synchorously mode.
Thanks
-
Looks like something is catching the exception and invoking e.printStackTrace()
This is unlikely to be the framework. I would need to see a complete DEBUG log to evaluate further but, hopefully, the above should help you track it down.