You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Giedrius Noreikis (JIRA)" <ji...@apache.org> on 2018/07/23 14:40:00 UTC

[jira] [Updated] (CXF-7798) Mapping of SOAP Faults in Asynchronous JAX-WS Client

     [ https://issues.apache.org/jira/browse/CXF-7798?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Giedrius Noreikis updated CXF-7798:
-----------------------------------
    Description: 
When a SOAP fault is received, asynchronous JAX-WS client throws {{ExecutionException}} with a CXF-specific {{SoapFault}} as its cause:

{code:java}
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)
	...
{code}

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:
{code:java}
package test;

import javax.jws.WebMethod;
import javax.jws.WebService;

@WebService
public interface TestService {
    @WebMethod
    void test();
}
{code}
TestServiceImpl.java:
{code: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());
    }
}
{code}
# Generate a client:
{code}
wsimport -b bindings.xml -keep http://localhost:8888/service/test?wsdl
{code}
bindings.xml:
{code: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>
{code}
# Use the service:
{code:java}
        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
            }
        }
{code}

  was:
When a SOAP fault is received, asynchronous JAX-WS client throws {{ExecutionException}} with a CXF-specific {{SoapFault}} as its cause:

{code:java}
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)
	...
{code}

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.



> Mapping of SOAP Faults in Asynchronous JAX-WS Client
> ----------------------------------------------------
>
>                 Key: CXF-7798
>                 URL: https://issues.apache.org/jira/browse/CXF-7798
>             Project: CXF
>          Issue Type: Bug
>          Components: JAX-WS Runtime
>    Affects Versions: 3.2.5
>            Reporter: Giedrius Noreikis
>            Priority: Major
>
> When a SOAP fault is received, asynchronous JAX-WS client throws {{ExecutionException}} with a CXF-specific {{SoapFault}} as its cause:
> {code:java}
> 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)
> 	...
> {code}
> 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:
> {code:java}
> package test;
> import javax.jws.WebMethod;
> import javax.jws.WebService;
> @WebService
> public interface TestService {
>     @WebMethod
>     void test();
> }
> {code}
> TestServiceImpl.java:
> {code: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());
>     }
> }
> {code}
> # Generate a client:
> {code}
> wsimport -b bindings.xml -keep http://localhost:8888/service/test?wsdl
> {code}
> bindings.xml:
> {code: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>
> {code}
> # Use the service:
> {code:java}
>         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
>             }
>         }
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)