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;
}
Aggregations