Examples of MessageContext

  • org.springframework.binding.message.MessageContext
    A context for recording and retrieving messages for display.
  • org.springframework.ws.context.MessageContext
    Context holder for message requests.

    Contains both the message request as well as the response. Response message are usually lazily created (but do not have to be).

    Also contains properties, which can be used to by {@link EndpointInterceptor interceptors} to pass information on toendpoints. @author Arjen Poutsma @since 1.0.0

  • xsul.message_router.MessageContext

  • Examples of org.apache.axis2.context.MessageContext

                    // NhttpConstants.SC_ACCEPTED set to Boolean.TRUE to indicate this is a
                    // placeholder message for the transport to send a HTTP 202 to the
                    // client. Should / would be ignored by any transport other than
                    // nhttp. For example, JMS would not send a reply message for one-way
                    // operations.
                    MessageContext outMsgCtx =
                            (MessageContext) context.getAttribute(OUTGOING_MESSAGE_CONTEXT);
                    MessageReceiver mr = outMsgCtx.getAxisOperation().getMessageReceiver();

                    // the following check is to support the dual channel invocation. Hence the
                    // response will be sent as a new request to the client over a different channel
                    // client sends back a 202 Accepted response to synapse and we need to neglect that
                    // 202 Accepted message
                    if (!outMsgCtx.isPropertyTrue(NhttpConstants.IGNORE_SC_ACCEPTED)) {

                        try {
                            MessageContext responseMsgCtx = outMsgCtx.getOperationContext().
                                    getMessageContext(WSDL2Constants.MESSAGE_LABEL_IN);
                            if (responseMsgCtx == null ||
                                    outMsgCtx.getOptions().isUseSeparateListener()) {
                                // Since we need to notify the SynapseCallback receiver to remove the
                                // call backs registered  we set a custom property
                                if (outMsgCtx.getOperationContext().isComplete()) {
                                    setHeaders(context, response, outMsgCtx, responseMsgCtx);
                                    outMsgCtx.setProperty(NhttpConstants.HTTP_202_RECEIVED, "true");
                                    mr.receive(outMsgCtx);
                                }
                                return;
                            }
                            setHeaders(context, response, outMsgCtx, responseMsgCtx);
                            responseMsgCtx.setServerSide(true);
                            responseMsgCtx.setDoingREST(outMsgCtx.isDoingREST());
                            responseMsgCtx.setProperty(MessageContext.TRANSPORT_IN,
                                    outMsgCtx.getProperty(MessageContext.TRANSPORT_IN));
                            responseMsgCtx.setTransportIn(outMsgCtx.getTransportIn());
                            responseMsgCtx.setTransportOut(outMsgCtx.getTransportOut());

                            responseMsgCtx.setAxisMessage(outMsgCtx.getAxisOperation().
                                    getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE));
                            responseMsgCtx.setOperationContext(outMsgCtx.getOperationContext());
                            responseMsgCtx.setConfigurationContext(outMsgCtx.getConfigurationContext());
                            responseMsgCtx.setTo(null);

                            if (!outMsgCtx.isDoingREST() && !outMsgCtx.isSOAP11()) {
                                responseMsgCtx.setEnvelope(OMAbstractFactory.getSOAP12Factory().getDefaultEnvelope());
                            } else {
                                responseMsgCtx.setEnvelope(OMAbstractFactory.getSOAP11Factory().getDefaultEnvelope());
                            }
                            responseMsgCtx.setProperty(AddressingConstants.
                                    DISABLE_ADDRESSING_FOR_OUT_MESSAGES, Boolean.TRUE);
                            responseMsgCtx.setProperty(NhttpConstants.SC_ACCEPTED, Boolean.TRUE);
                            mr.receive(responseMsgCtx);

                        } catch (org.apache.axis2.AxisFault af) {
                            log.debug("Unable to report back " +
                                    "202 Accepted state to the message receiver");
    View Full Code Here

    Examples of org.apache.axis2.context.MessageContext

         */
        private void processResponse(final NHttpClientConnection conn, HttpContext context,
            HttpResponse response) {

            ContentInputBuffer inputBuffer = null;
            MessageContext outMsgContext = (MessageContext) context.getAttribute(OUTGOING_MESSAGE_CONTEXT);
            String endptPrefix = (String) context.getAttribute(NhttpConstants.ENDPOINT_PREFIX);
            String requestMethod = (String) context.getAttribute(NhttpConstants.HTTP_REQ_METHOD);
            int statusCode = response.getStatusLine().getStatusCode();

            boolean expectEntityBody = false;
    View Full Code Here

    Examples of org.apache.axis2.context.MessageContext

            }
            return null;
        }

        private void setServerContextAttribute(String key, Object value, NHttpClientConnection conn) {
            MessageContext msgCtx = getMessageContext(conn);
            if (msgCtx != null) {
                Object outTransport = msgCtx.getProperty(Constants.OUT_TRANSPORT_INFO);
                if (outTransport != null && outTransport instanceof ServerWorker) {
                    HttpContext context = ((ServerWorker) outTransport).getConn().getContext();
                    context.setAttribute(key, value);
                }
            }
    View Full Code Here

    Examples of org.apache.axis2.context.MessageContext

         * @param request the http request to be used to create the corresponding Axis2 message context
         * @return the Axis2 message context created
         */
        private MessageContext createMessageContext(HttpRequest request) {

            MessageContext msgContext = new MessageContext();
            msgContext.setMessageID(UIDGenerator.generateURNString());

            // There is a discrepency in what I thought, Axis2 spawns a new threads to
            // send a message if this is TRUE - and I want it to be the other way
            msgContext.setProperty(MessageContext.CLIENT_API_NON_BLOCKING, Boolean.FALSE);
            msgContext.setConfigurationContext(cfgCtx);
            if (isHttps) {
                msgContext.setTransportOut(cfgCtx.getAxisConfiguration()
                    .getTransportOut(Constants.TRANSPORT_HTTPS));
                msgContext.setTransportIn(cfgCtx.getAxisConfiguration()
                    .getTransportIn(Constants.TRANSPORT_HTTPS));
                msgContext.setIncomingTransportName(Constants.TRANSPORT_HTTPS);
            } else {
                msgContext.setTransportOut(cfgCtx.getAxisConfiguration()
                    .getTransportOut(Constants.TRANSPORT_HTTP));
                msgContext.setTransportIn(cfgCtx.getAxisConfiguration()
                    .getTransportIn(Constants.TRANSPORT_HTTP));
                msgContext.setIncomingTransportName(Constants.TRANSPORT_HTTP);
            }
            msgContext.setProperty(Constants.OUT_TRANSPORT_INFO, this);
            // the following statement causes the soap session services to be failing - ruwan       
            // msgContext.setServiceGroupContextId(UUIDGenerator.getUUID());
            msgContext.setServerSide(true);
            msgContext.setProperty(
                Constants.Configuration.TRANSPORT_IN_URL, request.getRequestLine().getUri());

            // http transport header names are case insensitive
            Map<String, String> headers = new TreeMap<String, String>(new Comparator<String>() {
                public int compare(String o1, String o2) {
                    return o1.compareToIgnoreCase(o2);
                }
            });
           
            for (Header header : request.getAllHeaders()) {
                headers.put(header.getName(), header.getValue());
            }
            msgContext.setProperty(MessageContext.TRANSPORT_HEADERS, headers);

            // find the remote party IP address and set it to the message context
            if (conn instanceof HttpInetConnection) {
                HttpInetConnection inetConn = (HttpInetConnection) conn;
                InetAddress remoteAddr = inetConn.getRemoteAddress();
                if (remoteAddr != null) {
                    msgContext.setProperty(
                            MessageContext.REMOTE_ADDR, remoteAddr.getHostAddress());
                    msgContext.setProperty(
                            NhttpConstants.REMOTE_HOST, NhttpUtil.getHostName(remoteAddr));
                    remoteAddress = remoteAddr.getHostAddress();
                }
            }

            msgContext.setProperty(RequestResponseTransport.TRANSPORT_CONTROL,
                    new HttpCoreRequestResponseTransport(msgContext));

            msgContext.setProperty(ServerHandler.SERVER_CONNECTION_DEBUG,
                conn.getContext().getAttribute(ServerHandler.SERVER_CONNECTION_DEBUG));

            msgContext.setProperty(NhttpConstants.NHTTP_INPUT_STREAM, is);
            msgContext.setProperty(NhttpConstants.NHTTP_OUTPUT_STREAM, os);

            return msgContext;
        }
    View Full Code Here

    Examples of org.apache.axis2.context.MessageContext

            if (e == null) {
                newException = new Exception(msg);
            }

            try {
                MessageContext faultContext = MessageContextBuilder.createFaultMessageContext(
                        msgContext, newException);
                AxisEngine.sendFault(faultContext);

            } catch (Exception ex) {
                response.setStatusCode(HttpStatus.SC_INTERNAL_SERVER_ERROR);
    View Full Code Here

    Examples of org.apache.axis2.context.MessageContext

                        "] [encoding=" + endpoint.getCharSetEncoding() : "") +
                    "] [to=" + to + "]");
            }

            // save the original message context wihout altering it, so we can tie the response
            MessageContext originalInMsgCtx
                = ((Axis2MessageContext) synapseOutMessageContext).getAxis2MessageContext();

            // create a new MessageContext to be sent out as this should not corrupt the original
            // we need to create the response to the original message later on
            String preserveAddressingProperty = (String) synapseOutMessageContext.getProperty(
                    SynapseConstants.PRESERVE_WS_ADDRESSING);
            MessageContext axisOutMsgCtx = cloneForSend(originalInMsgCtx, preserveAddressingProperty);


            if (log.isDebugEnabled()) {
                log.debug("Message [Original Request Message ID : "
                        + synapseOutMessageContext.getMessageID() + "]"
                        + " [New Cloned Request Message ID : " + axisOutMsgCtx.getMessageID() + "]");
            }
            // set all the details of the endpoint only to the cloned message context
            // so that we can use the original message context for resending through different endpoints
            if (endpoint != null) {

                if (SynapseConstants.FORMAT_POX.equals(endpoint.getFormat())) {
                    axisOutMsgCtx.setDoingREST(true);
                    axisOutMsgCtx.setProperty(org.apache.axis2.Constants.Configuration.MESSAGE_TYPE,
                            org.apache.axis2.transport.http.HTTPConstants.MEDIA_TYPE_APPLICATION_XML);

                } else if (SynapseConstants.FORMAT_GET.equals(endpoint.getFormat())) {
                    axisOutMsgCtx.setDoingREST(true);
                    axisOutMsgCtx.setProperty(Constants.Configuration.HTTP_METHOD,
                        Constants.Configuration.HTTP_METHOD_GET);
                    axisOutMsgCtx.setProperty(org.apache.axis2.Constants.Configuration.MESSAGE_TYPE,
                            org.apache.axis2.transport.http.HTTPConstants.MEDIA_TYPE_X_WWW_FORM);
                   
                } else if (SynapseConstants.FORMAT_SOAP11.equals(endpoint.getFormat())) {
                    axisOutMsgCtx.setDoingREST(false);
                    axisOutMsgCtx.removeProperty(org.apache.axis2.Constants.Configuration.MESSAGE_TYPE);
                    // We need to set this ezplicitly here in case the requset was not a POST
                    axisOutMsgCtx.setProperty(Constants.Configuration.HTTP_METHOD,
                        Constants.Configuration.HTTP_METHOD_POST);
                    if (axisOutMsgCtx.getSoapAction() == null && axisOutMsgCtx.getWSAAction() != null) {
                        axisOutMsgCtx.setSoapAction(axisOutMsgCtx.getWSAAction());
                    }
                    if(!axisOutMsgCtx.isSOAP11()) {
                        SOAPUtils.convertSOAP12toSOAP11(axisOutMsgCtx);
                    }
                   
                } else if (SynapseConstants.FORMAT_SOAP12.equals(endpoint.getFormat())) {
                    axisOutMsgCtx.setDoingREST(false);
                    axisOutMsgCtx.removeProperty(org.apache.axis2.Constants.Configuration.MESSAGE_TYPE);
                    // We need to set this ezplicitly here in case the requset was not a POST
                    axisOutMsgCtx.setProperty(Constants.Configuration.HTTP_METHOD,
                        Constants.Configuration.HTTP_METHOD_POST);
                    if (axisOutMsgCtx.getSoapAction() == null && axisOutMsgCtx.getWSAAction() != null) {
                        axisOutMsgCtx.setSoapAction(axisOutMsgCtx.getWSAAction());
                    }
                    if(axisOutMsgCtx.isSOAP11()) {
                        SOAPUtils.convertSOAP11toSOAP12(axisOutMsgCtx);
                    }               

                } else if (SynapseConstants.FORMAT_REST.equals(endpoint.getFormat())) {
                    axisOutMsgCtx.removeProperty(org.apache.axis2.Constants.Configuration.MESSAGE_TYPE);
                    axisOutMsgCtx.setDoingREST(true);
                } else {
                    processWSDL2RESTRequestMessageType(originalInMsgCtx, axisOutMsgCtx);
                }

                if (endpoint.isUseMTOM()) {
                    axisOutMsgCtx.setDoingMTOM(true);
                    // fix / workaround for AXIS2-1798
                    axisOutMsgCtx.setProperty(
                            org.apache.axis2.Constants.Configuration.ENABLE_MTOM,
                            org.apache.axis2.Constants.VALUE_TRUE);
                    axisOutMsgCtx.setDoingMTOM(true);

                } else if (endpoint.isUseSwa()) {
                    axisOutMsgCtx.setDoingSwA(true);
                    // fix / workaround for AXIS2-1798
                    axisOutMsgCtx.setProperty(
                            org.apache.axis2.Constants.Configuration.ENABLE_SWA,
                            org.apache.axis2.Constants.VALUE_TRUE);
                    axisOutMsgCtx.setDoingSwA(true);
                }

                if (endpoint.getCharSetEncoding() != null) {
                    axisOutMsgCtx.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING,
                            endpoint.getCharSetEncoding());
                }

                // add rest request' suffix URI
                Object restSuffix =
                        axisOutMsgCtx.getProperty(NhttpConstants.REST_URL_POSTFIX);
                boolean isRest = SynapseConstants.FORMAT_REST.equals(endpoint.getFormat());

                if (!isRest) {
                    isRest = isRequestRest(originalInMsgCtx);
                }

                if (endpoint.getAddress() != null) {
                    if (isRest && restSuffix != null && !"".equals(restSuffix)) {
                        axisOutMsgCtx.setTo(
                                new EndpointReference(
                                        endpoint.getAddress(synapseOutMessageContext) + restSuffix));

                    } else {
                        axisOutMsgCtx.setTo(
                                new EndpointReference(endpoint.getAddress(synapseOutMessageContext)));
                    }

                    axisOutMsgCtx.setProperty(NhttpConstants.ENDPOINT_PREFIX,
                            endpoint.getAddress(synapseOutMessageContext));
                } else {
                    // Supporting RESTful invocation
                    if (isRest && restSuffix != null && !"".equals(restSuffix)) {
                        EndpointReference epr = axisOutMsgCtx.getTo();
                        if (epr != null) {
                            axisOutMsgCtx.setTo(new EndpointReference(epr.getAddress() + restSuffix));
                        }
                    }
                }
                
                if (endpoint.isUseSeparateListener()) {
                    axisOutMsgCtx.getOptions().setUseSeparateListener(true);
                }
            } else {
                processWSDL2RESTRequestMessageType(originalInMsgCtx, axisOutMsgCtx);
            }

            // only put whttp:location for the REST (GET) requests, otherwise causes issues for POX messages
            if (axisOutMsgCtx.isDoingREST() && HTTPConstants.MEDIA_TYPE_X_WWW_FORM.equals(
                    axisOutMsgCtx.getProperty(Constants.Configuration.MESSAGE_TYPE))) {
                if (axisOutMsgCtx.getProperty(WSDL2Constants.ATTR_WHTTP_LOCATION) == null
                        && axisOutMsgCtx.getEnvelope().getBody().getFirstElement() != null) {
                    axisOutMsgCtx.setProperty(WSDL2Constants.ATTR_WHTTP_LOCATION,
                            axisOutMsgCtx.getEnvelope().getBody().getFirstElement()
                                    .getQName().getLocalPart());
                }
            }

            if (wsAddressingEnabled) {

                if (wsAddressingVersion != null &&
                        SynapseConstants.ADDRESSING_VERSION_SUBMISSION.equals(wsAddressingVersion)) {

                    axisOutMsgCtx.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
                            AddressingConstants.Submission.WSA_NAMESPACE);

                } else if (wsAddressingVersion != null &&
                        SynapseConstants.ADDRESSING_VERSION_FINAL.equals(wsAddressingVersion)) {

                    axisOutMsgCtx.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
                            AddressingConstants.Final.WSA_NAMESPACE);
                }
               
                axisOutMsgCtx.setProperty
                        (AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES, Boolean.FALSE);
            } else {
                axisOutMsgCtx.setProperty
                        (AddressingConstants.DISABLE_ADDRESSING_FOR_OUT_MESSAGES, Boolean.TRUE);
            }

            // remove the headers if we don't need to preserve them.
            // determine weather we need to preserve the processed headers
            String preserveHeaderProperty =
                    (String) synapseOutMessageContext.getProperty(
                           SynapseConstants.PRESERVE_PROCESSED_HEADERS);
            if (preserveHeaderProperty == null || !Boolean.parseBoolean(preserveHeaderProperty)) {
                // default behaviour is to remove the headers
                MessageHelper.removeProcessedHeaders(axisOutMsgCtx,
                        (preserveAddressingProperty != null &&
                                Boolean.parseBoolean(preserveAddressingProperty)));
            }


            ConfigurationContext axisCfgCtx = axisOutMsgCtx.getConfigurationContext();
            AxisConfiguration axisCfg       = axisCfgCtx.getAxisConfiguration();

            AxisService anoymousService =
                AnonymousServiceFactory.getAnonymousService(synapseOutMessageContext.getConfiguration(),
                axisCfg, wsAddressingEnabled, wsRMEnabled, wsSecurityEnabled);
            // mark the anon services created to be used in the client side of synapse as hidden
            // from the server side of synapse point of view
            anoymousService.getParent().addParameter(SynapseConstants.HIDDEN_SERVICE_PARAM, "true");
            ServiceGroupContext sgc = new ServiceGroupContext(
                axisCfgCtx, (AxisServiceGroup) anoymousService.getParent());
            ServiceContext serviceCtx = sgc.getServiceContext(anoymousService);

            boolean outOnlyMessage = "true".equals(synapseOutMessageContext.getProperty(
                    SynapseConstants.OUT_ONLY)) || WSDL2Constants.MEP_URI_IN_ONLY.equals(
                    originalInMsgCtx.getOperationContext()
                            .getAxisOperation().getMessageExchangePattern());

            // get a reference to the DYNAMIC operation of the Anonymous Axis2 service
            AxisOperation axisAnonymousOperation = anoymousService.getOperation(
                outOnlyMessage ?
                    new QName(AnonymousServiceFactory.OUT_ONLY_OPERATION) :
                    new QName(AnonymousServiceFactory.OUT_IN_OPERATION));

            Options clientOptions = MessageHelper.cloneOptions(originalInMsgCtx.getOptions());
            clientOptions.setUseSeparateListener(separateListener);
            // if RM is requested,
            if (wsRMEnabled) {
                // if a WS-RM policy is specified, use it
                if (wsRMPolicyKey != null) {
                    Object property = synapseOutMessageContext.getEntry(wsRMPolicyKey);
                    if (property instanceof OMElement) {
                        OMElement policyOMElement = (OMElement) property;
                        RMAssertionBuilder builder = new RMAssertionBuilder();
                        SandeshaPolicyBean sandeshaPolicyBean = (SandeshaPolicyBean) builder.build(policyOMElement, null);
                        Parameter policyParam = new Parameter(Sandesha2Constants.SANDESHA_PROPERTY_BEAN, sandeshaPolicyBean);
                        anoymousService.addParameter(policyParam);
                    }
                }
            }

            // if security is enabled,
            if (wsSecurityEnabled) {
                // if a WS-Sec policy is specified, use it
                if (wsSecPolicyKey != null) {
                    clientOptions.setProperty(
                        SynapseConstants.RAMPART_POLICY,
                            MessageHelper.getPolicy(synapseOutMessageContext, wsSecPolicyKey));
                } else {
                    if (inboundWsSecPolicyKey != null) {
                        clientOptions.setProperty(SynapseConstants.RAMPART_IN_POLICY,
                                MessageHelper.getPolicy(
                                        synapseOutMessageContext, inboundWsSecPolicyKey));
                    }
                    if (outboundWsSecPolicyKey != null) {
                        clientOptions.setProperty(SynapseConstants.RAMPART_OUT_POLICY,
                                MessageHelper.getPolicy(
                                        synapseOutMessageContext, outboundWsSecPolicyKey));
                    }
                }
                // temporary workaround for https://issues.apache.org/jira/browse/WSCOMMONS-197
                if (axisOutMsgCtx.getEnvelope().getHeader() == null) {
                    SOAPFactory fac = axisOutMsgCtx.isSOAP11() ?
                            OMAbstractFactory.getSOAP11Factory() : OMAbstractFactory.getSOAP12Factory();
                    fac.createSOAPHeader(axisOutMsgCtx.getEnvelope());
                }
            }

            OperationClient mepClient = axisAnonymousOperation.createClient(serviceCtx, clientOptions);
            mepClient.addMessageContext(axisOutMsgCtx);
            axisOutMsgCtx.setAxisMessage(
                axisAnonymousOperation.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE));

            // set the SEND_TIMEOUT for transport sender
            if (endpoint != null && endpoint.getTimeoutDuration() > 0) {
                axisOutMsgCtx.setProperty(SynapseConstants.SEND_TIMEOUT, endpoint.getTimeoutDuration());
            }

            if (!outOnlyMessage) {
                // always set a callback as we decide if the send it blocking or non blocking within
                // the MEP client. This does not cause an overhead, as we simply create a 'holder'
                // object with a reference to the outgoing synapse message context
                // synapseOutMessageContext
                AsyncCallback callback = new AsyncCallback(synapseOutMessageContext);
                if (endpoint != null) {
                    // set the timeout time and the timeout action to the callback, so that the
                    // TimeoutHandler can detect timed out callbacks and take approprite action.
                    callback.setTimeOutOn(System.currentTimeMillis() + endpoint.getTimeoutDuration());
                    callback.setTimeOutAction(endpoint.getTimeoutAction());
                } else {
                    callback.setTimeOutOn(System.currentTimeMillis());
                }
                mepClient.setCallback(callback);
            }

            // this is a temporary fix for converting messages from HTTP 1.1 chunking to HTTP 1.0.
            // Without this HTTP transport can block & become unresponsive because we are streaming
            // HTTP 1.1 messages and HTTP 1.0 require the whole message to caculate the content length
            if (originalInMsgCtx.isPropertyTrue(NhttpConstants.FORCE_HTTP_1_0)) {
                synapseOutMessageContext.getEnvelope().toString();
            }

            // with the nio transport, this causes the listener not to write a 202
            // Accepted response, as this implies that Synapse does not yet know if
            // a 202 or 200 response would be written back.
            originalInMsgCtx.getOperationContext().setProperty(
                org.apache.axis2.Constants.RESPONSE_WRITTEN, "SKIP");

            // if the transport out is explicitly set use it
            Object o = originalInMsgCtx.getProperty("TRANSPORT_OUT_DESCRIPTION");
            if (o != null && o instanceof TransportOutDescription) {
                axisOutMsgCtx.setTransportOut((TransportOutDescription) o);
                clientOptions.setTransportOut((TransportOutDescription) o);
                clientOptions.setProperty("TRANSPORT_OUT_DESCRIPTION", o);
            }

            mepClient.execute(true);
            if (wsRMEnabled) {
                Object rm11 = clientOptions.getProperty(SandeshaClientConstants.RM_SPEC_VERSION);
                if ( (rm11 != null) && rm11.equals(Sandesha2Constants.SPEC_VERSIONS.v1_1)){
                    ServiceClient serviceClient = new ServiceClient(
                            axisOutMsgCtx.getConfigurationContext(), axisOutMsgCtx.getAxisService());
                    serviceClient.setTargetEPR(
                            new EndpointReference(endpoint.getAddress(synapseOutMessageContext)));
                    serviceClient.setOptions(clientOptions);
                    serviceClient.getOptions().setTo(
                            new EndpointReference(endpoint.getAddress(synapseOutMessageContext)));
    View Full Code Here

    Examples of org.apache.axis2.context.MessageContext

       }

        private static MessageContext cloneForSend(MessageContext ori, String preserveAddressing)
                throws AxisFault {

            MessageContext newMC = MessageHelper.clonePartially(ori);

            newMC.setEnvelope(ori.getEnvelope());
            if (preserveAddressing != null && Boolean.parseBoolean(preserveAddressing)) {
                newMC.setMessageID(ori.getMessageID());
            } else {
                MessageHelper.removeAddressingHeaders(newMC);
            }

            newMC.setProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS,
                ori.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS));

            return newMC;
        }
    View Full Code Here

    Examples of org.apache.axis2.context.MessageContext

                if (completed) {
            throw new AxisFault(Messages.getMessage("mepiscomplted"));
          }

                // if the OUT message is not set on the operation context, throw a fault
                MessageContext outMsgCtx = oc.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
          if (outMsgCtx == null) {
            throw new AxisFault(Messages.getMessage("outmsgctxnull"));
          }

                ConfigurationContext cfgCtx = sc.getConfigurationContext();

                // set ClientOptions to the current outgoing message
                outMsgCtx.setOptions(options);

          // do Target Resolution
          TargetResolver tr = cfgCtx.getAxisConfiguration().getTargetResolverChain();
                if (tr != null) {
                    tr.resolveTarget(outMsgCtx);
                }

                // if the transport to use for sending is not specified, try to find it from the URL
          TransportOutDescription transportOut = options.getTransportOut();
          if (transportOut == null) {
            EndpointReference toEPR =
                        (options.getTo() != null) ? options.getTo() : outMsgCtx.getTo();
            transportOut =
                        ClientUtils.inferOutTransport(cfgCtx.getAxisConfiguration(), toEPR, outMsgCtx);
          }
          outMsgCtx.setTransportOut(transportOut);

          if (options.getTransportIn() == null && outMsgCtx.getTransportIn() == null) {
            outMsgCtx.setTransportIn(ClientUtils.inferInTransport(
                            cfgCtx.getAxisConfiguration(), options, outMsgCtx));
          } else if (outMsgCtx.getTransportIn() == null) {
            outMsgCtx.setTransportIn(options.getTransportIn());
          }

                // add reference parameters to To EPR
                addReferenceParameters(outMsgCtx);

                if (options.isUseSeparateListener()) {

            options.setTransportIn(outMsgCtx.getConfigurationContext()
                .getAxisConfiguration().getTransportIn(Constants.TRANSPORT_HTTP));

            SynapseCallbackReceiver callbackReceiver =
                            (SynapseCallbackReceiver) axisOp.getMessageReceiver();
                   
                    ((Axis2MessageContext)((AsyncCallback)
                            axisCallback).getSynapseOutMsgCtx()).getAxis2MessageContext().setProperty(
                            NhttpConstants.IGNORE_SC_ACCEPTED, Constants.VALUE_TRUE);
                    callbackReceiver.addCallback(outMsgCtx.getMessageID(), axisCallback);
                   
                    EndpointReference replyToFromTransport = outMsgCtx.getConfigurationContext()
                            .getListenerManager().getEPRforService(sc.getAxisService().getName(),
                            axisOp.getName().getLocalPart(), outMsgCtx.getTransportOut().getName());

            if (outMsgCtx.getReplyTo() == null) {
              outMsgCtx.setReplyTo(replyToFromTransport);
            } else {
              outMsgCtx.getReplyTo().setAddress(replyToFromTransport.getAddress());
            }

            outMsgCtx.getConfigurationContext().registerOperationContext(
                outMsgCtx.getMessageID(), oc);

                    AxisEngine.send(outMsgCtx);

            // Options object reused so soapAction needs to be removed so
            // that soapAction+wsa:Action on response don't conflict
            options.setAction("");

          } else {

                    SynapseCallbackReceiver callbackReceiver =
                        (SynapseCallbackReceiver) axisOp.getMessageReceiver();
                    callbackReceiver.addCallback(outMsgCtx.getMessageID(), axisCallback);
                    send(outMsgCtx);
          }
        }
    View Full Code Here

    Examples of org.apache.axis2.context.MessageContext

        private void send(MessageContext msgctx) throws AxisFault {

          // create the responseMessageContext and set that its related to the current outgoing
                // message, so that it could be tied back to the original request even if the response
                // envelope does not contain addressing headers
                MessageContext responseMessageContext = new MessageContext();
                responseMessageContext.setMessageID(msgctx.getMessageID());
                responseMessageContext.setProperty(
                        SynapseConstants.RELATES_TO_FOR_POX, msgctx.getMessageID());
                responseMessageContext.setOptions(options);
                responseMessageContext.setServerSide(true);
          addMessageContext(responseMessageContext);

                AxisEngine.send(msgctx);

                // did the engine receive a immediate synchronous response?
                // e.g. sometimes the transport sender may listen for a syncronous reply
          if (msgctx.getProperty(MessageContext.TRANSPORT_IN) != null) {

                    responseMessageContext.setOperationContext(msgctx.getOperationContext());               
                    responseMessageContext.setAxisMessage(
                        msgctx.getOperationContext().getAxisOperation().
                        getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE));
                    responseMessageContext.setAxisService(msgctx.getAxisService());

                    responseMessageContext.setProperty(MessageContext.TRANSPORT_OUT,
                        msgctx.getProperty(MessageContext.TRANSPORT_OUT));
                    responseMessageContext.setProperty(org.apache.axis2.Constants.OUT_TRANSPORT_INFO,
                        msgctx.getProperty(org.apache.axis2.Constants.OUT_TRANSPORT_INFO));

                    responseMessageContext.setProperty(
                        org.apache.synapse.SynapseConstants.ISRESPONSE_PROPERTY, Boolean.TRUE);
                    responseMessageContext.setTransportIn(msgctx.getTransportIn());
                    responseMessageContext.setTransportOut(msgctx.getTransportOut());

                    // If request is REST assume that the responseMessageContext is REST too
                    responseMessageContext.setDoingREST(msgctx.isDoingREST());

                    responseMessageContext.setProperty(MessageContext.TRANSPORT_IN,
                        msgctx.getProperty(MessageContext.TRANSPORT_IN));
                    responseMessageContext.setTransportIn(msgctx.getTransportIn());
                    responseMessageContext.setTransportOut(msgctx.getTransportOut());

                    // Options object reused above so soapAction needs to be removed so
                    // that soapAction+wsa:Action on response don't conflict
                    responseMessageContext.setSoapAction("");

                    if (responseMessageContext.getEnvelope() == null) {
                        // If request is REST we assume the responseMessageContext is
                        // REST, so set the variable

                        SOAPEnvelope resenvelope =
                            TransportUtils.createSOAPMessage(responseMessageContext);

                        if (resenvelope != null) {
                            responseMessageContext.setEnvelope(resenvelope);
                            AxisEngine.receive(responseMessageContext);
                            if (responseMessageContext.getReplyTo() != null) {
                                sc.setTargetEPR(responseMessageContext.getReplyTo());
                            }

                            complete(msgctx);
                        } else {
                            throw new AxisFault(
    View Full Code Here

    Examples of org.apache.axis2.context.MessageContext

            msgContext.setProperty(HTTPConstants.MC_HTTP_STATUS_CODE, new Integer(method.getStatusCode()));
            Header header = method.getResponseHeader(HTTPConstants.HEADER_CONTENT_TYPE);

            if (header != null) {
                HeaderElement[] headers = header.getElements();
                MessageContext inMessageContext = msgContext.getOperationContext().getMessageContext(
                        WSDLConstants.MESSAGE_LABEL_IN_VALUE);

                Object contentType = header.getValue();
                Object charSetEnc = null;

                for (int i = 0; i < headers.length; i++) {
                    NameValuePair charsetEnc = headers[i].getParameterByName(
                            HTTPConstants.CHAR_SET_ENCODING);
                    if (charsetEnc != null) {
                        charSetEnc = charsetEnc.getValue();
                    }
                }

                if (inMessageContext != null) {
                    inMessageContext
                            .setProperty(Constants.Configuration.CONTENT_TYPE, contentType);
                    inMessageContext
                            .setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEnc);
                } else {

                    // Transport details will be stored in a HashMap so that anybody interested can
                    // retrieve them
    View Full Code Here
    TOP
    Copyright © 2018 www.massapi.com. All rights reserved.
    All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.