Uploaded image for project: 'CXF'
  1. CXF
  2. CXF-7798

Mapping of SOAP Faults in Asynchronous JAX-WS Client

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.2.5
    • 3.2.6, 3.3.0
    • JAX-WS Runtime
    • 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:

      1. 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());
            }
        }
        
      2. 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>
        
      3. 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
                    }
                }
        

      Attachments

        Activity

          People

            dkulp Daniel Kulp
            gino Giedrius Noreikis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: