Search in sources :

Example 1 with ThrowableContainerPropertySet

use of com.sun.xml.ws.api.pipe.ThrowableContainerPropertySet in project metro-jax-ws by eclipse-ee4j.

the class ThrowableInPacketCompletionTest method testThrowableAsync.

public void testThrowableAsync() {
    Service service = Service.create(SERVICE_NAME, serviceFeatures());
    service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, "http://localhost:7001/TestService/TestPort");
    Dispatch<Packet> dispatch = service.createDispatch(PORT_NAME, Packet.class, Mode.MESSAGE, portFeatures(false));
    Packet request = new Packet();
    try {
        Response<Packet> response = dispatch.invokeAsync(request);
        assertNotNull(response);
        Packet responsePacket = response.get();
        assertNotNull(responsePacket);
        ThrowableContainerPropertySet ps = responsePacket.getSatellite(ThrowableContainerPropertySet.class);
        fail("Exception expected, but got none");
    } catch (Throwable t) {
        assertTrue(t instanceof ExecutionException);
        assertTrue(t.getCause() instanceof WebServiceException);
        assertTrue(t.getCause().getCause() instanceof TestException);
    }
}
Also used : Packet(com.sun.xml.ws.api.message.Packet) WebServiceException(jakarta.xml.ws.WebServiceException) Service(jakarta.xml.ws.Service) ThrowableContainerPropertySet(com.sun.xml.ws.api.pipe.ThrowableContainerPropertySet) ExecutionException(java.util.concurrent.ExecutionException)

Example 2 with ThrowableContainerPropertySet

use of com.sun.xml.ws.api.pipe.ThrowableContainerPropertySet in project metro-jax-ws by eclipse-ee4j.

the class ThrowableInPacketCompletionTest method testThrowableInPacketAsync.

public void testThrowableInPacketAsync() {
    Service service = Service.create(SERVICE_NAME, serviceFeatures());
    service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, "http://localhost:7001/TestService/TestPort");
    Dispatch<Packet> dispatch = service.createDispatch(PORT_NAME, Packet.class, Mode.MESSAGE, portFeatures(true));
    Packet request = new Packet();
    try {
        Response<Packet> response = dispatch.invokeAsync(request);
        assertNotNull(response);
        Packet responsePacket = response.get();
        assertNotNull(responsePacket);
        ThrowableContainerPropertySet ps = responsePacket.getSatellite(ThrowableContainerPropertySet.class);
        assertNotNull(ps);
        assertTrue(ps.getThrowable() instanceof TestException);
    } catch (Throwable t) {
        fail("Exception not expected, but got: " + t.getMessage());
    }
}
Also used : Packet(com.sun.xml.ws.api.message.Packet) Service(jakarta.xml.ws.Service) ThrowableContainerPropertySet(com.sun.xml.ws.api.pipe.ThrowableContainerPropertySet)

Example 3 with ThrowableContainerPropertySet

use of com.sun.xml.ws.api.pipe.ThrowableContainerPropertySet in project metro-jax-ws by eclipse-ee4j.

the class ThrowableInPacketCompletionTest method testThrowableInPacket.

public void testThrowableInPacket() {
    Service service = Service.create(SERVICE_NAME, serviceFeatures());
    service.addPort(PORT_NAME, SOAPBinding.SOAP11HTTP_BINDING, "http://localhost:7001/TestService/TestPort");
    Dispatch<Packet> dispatch = service.createDispatch(PORT_NAME, Packet.class, Mode.MESSAGE, portFeatures(true));
    Packet request = new Packet();
    try {
        Packet response = dispatch.invoke(request);
        assertNotNull(response);
        ThrowableContainerPropertySet ps = response.getSatellite(ThrowableContainerPropertySet.class);
        assertNotNull(ps);
        assertTrue(ps.getThrowable() instanceof TestException);
    } catch (Throwable t) {
        fail("Exception not expected, but got: " + t.getMessage());
    }
}
Also used : Packet(com.sun.xml.ws.api.message.Packet) Service(jakarta.xml.ws.Service) ThrowableContainerPropertySet(com.sun.xml.ws.api.pipe.ThrowableContainerPropertySet)

Example 4 with ThrowableContainerPropertySet

use of com.sun.xml.ws.api.pipe.ThrowableContainerPropertySet in project metro-jax-ws by eclipse-ee4j.

the class AsyncProviderInvokerTube method processRequest.

