private void changeToOneway(Exchange exchange) { exchange.setOneWay(true); exchange.setOutMessage(null); javax.servlet.http.HttpServletResponse httpresp = (javax.servlet.http.HttpServletResponse)exchange.getInMessage(). get("HTTP.RESPONSE"); if (httpresp != null) { httpresp.setStatus(202); } }
protected void setupBindingOperationInfo(Exchange exch, Object data) { if (exch.getBindingOperationInfo() == null) { //need to know the operation to determine if oneway QName opName = getOpQName(exch, data); if (opName == null) { return; } BindingOperationInfo bop = ServiceModelUtil .getOperationForWrapperElement(exch, opName, false); if (bop == null) { bop = ServiceModelUtil.getOperation(exch, opName); } if (bop != null) { exch.put(BindingOperationInfo.class, bop); if (bop.getOutput() == null) { exch.setOneWay(true); } } } }
private static void changeToOneway(org.apache.cxf.message.Exchange cxfExchange) { cxfExchange.setOneWay(true); Object httpresp = cxfExchange.getInMessage().get("HTTP.RESPONSE"); if (httpresp != null) { try { Method m = findMethod(httpresp.getClass(), "setStatus", int.class); if (m != null) { m.invoke(httpresp, 202); } } catch (Exception e) { LOG.warn("Unable to set the http ", e); } } } public static Method findMethod(Class<?> cls,
private void changeToOneway(Exchange exchange) { exchange.setOneWay(true); exchange.setOutMessage(null); javax.servlet.http.HttpServletResponse httpresp = (javax.servlet.http.HttpServletResponse)exchange.getInMessage(). get("HTTP.RESPONSE"); if (httpresp != null) { httpresp.setStatus(202); } }
private void getBindingOperationForEmptyBody(Collection<OperationInfo> operations, Endpoint ep, Exchange exchange) { // TO DO : check duplicate operation with no input and also check if the action matches for (OperationInfo op : operations) { MessageInfo bmsg = op.getInput(); List<MessagePartInfo> bparts = bmsg.getMessageParts(); if (bparts.size() == 0 || (bparts.size() == 1 && XMLSchemaQNames.XSD_ANY.equals(bparts.get(0).getTypeQName()))) { BindingOperationInfo boi = ep.getEndpointInfo().getBinding().getOperation(op); exchange.put(BindingOperationInfo.class, boi); exchange.put(OperationInfo.class, op); exchange.setOneWay(op.isOneWay()); } } }
private void getBindingOperationForEmptyBody(Collection<OperationInfo> operations, Endpoint ep, Exchange exchange) { // TO DO : check duplicate operation with no input and also check if the action matches for (OperationInfo op : operations) { MessageInfo bmsg = op.getInput(); List<MessagePartInfo> bparts = bmsg.getMessageParts(); if (bparts.size() == 0 || (bparts.size() == 1 && XMLSchemaQNames.XSD_ANY.equals(bparts.get(0).getTypeQName()))) { BindingOperationInfo boi = ep.getEndpointInfo().getBinding().getOperation(op); exchange.put(BindingOperationInfo.class, boi); exchange.put(OperationInfo.class, op); exchange.setOneWay(op.isOneWay()); } } }
private void getBindingOperationForEmptyBody(Collection<OperationInfo> operations, Endpoint ep, Exchange exchange) { // TO DO : check duplicate operation with no input and also check if the action matches for (OperationInfo op : operations) { MessageInfo bmsg = op.getInput(); int bPartsNum = bmsg.getMessagePartsNumber(); if (bPartsNum == 0 || (bPartsNum == 1 && Constants.XSD_ANYTYPE.equals(bmsg.getFirstMessagePart().getTypeQName()))) { BindingOperationInfo boi = ep.getEndpointInfo().getBinding().getOperation(op); exchange.put(BindingOperationInfo.class, boi); exchange.setOneWay(op.isOneWay()); } } }
protected void setupBindingOperationInfo(Exchange exch, Object data) { if (exch.getBindingOperationInfo() == null) { //need to know the operation to determine if oneway QName opName = getOpQName(exch, data); if (opName == null) { return; } BindingOperationInfo bop = ServiceModelUtil .getOperationForWrapperElement(exch, opName, false); if (bop == null) { bop = ServiceModelUtil.getOperation(exch, opName); } if (bop != null) { exch.put(BindingOperationInfo.class, bop); if (bop.getOutput() == null) { exch.setOneWay(true); } } } }
public void handleFault(SoapMessage message) { if (!ContextUtils.isRequestor(message)) { Exchange exchange = message.getExchange(); Message inMessage = exchange.getInMessage(); final AddressingProperties maps = ContextUtils.retrieveMAPs(inMessage, false, false, true); if (maps != null && !ContextUtils.isGenericAddress(maps.getFaultTo())) { //Just keep the wsa headers to remove the not understand headers if (exchange.getOutMessage() != null) { message = (SoapMessage)exchange.getOutMessage(); } Iterator<Header> iterator = message.getHeaders().iterator(); while (iterator.hasNext()) { Header header = iterator.next(); if (!isWSAHeader(header)) { iterator.remove(); } } exchange.setOneWay(false); exchange.setOutMessage(message); //manually set the action message.put(ContextUtils.ACTION, WSA_ACTION); Destination destination = createDecoupledDestination( exchange, maps.getFaultTo()); exchange.setDestination(destination); } } }
/** * {@inheritDoc} */ @Override public void handleMessage(SoapMessage message) throws Fault { final Header callHeader = message.getHeader( RequestCallbackFeature.CALL_ID_HEADER_NAME); if (callHeader == null) { return; } final Exchange e = message.getExchange(); if (!e.isOneWay()) { e.setOneWay(true); } final Header callbackHeader = message.getHeader( RequestCallbackFeature.CALLBACK_ID_HEADER_NAME); if (callbackHeader == null) { doHandleRequestSoapMessage(message, callHeader); } else { doHandleCallbackSoapMessage(message, callHeader, callbackHeader); } }
private void setExchangeProperties(Message message, OperationResourceInfo ori, MultivaluedMap<String, String> values, int numberOfResources) { message.getExchange().put(OperationResourceInfo.class, ori); message.put(RESOURCE_METHOD, ori.getMethodToInvoke()); message.put(URITemplate.TEMPLATE_PARAMETERS, values); String plainOperationName = ori.getMethodToInvoke().getName(); if (numberOfResources > 1) { plainOperationName = ori.getClassResourceInfo().getServiceClass().getSimpleName() + "#" + plainOperationName; } message.getExchange().put(RESOURCE_OPERATION_NAME, plainOperationName); boolean oneway = ori.isOneway() || MessageUtils.isTrue(HttpUtils.getProtocolHeader(message, Message.ONE_WAY_REQUEST, null)); message.getExchange().setOneWay(oneway); }
private void setExchangeProperties(Message message, Exchange exchange, OperationResourceInfo ori, MultivaluedMap<String, String> values, int numberOfResources) { final ClassResourceInfo cri = ori.getClassResourceInfo(); exchange.put(OperationResourceInfo.class, ori); exchange.put(JAXRSUtils.ROOT_RESOURCE_CLASS, cri); message.put(RESOURCE_METHOD, ori.getMethodToInvoke()); message.put(URITemplate.TEMPLATE_PARAMETERS, values); String plainOperationName = ori.getMethodToInvoke().getName(); if (numberOfResources > 1) { plainOperationName = cri.getServiceClass().getSimpleName() + "#" + plainOperationName; } exchange.put(RESOURCE_OPERATION_NAME, plainOperationName); if (ori.isOneway() || PropertyUtils.isTrue(HttpUtils.getProtocolHeader(message, Message.ONE_WAY_REQUEST, null))) { exchange.setOneWay(true); } ResourceProvider rp = cri.getResourceProvider(); if (rp instanceof SingletonResourceProvider) { //cri.isSingleton is not guaranteed to indicate we have a 'pure' singleton exchange.put(Message.SERVICE_OBJECT, rp.getInstance(message)); } }
public Conduit getBackChannel(Message inMessage) throws IOException { Bus bus = inMessage.getExchange().getBus(); //this is a response targeting a decoupled endpoint. Treat it as a oneway so //we don't wait for a response. inMessage.getExchange().setOneWay(true); ConduitInitiator conduitInitiator = bus.getExtension(ConduitInitiatorManager.class) .getConduitInitiatorForUri(reference.getAddress().getValue()); if (conduitInitiator != null) { Conduit c = conduitInitiator.getConduit(ei, reference, bus); //ensure decoupled back channel input stream is closed c.setMessageObserver(new MessageObserver() { public void onMessage(Message m) { InputStream is = m.getContent(InputStream.class); if (is != null) { try { is.close(); } catch (Exception e) { //ignore } } } }); return c; } return null; } public MessageObserver getMessageObserver() {
public Conduit getBackChannel(Message inMessage, Message partialResponse, EndpointReferenceType address) throws IOException { Bus bus = inMessage.getExchange().get(Bus.class); //this is a response targeting a decoupled endpoint. Treat it as a oneway so //we don't wait for a response. inMessage.getExchange().setOneWay(true); ConduitInitiator conduitInitiator = bus.getExtension(ConduitInitiatorManager.class) .getConduitInitiatorForUri(reference.getAddress().getValue()); if (conduitInitiator != null) { Conduit c = conduitInitiator.getConduit(ei, reference); //ensure decoupled back channel input stream is closed c.setMessageObserver(new MessageObserver() { public void onMessage(Message m) { InputStream is = m.getContent(InputStream.class); if (is != null) { try { is.close(); } catch (Exception e) { //ignore } } } }); return c; } return null; } public MessageObserver getMessageObserver() {
public Conduit getBackChannel(Message inMessage) throws IOException { Bus bus = inMessage.getExchange().getBus(); //this is a response targeting a decoupled endpoint. Treat it as a oneway so //we don't wait for a response. inMessage.getExchange().setOneWay(true); ConduitInitiator conduitInitiator = bus.getExtension(ConduitInitiatorManager.class) .getConduitInitiatorForUri(reference.getAddress().getValue()); if (conduitInitiator != null) { Conduit c = conduitInitiator.getConduit(ei, reference, bus); //ensure decoupled back channel input stream is closed c.setMessageObserver(new MessageObserver() { public void onMessage(Message m) { InputStream is = m.getContent(InputStream.class); if (is != null) { try { is.close(); } catch (Exception e) { //ignore } } } }); return c; } return null; } public MessageObserver getMessageObserver() {
private void wrapExceptionAsFault(Message message, RuntimeException ex) { String description = getServiceInfo(message); message.setContent(Exception.class, ex); unwind(message); Exception ex2 = message.getContent(Exception.class); if (ex2 == null) { ex2 = ex; } FaultListener flogger = (FaultListener) message.getContextualProperty(FaultListener.class.getName()); boolean useDefaultLogging = true; if (flogger != null) { useDefaultLogging = flogger.faultOccurred(ex2, description, message); } if (useDefaultLogging) { doDefaultLogging(message, ex2, description); } if (message.getExchange() != null && message.getContent(Exception.class) != null) { message.getExchange().put(Exception.class, ex2); } if (faultObserver != null && !isOneWay(message)) { // CXF-5629. when exchange is one way and robust, it becomes req-resp in order to // send the fault message.getExchange().setOneWay(false); faultObserver.onMessage(message); } }
public void invoke(ServerRequest request) throws CorbaBindingException { String opName = request.operation(); QName requestOperation = operationMap.get(opName); MessageImpl msgImpl = new MessageImpl(); msgImpl.setDestination(getDestination()); Exchange exg = new ExchangeImpl(); exg.put(String.class, requestOperation.getLocalPart()); exg.put(ORB.class, getOrb()); exg.put(ServerRequest.class, request); msgImpl.setExchange(exg); CorbaMessage msg = new CorbaMessage(msgImpl); msg.setCorbaTypeMap(typeMap); // If there's no output message part in our operation then it's a oneway op BindingMessageInfo bindingMsgOutputInfo = null; BindingOperationInfo bindingOpInfo = null; try { bindingOpInfo = this.destination.getEndPointInfo().getBinding().getOperation(requestOperation); } catch (Exception ex) { throw new CorbaBindingException("Invalid Request. Operation unknown: " + opName); } if (bindingOpInfo != null) { bindingMsgOutputInfo = bindingOpInfo.getOutput(); if (bindingMsgOutputInfo == null) { exg.setOneWay(true); } } // invokes the interceptors getObserver().onMessage(msg); }
&& !PropertyUtils.isTrue(message.get(RMMessageConstants.DELIVERING_ROBUST_ONEWAY))) { Exchange exchange = message.getExchange(); exchange.setOneWay(false);
public void handleMessage(JBIMessage message) throws Fault { Exchange ex = message.getExchange(); Endpoint ep = ex.get(Endpoint.class); BindingOperationInfo boi = ex.get(BindingOperationInfo.class); if (boi == null) { if (message.getJbiExchange().getOperation() != null) { BindingInfo service = ep.getEndpointInfo().getBinding(); boi = getBindingOperationInfo(service, message.getJbiExchange().getOperation()); if (boi == null) { throw new Fault(new Message("UNKNOWN_OPERATION", BUNDLE, message.getJbiExchange().getOperation().toString())); } } else { throw new Fault(new Message("UNKNOWN_OPERATION", BUNDLE, message.getJbiExchange().getInterfaceName().toString())); } ex.put(BindingOperationInfo.class, boi); ex.put(OperationInfo.class, boi.getOperationInfo()); ex.setOneWay(boi.getOperationInfo().isOneWay()); message.put(MessageInfo.class, boi.getInput().getMessageInfo()); } }
public void handleMessage(NMRMessage message) throws Fault { Exchange ex = message.getExchange(); Endpoint ep = ex.get(Endpoint.class); BindingOperationInfo boi = ex.get(BindingOperationInfo.class); if (boi == null && message.getNmrExchange()!= null && message.getNmrExchange().getOperation() != null) { BindingInfo service = ep.getEndpointInfo().getBinding(); boi = getBindingOperationInfo(service, message.getNmrExchange().getOperation()); if (boi == null) { throw new Fault(new Message("UNKNOWN_OPERATION", BUNDLE, message.getNmrExchange().getOperation().toString())); } ex.put(BindingOperationInfo.class, boi); ex.put(OperationInfo.class, boi.getOperationInfo()); ex.setOneWay(boi.getOperationInfo().isOneWay()); message.put(MessageInfo.class, boi.getInput().getMessageInfo()); } }