My Tests runs fine with my testsuite but their seems to be an issue regarding the client side if custom exceptions are thrown. I throw in two service methods special exception including messages.
public void badMethod() throws MyException{
throw new MyException("bad bad");
}
The messages are transported to the client side inside a XFireRuntimeException including a XFireFault with the correct message.
[00:37:02] [ERROR] [test.BadServiceTest]
org.codehaus.xfire.XFireRuntimeException: Could not invoke service.. Nested exception is org.codehaus.xfire.fault.XFireFault: bad bad
org.codehaus.xfire.fault.XFireFault: bad bad
at org.codehaus.xfire.fault.Soap11FaultSerializer.readMessage(Soap11FaultSerializer.java:31)
at org.codehaus.xfire.fault.SoapFaultSerializer.readMessage(SoapFaultSerializer.java:28)
at org.codehaus.xfire.soap.handler.ReadHeadersHandler.checkForFault(ReadHeadersHandler.java:108)
at org.codehaus.xfire.soap.handler.ReadHeadersHandler.invoke(ReadHeadersHandler.java:67)
at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:98)
at org.codehaus.xfire.client.Client.onReceive(Client.java:436)
[00:37:02] [DEBUG] [org.codehaus.xfire.transport.DefaultEndpoint] Received message to /XFireTest/services/BadService [00:37:02] [DEBUG] [org.codehaus.xfire.handler.HandlerPipeline] Invoking handler org.codehaus.xfire.soap.handler.ReadHeadersHandler in phase parse [00:37:02] [DEBUG] [org.codehaus.xfire.handler.HandlerPipeline] Invoking handler org.codehaus.xfire.handler.LocateBindingHandler in phase dispatch [00:37:02] [DEBUG] [org.codehaus.xfire.handler.HandlerPipeline] Invoking handler org.codehaus.xfire.soap.handler.SoapBodyHandler in phase dispatch [00:37:02] [DEBUG] [org.codehaus.xfire.handler.HandlerPipeline] Invoking handler org.codehaus.xfire.soap.handler.SoapActionInHandler in phase dispatch [00:37:02] [DEBUG] [org.codehaus.xfire.handler.HandlerPipeline] Invoking handler org.codehaus.xfire.handler.DispatchServiceHandler in phase dispatch [00:37:02] [DEBUG] [org.codehaus.xfire.handler.HandlerPipeline] Invoking handler org.codehaus.xfire.xml.handler.ExceptionFaultDetailHandler in phase user [00:37:02] [DEBUG] [org.codehaus.xfire.handler.HandlerPipeline] Invoking handler org.codehaus.xfire.soap.handler.ValidateHeadersHandler in phase pre-invoke [00:37:02] [DEBUG] [org.codehaus.xfire.handler.HandlerPipeline] Invoking handler org.codehaus.xfire.service.binding.ServiceInvocationHandler in phase service [00:37:02] [DEBUG] [org.codehaus.xfire.handler.DefaultFaultHandler] Fault occurred!
org.codehaus.xfire.fault.XFireFault: bad bad
at org.codehaus.xfire.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:68)
at org.codehaus.xfire.service.invoker.ObjectInvoker.invoke(ObjectInvoker.java:45)
at org.codehaus.xfire.service.binding.ServiceInvocationHandler.sendMessage(ServiceInvocationHandler.java:260)
at org.codehaus.xfire.service.binding.ServiceInvocationHandler$1.run(ServiceInvocationHandler.java:85)
at org.codehaus.xfire.service.binding.ServiceInvocationHandler.execute(ServiceInvocationHandler.java:132)
at org.codehaus.xfire.service.binding.ServiceInvocationHandler.invoke(ServiceInvocationHandler.java:107)
at org.codehaus.xfire.handler.HandlerPipeline.invoke(HandlerPipeline.java:98)
at org.codehaus.xfire.transport.DefaultEndpoint.onReceive(DefaultEndpoint.java:60)
at org.codehaus.xfire.transport.AbstractChannel.receive(AbstractChannel.java:38)
at org.codehaus.xfire.transport.http.XFireServletController.invoke(XFireServletController.java:287)
at org.codehaus.xfire.transport.http.XFireServletController.doService(XFireServletController.java:146)
at org.codehaus.xfire.transport.http.XFireServlet.doPost(XFireServlet.java:110)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:868)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:663)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
at java.lang.Thread.run(Thread.java:595)
Caused by: test.MyException: bad bad
at test.BadService.badMethod(BadService.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at org.codehaus.xfire.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:52)
... 27 more
[00:37:02] [DEBUG] [org.codehaus.xfire.handler.HandlerPipeline] Invoking handler org.codehaus.xfire.soap.handler.FaultSoapSerializerHandler in phase post-invoke [00:37:02] [DEBUG] [org.codehaus.xfire.handler.HandlerPipeline] Invoking handler org.codehaus.xfire.handler.CustomFaultHandler in phase user [00:37:02] [DEBUG] [org.codehaus.xfire.handler.HandlerPipeline] Invoking handler org.codehaus.xfire.transport.http.XFireServletController$FaultResponseCodeHandler in phase transport [00:37:02] [DEBUG] [org.codehaus.xfire.handler.HandlerPipeline] Invoking handler org.codehaus.xfire.fault.FaultSender in phase send
What me wonders
is the last classes of the stacktrace: Soap11FaultSerializer. The services had to use Soap 1.2 as defined in the services.xml
<service>
<!-- The service name -->
<name>BadService</name>
<!-- The default namespace for the service -->
<namespace>urn:BadService</namespace>
<bindings>
<!-- Adds a SOAP 1.2 bidning -->
<soap12Binding transport="http://www.w3.org/2003/05/soap/bindings/HTTP/"/>
</bindings>
<!-- wrapped, document, or rpc. -->
<style>wrapped</style>
<!-- Document or RPC? -->
<use>literal</use>
<!-- The class for the service -->
<serviceClass>test.IBadService</serviceClass>
<serviceFactory>org.codehaus.xfire.service.binding.ObjectServiceFactory</serviceFactory>
<implementationClass>test.BadService</implementationClass>
</service>
I sniffed the incoming messages which should every time be the same:
----- using my own webservice client -------------
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<soap:Fault>
<soap:Code>
<soap:Value>soap:Sender</soap:Value>
</soap:Code>
<soap:Reason>
<soap:Text>bad bad</soap:Text>
</soap:Reason>
<soap:Detail>
<MyException xmlns="urn:BadService"/>
</soap:Detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
------ using the xfire client ---------
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>bad bad</faultstring>
<detail>
<MyException xmlns="urn:BadService"/>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>