/*
    * This binds the parameter for Provider endpoints and invokes the
    * invoke() method of {@linke Provider} endpoint. The return value from
    * invoke() is used to create a new {@link Message} that traverses
    * through the Pipeline to transport.
    */
@NotNull
public NextAction processRequest(@NotNull Packet request) {
    T param = argsBuilder.getParameter(request);
    NoSuspendResumer resumer = new NoSuspendResumer();
    @SuppressWarnings({ "rawtypes", "unchecked" }) AsyncProviderCallbackImpl callback = new AsyncProviderInvokerTube.AsyncProviderCallbackImpl(request, resumer);
    AsyncWebServiceContext ctxt = new AsyncWebServiceContext(getEndpoint(), request);
    AsyncProviderInvokerTube.LOGGER.fine("Invoking AsyncProvider Endpoint");
    try {
        getInvoker(request).invokeAsyncProvider(request, param, callback, ctxt);
    } catch (Throwable e) {
        LOGGER.log(Level.SEVERE, e.getMessage(), e);
        return doThrow(e);
    }
    synchronized (callback) {
        if (resumer.response != null) {
            // Only used by AsyncProvider<Packet>
            // Implementation may pass Packet containing throwable; use both
            ThrowableContainerPropertySet tc = resumer.response.getSatellite(ThrowableContainerPropertySet.class);
            Throwable t = (tc != null) ? tc.getThrowable() : null;
            return t != null ? doThrow(resumer.response, t) : doReturnWith(resumer.response);
        }
        // Suspend the Fiber. AsyncProviderCallback will resume the Fiber after
        // it receives response.
        callback.resumer = new FiberResumer();
        return doSuspend();
    }
}
Also used : ThrowableContainerPropertySet(com.sun.xml.ws.api.pipe.ThrowableContainerPropertySet) NotNull(com.sun.istack.NotNull)

Example 5 with ThrowableContainerPropertySet

use of com.sun.xml.ws.api.pipe.ThrowableContainerPropertySet in project metro-jax-ws by eclipse-ee4j.

the class SyncProviderInvokerTube method processRequest.

/*
    * This binds the parameter for Provider endpoints and invokes the
    * invoke() method of {@linke Provider} endpoint. The return value from
    * invoke() is used to create a new {@link Message} that traverses
    * through the Pipeline to transport.
    */
public NextAction processRequest(Packet request) {
    WSDLPort port = getEndpoint().getPort();
    WSBinding binding = getEndpoint().getBinding();
    T param = argsBuilder.getParameter(request);
    LOGGER.fine("Invoking Provider Endpoint");
    T returnValue;
    try {
        returnValue = getInvoker(request).invokeProvider(request, param);
    } catch (Exception e) {
        LOGGER.log(Level.SEVERE, e.getMessage(), e);
        Packet response = argsBuilder.getResponse(request, e, port, binding);
        return doReturnWith(response);
    }
    if (returnValue == null) {
        // Don't do this above, since close() may generate some exceptions
        if (request.transportBackChannel != null) {
            request.transportBackChannel.close();
        }
    }
    Packet response = argsBuilder.getResponse(request, returnValue, port, binding);
    // Only used by Provider<Packet>
    // Implementation may pass Packet containing throwable; use both
    ThrowableContainerPropertySet tc = response.getSatellite(ThrowableContainerPropertySet.class);
    Throwable t = (tc != null) ? tc.getThrowable() : null;
    return t != null ? doThrow(response, t) : doReturnWith(response);
}
Also used : WSBinding(com.sun.xml.ws.api.WSBinding) Packet(com.sun.xml.ws.api.message.Packet) ThrowableContainerPropertySet(com.sun.xml.ws.api.pipe.ThrowableContainerPropertySet) WSDLPort(com.sun.xml.ws.api.model.wsdl.WSDLPort)

Aggregations

ThrowableContainerPropertySet (com.sun.xml.ws.api.pipe.ThrowableContainerPropertySet)6 Packet (com.sun.xml.ws.api.message.Packet)5 Service (jakarta.xml.ws.Service)4 WebServiceException (jakarta.xml.ws.WebServiceException)2 NotNull (com.sun.istack.NotNull)1 WSBinding (com.sun.xml.ws.api.WSBinding)1 WSDLPort (com.sun.xml.ws.api.model.wsdl.WSDLPort)1 ExecutionException (java.util.concurrent.ExecutionException)1