Issue Details (XML | Word | Printable)

Key: XFIRE-337
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Dan Diephouse
Reporter: Ralf Schaeftlein
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
XFire

Exception Handling of Client API

Created: 05/Apr/06 01:57 PM   Updated: 26/Apr/06 07:18 PM
Component/s: None
Affects Version/s: 1.1-beta-1
Fix Version/s: 1.1-RC1

Time Tracking:
Not Specified

File Attachments: 1. Java Source File BadService.java (0.4 kB)
2. Java Source File BadServiceTest.java (1 kB)
3. Java Source File BaseTestCase.java (2 kB)
4. Java Source File IBadService.java (0.2 kB)
5. Java Source File MyException.java (0.4 kB)
6. Text File output_junit.txt (6 kB)
7. Text File output_server.txt (18 kB)
8. XML File services.xml (8 kB)
9. Text File tracelog_request_via_Client_API.txt (1 kB)
10. Text File tracelog_via_dynamic_client.txt (1 kB)


Testcase included: yes


 Description  « Hide
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>



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Dan Diephouse added a comment - 09/Apr/06 04:25 PM
Hi Ralph, I can't reproduce this with your test cases. Its throw the right exceptions for me. Do your exceptions happen to extend RuntimeException or something? (although I think those should work too).

Dan Diephouse added a comment - 14/Apr/06 01:44 PM
OK, I see what you're saying now with the SOAP 1.2 stuff. Taking a closer look now...

Ralf Schaeftlein added a comment - 14/Apr/06 04:45 PM
They are two things in this issue:

a) Soap 1.1 used instead of 1.2 as definied services.xml by client api
b) thrown custom Exceptions are not directly given to user of client api, instead it's wrapped inside XFireRuntimeException which leads to special handling on client side to get designed exception


Dan Diephouse added a comment - 19/Apr/06 01:19 PM
Ralf - can you try this again with current SVN? I made it so the client can now work with soap 1.2. Just do:

Foo client = (Foo) new XFireServiceFactory().create(soap12BindingQName, "url");

I think that also probably fixes (b) too.


Dan Diephouse added a comment - 26/Apr/06 07:18 PM
I'm closing this as I can't reproduce now and I haven't heard back from you....