Search in sources :

Example 1 with DeserializationException

use of com.sun.xml.ws.encoding.soap.DeserializationException in project metro-jax-ws by eclipse-ee4j.

the class SyncMethodHandler method invoke.

/**
 * Invokes synchronously, but with the given {@link RequestContext}
 * and {@link ResponseContextReceiver}.
 *
 * @param rc
 *      This {@link RequestContext} is used for invoking this method.
 *      We take this as a separate parameter because of the async invocation
 *      handling, which requires a separate copy.
 */
Object invoke(Object proxy, Object[] args, RequestContext rc, ResponseContextReceiver receiver) throws Throwable {
    JavaCallInfo call = owner.databinding.createJavaCallInfo(method, args);
    Packet req = (Packet) owner.databinding.serializeRequest(call);
    // process the message
    Packet reply = owner.doProcess(req, rc, receiver);
    Message msg = reply.getMessage();
    if (msg == null) {
        if (!isOneway || !isVoid) {
            throw new WebServiceException(DispatchMessages.INVALID_RESPONSE());
        }
        return null;
    }
    try {
        call = owner.databinding.deserializeResponse(reply, call);
        if (call.getException() != null) {
            throw call.getException();
        } else {
            return call.getReturnValue();
        }
    } catch (JAXBException e) {
        throw new DeserializationException(DispatchMessages.INVALID_RESPONSE_DESERIALIZATION(), e);
    } catch (XMLStreamException e) {
        throw new DeserializationException(DispatchMessages.INVALID_RESPONSE_DESERIALIZATION(), e);
    } finally {
        if (reply.transportBackChannel != null)
            reply.transportBackChannel.close();
    }
}
Also used : Packet(com.sun.xml.ws.api.message.Packet) JAXBMessage(com.sun.xml.ws.message.jaxb.JAXBMessage) Message(com.sun.xml.ws.api.message.Message) WebServiceException(jakarta.xml.ws.WebServiceException) XMLStreamException(javax.xml.stream.XMLStreamException) JAXBException(jakarta.xml.bind.JAXBException) JavaCallInfo(com.oracle.webservices.api.databinding.JavaCallInfo) DeserializationException(com.sun.xml.ws.encoding.soap.DeserializationException)

Example 2 with DeserializationException

use of com.sun.xml.ws.encoding.soap.DeserializationException in project metro-jax-ws by eclipse-ee4j.

the class DispatchImpl method doInvoke.

/**
 * Synchronously invokes a service.
 *
 * See {@link #process(Packet, RequestContext, ResponseContextReceiver)} on
 * why it takes a {@link RequestContext} and {@link ResponseContextReceiver} as a parameter.
 */
public final T doInvoke(T in, RequestContext rc, ResponseContextReceiver receiver) {
    Packet response = null;
    try {
        try {
            checkNullAllowed(in, rc, binding, mode);
            Packet message = createPacket(in);
            message.setState(Packet.State.ClientRequest);
            resolveEndpointAddress(message, rc);
            setProperties(message, true);
            response = process(message, rc, receiver);
            Message msg = response.getMessage();
            // REVIEW: eliminate allowFaultResponseMsg, but make that behavior default for MessageDispatch, PacketDispatch
            if (msg != null && msg.isFault() && !allowFaultResponseMsg) {
                SOAPFaultBuilder faultBuilder = SOAPFaultBuilder.create(msg);
                // it will get back to us is a protocol exception
                throw (SOAPFaultException) faultBuilder.createException(null);
            }
        } catch (JAXBException e) {
            // TODO: i18nify
            throw new DeserializationException(DispatchMessages.INVALID_RESPONSE_DESERIALIZATION(), e);
        } catch (WebServiceException e) {
            // it could be a WebServiceException or a ProtocolException
            throw e;
        } catch (Throwable e) {
            // WebServiceException
            throw new WebServiceException(e);
        }
        return toReturnValue(response);
    } finally {
        // REVIEW: Move to AsyncTransportProvider
        if (response != null && response.transportBackChannel != null)
            response.transportBackChannel.close();
    }
}
Also used : Packet(com.sun.xml.ws.api.message.Packet) Message(com.sun.xml.ws.api.message.Message) WebServiceException(jakarta.xml.ws.WebServiceException) SOAPFaultBuilder(com.sun.xml.ws.fault.SOAPFaultBuilder) JAXBException(jakarta.xml.bind.JAXBException) SOAPFaultException(jakarta.xml.ws.soap.SOAPFaultException) DeserializationException(com.sun.xml.ws.encoding.soap.DeserializationException)

Aggregations

Message (com.sun.xml.ws.api.message.Message)2 Packet (com.sun.xml.ws.api.message.Packet)2 DeserializationException (com.sun.xml.ws.encoding.soap.DeserializationException)2 JAXBException (jakarta.xml.bind.JAXBException)2 WebServiceException (jakarta.xml.ws.WebServiceException)2 JavaCallInfo (com.oracle.webservices.api.databinding.JavaCallInfo)1 SOAPFaultBuilder (com.sun.xml.ws.fault.SOAPFaultBuilder)1 JAXBMessage (com.sun.xml.ws.message.jaxb.JAXBMessage)1 SOAPFaultException (jakarta.xml.ws.soap.SOAPFaultException)1 XMLStreamException (javax.xml.stream.XMLStreamException)1