Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
3.2.5
-
None
-
Unknown
Description
When a SOAP fault is received, asynchronous JAX-WS client throws ExecutionException with a CXF-specific SoapFault as its cause:
Caused by: java.util.concurrent.ExecutionException: org.apache.cxf.binding.soap.SoapFault: ... at org.apache.cxf.endpoint.ClientCallback.get(ClientCallback.java:147) at org.apache.cxf.jaxws.JaxwsResponseCallback.get(JaxwsResponseCallback.java:49) ...
Instead, the cause of ExecutionException is supposed to contain an instance of javax.xml.ws.soap.SOAPFaultException in this case, as the mapping should be identical for both asynchronous and synchronous cases.
Steps to reproduce:
- Create and publish a service:
TestService.java:package test; import javax.jws.WebMethod; import javax.jws.WebService; @WebService public interface TestService { @WebMethod void test(); }
TestServiceImpl.java:
package test; import javax.jws.WebService; import javax.xml.ws.Endpoint; @WebService(endpointInterface = "test.TestService") public class TestServiceImpl implements TestService { @Override public void test() { throw new IllegalArgumentException("test"); } public static void main(String[] args) { Endpoint.publish("http://localhost:8888/service/test", new TestServiceImpl()); } }
- Generate a client:
wsimport -b bindings.xml -keep http://localhost:8888/service/test?wsdl
bindings.xml:
<bindings xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns="http://java.sun.com/xml/ns/jaxws"> <bindings node="wsdl:definitions/wsdl:portType[@name='TestService']/wsdl:operation[@name='test']"> <enableAsyncMapping>true</enableAsyncMapping> </bindings> </bindings>
- Use the service:
try { testService.test(); } catch (SOAPFaultException e) { System.out.println("good"); } try { testService.testAsync().get(); } catch (ExecutionException e) { if (e.getCause() instanceof SOAPFaultException) { System.out.println("good"); } else { System.out.println("bad"); // fails with CXF } }