Search in sources :

Example 1 with Provider

use of javax.xml.ws.Provider in project cxf by apache.

the class JAXWSMethodInvoker method invoke.

@Override
protected Object invoke(Exchange exchange, final Object serviceObject, Method m, List<Object> params) {
    // set up the webservice request context
    WrappedMessageContext ctx = new WrappedMessageContext(exchange.getInMessage(), Scope.APPLICATION);
    Map<String, Object> handlerScopedStuff = removeHandlerProperties(ctx);
    final MessageContext oldCtx = WebServiceContextImpl.setMessageContext(ctx);
    List<Object> res = null;
    try {
        if ((params == null || params.isEmpty()) && serviceObject instanceof Provider) {
            params = Collections.singletonList(null);
        }
        res = CastUtils.cast((List<?>) super.invoke(exchange, serviceObject, m, params));
        if ((serviceObject instanceof Provider) && MessageUtils.getContextualBoolean(exchange.getInMessage(), "jaxws.provider.interpretNullAsOneway", true) && (res != null && !res.isEmpty() && res.get(0) == null) && exchange.getInMessage().getInterceptorChain().getState() == InterceptorChain.State.EXECUTING) {
            // treat the non-oneway call as oneway when a provider returns null
            // and the chain is not suspended due to a continuation suspend
            res = null;
            changeToOneway(exchange);
        }
        // update the webservice response context
        updateWebServiceContext(exchange, ctx);
    } catch (Fault f) {
        // get chance to copy over customer's header
        if (MessageUtils.getContextualBoolean(exchange.getInMessage(), COPY_SOAP_HEADERS_BY_FAULT, true)) {
            updateHeader(exchange, ctx);
        }
        throw f;
    } finally {
        // restore the WebServiceContextImpl's ThreadLocal variable to the previous value
        if (oldCtx == null) {
            WebServiceContextImpl.clear();
        } else {
            WebServiceContextImpl.setMessageContext(oldCtx);
        }
        addHandlerProperties(ctx, handlerScopedStuff);
    }
    return res;
}
Also used : WrappedMessageContext(org.apache.cxf.jaxws.context.WrappedMessageContext) List(java.util.List) Fault(org.apache.cxf.interceptor.Fault) WrappedMessageContext(org.apache.cxf.jaxws.context.WrappedMessageContext) MessageContext(javax.xml.ws.handler.MessageContext) Provider(javax.xml.ws.Provider)

Aggregations

List (java.util.List)1 Provider (javax.xml.ws.Provider)1 MessageContext (javax.xml.ws.handler.MessageContext)1 Fault (org.apache.cxf.interceptor.Fault)1 WrappedMessageContext (org.apache.cxf.jaxws.context.WrappedMessageContext)1