Package org.apache.axis2.addressing

Examples of org.apache.axis2.addressing.MessageInformationHeaders


                    log.error(msg, e);
                    throw new SynapseException(msg, e);
                }
            }

            return new EndpointReference(transport + "://" + currentMember.getHostName() +
                    ":" + ("http".equals(transport) ? currentMember.getHttpPort() :
                    currentMember.getHttpsPort()) + address);
        } else {
            String msg = "Cannot load balance for non-HTTP/S transport " + transport;
            log.error(msg);
View Full Code Here


            }

            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)));
                SandeshaClient.terminateSequence(serviceClient);
            }
        }
   }
View Full Code Here

            }

            // 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);
View Full Code Here

                new MessageContext(msgContext.getSystemContext(),
                        msgContext.getSessionContext(),
                        msgContext.getTransportIn(),
                        msgContext.getTransportOut());

        MessageInformationHeaders oldMessageInfoHeaders =
                msgContext.getMessageInformationHeaders();
        MessageInformationHeaders messageInformationHeaders =
                new MessageInformationHeaders();
        messageInformationHeaders.setMessageId(UUIDGenerator.getUUID());
        messageInformationHeaders.setTo(oldMessageInfoHeaders.getReplyTo());
        messageInformationHeaders.setFaultTo(
                oldMessageInfoHeaders.getFaultTo());
        messageInformationHeaders.setFrom(oldMessageInfoHeaders.getTo());
        messageInformationHeaders.setRelatesTo(
                new RelatesTo(oldMessageInfoHeaders.getMessageId(),
                        AddressingConstants.Submission.WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE));
        messageInformationHeaders.setAction(oldMessageInfoHeaders.getAction());
        outMsgContext.setMessageInformationHeaders(messageInformationHeaders);
        outMsgContext.setOperationContext(msgContext.getOperationContext());
        outMsgContext.setServiceContext(msgContext.getServiceContext());
        outMsgContext.setServiceGroupContextId(msgContext.getServiceGroupContextId());
        outMsgContext.setProperty(MessageContext.TRANSPORT_OUT,
View Full Code Here

                        new MessageContext(messgeCtx.getSystemContext(),
                                messgeCtx.getSessionContext(),
                                messgeCtx.getTransportIn(),
                                messgeCtx.getTransportOut());
                   
                    MessageInformationHeaders oldMessageInfoHeaders =
                            messgeCtx.getMessageInformationHeaders();
                    MessageInformationHeaders messageInformationHeaders =
                            new MessageInformationHeaders();
                    messageInformationHeaders.setMessageId(UUIDGenerator.getUUID());
                    messageInformationHeaders.setTo(oldMessageInfoHeaders.getReplyTo());
                    messageInformationHeaders.setFaultTo(
                            oldMessageInfoHeaders.getFaultTo());
                    messageInformationHeaders.setFrom(oldMessageInfoHeaders.getTo());
                    messageInformationHeaders.setRelatesTo(
                            new RelatesTo(oldMessageInfoHeaders.getMessageId(),
                                    AddressingConstants.Submission.WSA_RELATES_TO_RELATIONSHIP_TYPE_DEFAULT_VALUE));
                    messageInformationHeaders.setAction(oldMessageInfoHeaders.getAction());
                    newmsgCtx.setMessageInformationHeaders(messageInformationHeaders);
                    newmsgCtx.setOperationContext(messgeCtx.getOperationContext());
                    newmsgCtx.setServiceContext(messgeCtx.getServiceContext());
                    newmsgCtx.setProperty(MessageContext.TRANSPORT_OUT,
                            messgeCtx.getProperty(MessageContext.TRANSPORT_OUT));
View Full Code Here

        if (sessionContext == null) {
            this.sessionContext = new SessionContext(null);
        } else {
            this.sessionContext = sessionContext;
        }
        messageInformationHeaders = new MessageInformationHeaders();
        this.transportIn = transportIn;
        this.transportOut = transportOut;
        this.configurationContext = engineContext;

        if (transportIn != null)
View Full Code Here

    protected TransportOutDescription senderTransport;


    public InOnlyMEPClient(ServiceContext service) {
        super(service, WSDLConstants.MEP_URI_IN_ONLY);
        messageInformationHeaders = new MessageInformationHeaders();
    }
View Full Code Here

        try {
            StAXSOAPModelBuilder omBuilder = testUtil.getOMBuilder(
                    testFileName);

            SOAPHeader header = ((SOAPEnvelope) omBuilder.getDocumentElement()).getHeader();
            MessageInformationHeaders messageInformationHeaders =
                    inHandler.extractCommonAddressingParameters(header,
                            null,
                            header.getHeaderBlocksWithNSURI(
                                    AddressingConstants.Submission.WSA_NAMESPACE),
                            AddressingConstants.Submission.WSA_NAMESPACE);

            if (messageInformationHeaders == null) {
                fail(
                        "Addressing Information Headers have not been retrieved properly");
            }
            assertEquals("action header is not correct",
                    messageInformationHeaders.getAction(),
                    action);
            assertEquals("action header is not correct",
                    messageInformationHeaders.getMessageId().trim(),
                    messageID.trim());

            assertFromEPR(messageInformationHeaders.getFrom());

        } catch (Exception e) {
            e.printStackTrace();
            log.info(e.getMessage());
            fail(" An Exception has occured " + e.getMessage());
View Full Code Here

        addressingNamespaceObject =
                OMAbstractFactory.getOMFactory().createOMNamespace(
                        addressingNamespace, WSA_DEFAULT_PRFIX);


        MessageInformationHeaders messageInformationHeaders =
                msgContext.getMessageInformationHeaders();
        SOAPHeader soapHeader = msgContext.getEnvelope().getHeader();


        EndpointReference epr = messageInformationHeaders.getTo();
        if (epr != null) {

            String address = epr.getAddress();
            if (!"".equals(address) && address != null) {
                SOAPHeaderBlock toHeaderBlock = soapHeader.addHeaderBlock(
                        WSA_TO, addressingNamespaceObject);
                toHeaderBlock.setText(address);
            }

            AnyContentType referenceParameters = epr.getReferenceParameters();
            if (referenceParameters != null) {
                processAnyContentType(referenceParameters, soapHeader);
            }

            addToHeader(epr, soapHeader);
        }

        String action = messageInformationHeaders.getAction();
        if (action != null) {
            processStringInfo(action, WSA_ACTION, soapHeader);
        }

        epr = messageInformationHeaders.getReplyTo();
        if (epr == null) {//optional
            // setting anonymous URI. Defaulting to Final.
            String anonymousURI = Final.WSA_ANONYMOUS_URL;
            if (Submission.WSA_NAMESPACE.equals(addressingNamespace)) {
                anonymousURI = Submission.WSA_ANONYMOUS_URL;
            }
            epr = new EndpointReference(anonymousURI);
        }
        // add the service group id as a reference parameter
        String serviceGroupContextId = msgContext.getServiceGroupContextId();
        if (serviceGroupContextId != null && !"".equals(serviceGroupContextId)) {
            if(epr.getReferenceParameters() == null){
                epr.setReferenceParameters(new AnyContentType());
            }
            epr.getReferenceParameters().addReferenceValue(new QName(Constants.AXIS2_NAMESPACE_URI,
                    Constants.SERVICE_GROUP_ID, Constants.AXIS2_NAMESPACE_PREFIX), serviceGroupContextId);
        }
        addToSOAPHeader(epr, AddressingConstants.WSA_REPLY_TO, soapHeader);


        epr = messageInformationHeaders.getFrom();
        if (epr != null) {//optional
            addToSOAPHeader(epr, AddressingConstants.WSA_FROM, soapHeader);
        }

        epr = messageInformationHeaders.getFaultTo();
        if (epr != null) {//optional
            addToSOAPHeader(epr, AddressingConstants.WSA_FAULT_TO, soapHeader);
        }

        String messageID = messageInformationHeaders.getMessageId();
        if (messageID != null) {//optional
            processStringInfo(messageID, WSA_MESSAGE_ID, soapHeader);
        }

        RelatesTo relatesTo = messageInformationHeaders.getRelatesTo();
        OMElement relatesToHeader = null;

        if (relatesTo != null) {
            relatesToHeader =
                    processStringInfo(relatesTo.getValue(),
View Full Code Here

            MessageInformationHeaders messageInformationHeaders,
            ArrayList addressingHeaders,
            String addressingNamespace)
            throws AddressingException {
        if (messageInformationHeaders == null) {
            messageInformationHeaders = new MessageInformationHeaders();
        }

        Iterator addressingHeadersIt = addressingHeaders.iterator();
        while (addressingHeadersIt.hasNext()) {
            SOAPHeaderBlock soapHeaderBlock = (SOAPHeaderBlock) addressingHeadersIt.next();
View Full Code Here

TOP

Related Classes of org.apache.axis2.addressing.MessageInformationHeaders

Copyright © 2018 www.massapicom. 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.