ctoestreich/cxf-client — Issue #9: CxfClientException is a checked exception
Author: jespersm
Created: 2012-03-01 23:06:13+00:00
State: open

Imagine a JAX-WS generated standard port type interface, called SomeWSDLServicePortType

Now imagine this the following code:

SomeWSDLServicePortType client = new DynamicWebServiceClient(
clientInterface: SomeWSDLServicePortType,
serviceEndpointAddress: "http://localhost:9897/foo",
clientPolicyMap: [receiveTimeout: 1000, connectionTimeout: 1000, allowChunking: true],
webServiceClientFactory: new WebServiceClientFactoryImpl()).getObject()
client.daService(new DeRequestType())

If the service invocation fails, a CxfClientException is thrown by the WSClientInvocationHandler (even if the underlying exception is actually a nice CXF exception itself)

This exception is then propagated through the JAX-WS port type interface which does not declare this exception, and since it is a checked exception, it consequently gets wrapped in an UndeclaredThrowableException, thus adding one more layer of stacktrace into the confusion.

I'm no wiz on Groovy exception handling, but isn't this a bad idea? Wouldn't a RuntimeException such as WebServiceException be a better choice?