Package org.apache.axis2.context

Examples of org.apache.axis2.context.MessageContext


      log.debug("Enter: AcknowledgementManager::sendAckNow");

    // Write the acks into the envelope
    ackRMMsgContext.addSOAPEnvelope();
   
    MessageContext ackMsgContext = ackRMMsgContext.getMessageContext();
   
    // setting CONTEXT_WRITTEN since acksto is anonymous
    if (ackRMMsgContext.getMessageContext().getOperationContext() == null) {
      // operation context will be null when doing in a GLOBAL
      // handler.
      AxisOperation op = ackMsgContext.getAxisOperation();

      OperationContext opCtx = OperationContextFactory.createOperationContext(op.getAxisSpecificMEPConstant(), op, ackRMMsgContext.getMessageContext().getServiceContext());
      ackRMMsgContext.getMessageContext().setOperationContext(opCtx);
    }
View Full Code Here


  {
    SOAPFactory factory = new SOAP11Factory();
    SOAPEnvelope dummyEnvelope = factory.getDefaultEnvelope();
   
    // Create a "new" application message
    MessageContext messageContext = new MessageContext();
    messageContext.setConfigurationContext(serverConfigContext);
    messageContext.setAxisService(serverConfigContext.getAxisConfiguration().getService("RMSampleService"));   
    messageContext.setEnvelope(dummyEnvelope);
   
    RMMsgContext applicationRMMsg = new RMMsgContext(messageContext);
   
    // Generate the Sequence field.
    // -------------------------------
    String rmNamespaceValue = SpecSpecificConstants.getRMNamespaceValue(Sandesha2Constants.SPEC_VERSIONS.v1_1);

    Sequence sequence = new Sequence(rmNamespaceValue);
    MessageNumber msgNumber = new MessageNumber(rmNamespaceValue);
    msgNumber.setMessageNumber(1);
    sequence.setMessageNumber(msgNumber);
    Identifier id1 = new Identifier(rmNamespaceValue);
    id1.setIndentifer(uuid);
    sequence.setIdentifier(id1);
    applicationRMMsg.setMessagePart(Sandesha2Constants.MessageParts.SEQUENCE, sequence);
    applicationRMMsg.addSOAPEnvelope();

    // --------------------------------------------
    // Finished generating Sequence part
   
    // Create an RMSBean so the create sequence message can be created
    messageContext.setWSAAction(pingAction);

    // Set the AxisOperation to be InOut
    AxisOperation operation = messageContext.getAxisService().getOperation(Sandesha2Constants.RM_IN_OUT_OPERATION);
    operation.setMessageReceiver(new RMMessageReceiver());
    messageContext.setAxisOperation(operation);

    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
   
    // Serialize the application message
    applicationRMMsg.getMessageContext().getEnvelope().serialize(outputStream);
View Full Code Here

  {
    SOAPFactory factory = new SOAP11Factory();
    SOAPEnvelope dummyEnvelope = factory.getDefaultEnvelope();
   
    // Create a "new" application message
    MessageContext messageContext = new MessageContext();
    messageContext.setConfigurationContext(serverConfigContext);
    messageContext.setAxisService(serverConfigContext.getAxisConfiguration().getService("RMSampleService"));   
    messageContext.setEnvelope(dummyEnvelope);
   
    RMMsgContext applicationRMMsg = new RMMsgContext(messageContext);
   
    // Generate the Sequence field.
    // -------------------------------
    String rmNamespaceValue = SpecSpecificConstants.getRMNamespaceValue(Sandesha2Constants.SPEC_VERSIONS.v1_1);

    Sequence sequence = new Sequence(rmNamespaceValue);
    MessageNumber msgNumber = new MessageNumber(rmNamespaceValue);
    msgNumber.setMessageNumber(Long.MAX_VALUE);
    sequence.setMessageNumber(msgNumber);
    Identifier id1 = new Identifier(rmNamespaceValue);
    id1.setIndentifer(uuid);
    sequence.setIdentifier(id1);
    applicationRMMsg.setMessagePart(Sandesha2Constants.MessageParts.SEQUENCE, sequence);
    applicationRMMsg.addSOAPEnvelope();

    // --------------------------------------------
    // Finished generating Sequence part
   
    // Create an RMSBean so the create sequence message can be created
    messageContext.setWSAAction(pingAction);

    // Set the AxisOperation to be InOut
    AxisOperation operation = messageContext.getAxisService().getOperation(Sandesha2Constants.RM_IN_OUT_OPERATION);
    operation.setMessageReceiver(new RMMessageReceiver());
    messageContext.setAxisOperation(operation);

    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
   
    // Serialize the application message
    applicationRMMsg.getMessageContext().getEnvelope().serialize(outputStream);
View Full Code Here

  {
    SOAPFactory factory = new SOAP11Factory();
    SOAPEnvelope dummyEnvelope = factory.getDefaultEnvelope();
   
    // Create a "new" application message
    MessageContext messageContext = new MessageContext();
    messageContext.setConfigurationContext(serverConfigContext);
    messageContext.setAxisService(serverConfigContext.getAxisConfiguration().getService("RMSampleService"));   
    messageContext.setEnvelope(dummyEnvelope);
   
    RMMsgContext applicationRMMsg = new RMMsgContext(messageContext);
   
    // Generate the SequenceAck field.
    // -------------------------------
    String rmNamespaceValue = SpecSpecificConstants.getRMNamespaceValue(Sandesha2Constants.SPEC_VERSIONS.v1_1);

    SequenceAcknowledgement sequenceAck = new SequenceAcknowledgement(rmNamespaceValue);
    // Set the sequenceId
    Identifier id = new Identifier(rmNamespaceValue);
    id.setIndentifer(sequenceId);
    sequenceAck.setIdentifier(id);
   
    // Set the Invalid range!
    AcknowledgementRange ackRange = new AcknowledgementRange(rmNamespaceValue);
    ackRange.setLowerValue(1);
    ackRange.setUpperValue(3);
    sequenceAck.addAcknowledgementRanges(ackRange);

    // Set the SequenceAcknowledgement part in the message
    applicationRMMsg.setMessagePart(Sandesha2Constants.MessageParts.SEQ_ACKNOWLEDGEMENT, sequenceAck);
    applicationRMMsg.addSOAPEnvelope();

    // --------------------------------------------
    // Finished generating SequenceAck part
   
    // Create an RMSBean so the create sequence message can be created
    messageContext.setWSAAction("http://docs.oasis-open.org/ws-rx/wsrm/200702/SequenceAcknowledgement");

    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
   
    // Serialize the application message
    applicationRMMsg.getMessageContext().getEnvelope().serialize(outputStream);
View Full Code Here

        if (LOG.isDebugEnabled()) {
            LOG.debug("Target URI: " + request.getURI());
        }

        MessageContext msgContext = new MessageContext();
        msgContext.setIncomingTransportName(Constants.TRANSPORT_HTTP);
        msgContext.setProperty(MessageContext.REMOTE_ADDR, request.getRemoteAddr());

        try {
            TransportOutDescription transportOut = this.configurationContext.getAxisConfiguration()
                    .getTransportOut(Constants.TRANSPORT_HTTP);
            TransportInDescription transportIn = this.configurationContext.getAxisConfiguration()
                    .getTransportIn(Constants.TRANSPORT_HTTP);

            msgContext.setConfigurationContext(this.configurationContext);

            //TODO: Port this segment for session support.
//            String sessionKey = (String) this.httpcontext.getAttribute(HTTPConstants.COOKIE_STRING);
//            if (this.configurationContext.getAxisConfiguration().isManageTransportSession()) {
//                SessionContext sessionContext = this.sessionManager.getSessionContext(sessionKey);
//                msgContext.setSessionContext(sessionContext);
//            }
            msgContext.setTransportIn(transportIn);
            msgContext.setTransportOut(transportOut);
            msgContext.setServiceGroupContextId(UUIDGenerator.getUUID());
            msgContext.setServerSide(true);
            msgContext.setAxisService(this.service);
           
            doService2(request, response, msgContext);
        } catch (Throwable e) {
            String msg = "Exception occurred while trying to invoke service method doService()";
            LOG.error(msg, e);
            try {
                AxisEngine engine = new AxisEngine(this.configurationContext);

                msgContext.setProperty(MessageContext.TRANSPORT_OUT, response.getOutputStream());
                msgContext.setProperty(Constants.OUT_TRANSPORT_INFO, new Axis2TransportInfo(response));

                MessageContext faultContext = MessageContextBuilder.createFaultMessageContext(msgContext, e);
                // If the fault is not going along the back channel we should be 202ing
                if (AddressingHelper.isFaultRedirected(msgContext)) {
                    response.setStatusCode(HttpURLConnection.HTTP_ACCEPTED);
                } else {
                    response.setStatusCode(HttpURLConnection.HTTP_INTERNAL_ERROR);
View Full Code Here

        if (args != null && args.length > 0) {
            OMElement requestOM = dataBinding.toOMElement(args);
            env.getBody().addChild(requestOM);
        }

        MessageContext requestMC = new MessageContext();
        requestMC.setEnvelope(env);

        operationClient.addMessageContext(requestMC);

        ClassLoader tccl = Thread.currentThread().getContextClassLoader();
        ClassLoader scl = this.getClass().getClassLoader();
        try {
            if (tccl != scl) {
                Thread.currentThread().setContextClassLoader(scl);
            }

            operationClient.execute(true);

        } finally {
            if (tccl != scl) {
                Thread.currentThread().setContextClassLoader(tccl);
            }
        }

        MessageContext responseMC = operationClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
        OMElement responseOM = responseMC.getEnvelope().getBody().getFirstElement();

        Object[] os = null;
        if (responseOM != null) {
            os = dataBinding.fromOMElement(responseOM);
        }
View Full Code Here

        if (log.isDebugEnabled()) {
            log.debug("Target URI: " + request.getURI());
        }

        MessageContext msgContext = new MessageContext();
        msgContext.setIncomingTransportName(Constants.TRANSPORT_HTTP);
        msgContext.setProperty(MessageContext.REMOTE_ADDR, request.getRemoteAddr());
       

        try {
            TransportOutDescription transportOut = this.configurationContext.getAxisConfiguration()
                    .getTransportOut(Constants.TRANSPORT_HTTP);
            TransportInDescription transportIn = this.configurationContext.getAxisConfiguration()
                    .getTransportIn(Constants.TRANSPORT_HTTP);
           
           

            msgContext.setConfigurationContext(this.configurationContext);

            //TODO: Port this segment for session support.
//            String sessionKey = (String) this.httpcontext.getAttribute(HTTPConstants.COOKIE_STRING);
//            if (this.configurationContext.getAxisConfiguration().isManageTransportSession()) {
//                SessionContext sessionContext = this.sessionManager.getSessionContext(sessionKey);
//                msgContext.setSessionContext(sessionContext);
//            }
            msgContext.setTransportIn(transportIn);
            msgContext.setTransportOut(transportOut);
            msgContext.setServiceGroupContextId(UUIDGenerator.getUUID());
            msgContext.setServerSide(true);
           

//            // set the transport Headers
//            HashMap headerMap = new HashMap();
//            for (Iterator it = request.headerIterator(); it.hasNext();) {
//                Header header = (Header) it.next();
//                headerMap.put(header.getName(), header.getValue());
//            }
//            msgContext.setProperty(MessageContext.TRANSPORT_HEADERS, headerMap);
//
//            this.httpcontext.setAttribute(AxisParams.MESSAGE_CONTEXT, msgContext);

            doService2(request, response, msgContext);
        } catch (Throwable e) {
            String msg = "Exception occurred while trying to invoke service method doService()";
            log.error(msg, e);
            try {
                AxisEngine engine = new AxisEngine(this.configurationContext);

                msgContext.setProperty(MessageContext.TRANSPORT_OUT, response.getOutputStream());
                msgContext.setProperty(Constants.OUT_TRANSPORT_INFO, new Axis2TransportInfo(response));

                MessageContext faultContext = MessageContextBuilder.createFaultMessageContext(msgContext, e);
                // If the fault is not going along the back channel we should be 202ing
                if (AddressingHelper.isFaultRedirected(msgContext)) {
                    response.setStatusCode(202);
                } else {
                    response.setStatusCode(500);
View Full Code Here

            return;
        } else if (log.isDebugEnabled()) {
            log.debug("Processing message as Content-Type : " + contentType);
        }

        MessageContext msgContext = entry.createMessageContext();

        // Extract the charset encoding from the configured content type and
        // set the CHARACTER_SET_ENCODING property as e.g. SOAPBuilder relies on this.
        String charSetEnc;
        try {
            charSetEnc = new ContentType(contentType).getParameter("charset");
        } catch (ParseException ex) {
            // ignore
            charSetEnc = null;
        }
        msgContext.setProperty(Constants.Configuration.CHARACTER_SET_ENCODING, charSetEnc);
       
        MailOutTransportInfo outInfo = buildOutTransportInfo(message, entry);

        // save out transport information
        msgContext.setProperty(Constants.OUT_TRANSPORT_INFO, outInfo);
        // this property only useful for supporting smtp with Sandesha2.
        msgContext.setProperty(RequestResponseTransport.TRANSPORT_CONTROL, new MailRequestResponseTransport());

        // set message context From
        if (outInfo.getFromAddress() != null) {
            msgContext.setFrom(
                new EndpointReference(MailConstants.TRANSPORT_PREFIX +
                    outInfo.getFromAddress().getAddress()));
        }

        // save original mail message id message context MessageID
        msgContext.setMessageID(outInfo.getRequestMessageID());

        // set the message payload to the message context
        InputStream in = messagePart.getInputStream();
        try {
            try {
                msgContext.setEnvelope(TransportUtils.createSOAPMessage(msgContext, in, contentType));
            } catch (XMLStreamException ex) {
                handleException("Error parsing message", ex);
            }

            String soapAction = (String) trpHeaders.get(BaseConstants.SOAPACTION);
View Full Code Here

  private void processResponseMessage(RMMsgContext rmMsg, RMSBean rmsBean, String internalSequenceId, String outSequenceID, long messageNumber,
      String storageKey, StorageManager storageManager) throws AxisFault {
    if (log.isDebugEnabled())
      log.debug("Enter: ApplicationMsgProcessor::processResponseMessage, " + internalSequenceId + ", " + outSequenceID);

    MessageContext msg = rmMsg.getMessageContext();

    SenderBeanMgr retransmitterMgr = storageManager.getSenderBeanMgr();

    // setting last message
    boolean lastMessage = false;
    if (msg.isServerSide()) {
      Boolean inboundLast = (Boolean) msg.getProperty(Sandesha2Constants.MessageContextProperties.INBOUND_LAST_MESSAGE);
      if (inboundLast != null && inboundLast.booleanValue()) {
        lastMessage = true;
      }

    } else {
      // client side
      Object obj = msg.getProperty(SandeshaClientConstants.LAST_MESSAGE);
      if (obj != null && "true".equals(obj)) {
        lastMessage = true;
      }
    }

    // Now that we have decided which sequence to use for the message, make sure that we secure
    // it with the correct token.
    RMMsgCreator.secureOutboundMessage(rmsBean, msg);

    // Retransmitter bean entry for the application message
    SenderBean appMsgEntry = new SenderBean();

    appMsgEntry.setMessageContextRefKey(storageKey);

    appMsgEntry.setTimeToSend(System.currentTimeMillis());
    appMsgEntry.setMessageID(rmMsg.getMessageId());
    appMsgEntry.setMessageNumber(messageNumber);
    appMsgEntry.setLastMessage(lastMessage);
   
    SOAPEnvelope envelope = rmMsg.getSOAPEnvelope();
    if (lastMessage && envelope!=null && envelope.getBody().getFirstOMChild()==null)
      appMsgEntry.setMessageType(Sandesha2Constants.MessageTypes.LAST_MESSAGE);
    else
      appMsgEntry.setMessageType(Sandesha2Constants.MessageTypes.APPLICATION);
   
    appMsgEntry.setInboundSequenceId(inboundSequence);
    appMsgEntry.setInboundMessageNumber(inboundMessageNumber);
    if (outSequenceID == null) {
      appMsgEntry.setSend(false);
    } else {
      appMsgEntry.setSend(true);
      // Send will be set to true at the sender.
      msg.setProperty(Sandesha2Constants.SET_SEND_TO_TRUE, Sandesha2Constants.VALUE_TRUE);
      appMsgEntry.setSequenceID(outSequenceID);
    }
   
    EndpointReference to = rmMsg.getTo();
    if (to!=null)
      appMsgEntry.setToAddress(to.getAddress());
   
    appMsgEntry.setInternalSequenceID(internalSequenceId);

    msg.setProperty(Sandesha2Constants.QUALIFIED_FOR_SENDING, Sandesha2Constants.VALUE_FALSE);

    // increasing the current handler index, so that the message will not be
    // going throught the SandeshaOutHandler again.
    msg.setCurrentHandlerIndex(msg.getCurrentHandlerIndex() + 1);

    SandeshaUtil.executeAndStore(rmMsg, storageKey);

    retransmitterMgr.insert(appMsgEntry);
View Full Code Here


  public static MessageContext createNewRelatedMessageContext(RMMsgContext referenceRMMessage, AxisOperation operation)
      throws SandeshaException {
    try {
      MessageContext referenceMessage = referenceRMMessage.getMessageContext();
      ConfigurationContext configContext = referenceMessage.getConfigurationContext();
      AxisConfiguration axisConfiguration = configContext.getAxisConfiguration();

      MessageContext newMessageContext = new MessageContext();
      newMessageContext.setConfigurationContext(configContext);
     
      Options newOptions = new Options ();
      Options oldOptions = referenceMessage.getOptions();
     
      newMessageContext.setOptions(newOptions);
     
      if (referenceMessage.getAxisServiceGroup() != null) {
        newMessageContext.setAxisServiceGroup(referenceMessage.getAxisServiceGroup());
       
        if (referenceMessage.getServiceGroupContext()!=null) {
          newMessageContext.setServiceGroupContext(referenceMessage.getServiceGroupContext());
          newMessageContext.setServiceGroupContextId(referenceMessage.getServiceGroupContextId());
        } else {
          ServiceGroupContext serviceGroupContext = new ServiceGroupContext (
              configContext,referenceMessage.getAxisServiceGroup());
          newMessageContext.setServiceGroupContext(serviceGroupContext);
        }
      } else {
        AxisServiceGroup axisServiceGroup = new AxisServiceGroup(axisConfiguration);
        ServiceGroupContext serviceGroupContext = new ServiceGroupContext(configContext, axisServiceGroup);

        newMessageContext.setAxisServiceGroup(axisServiceGroup);
        newMessageContext.setServiceGroupContext(serviceGroupContext);
      }

      if (referenceMessage.getAxisService() != null) {
        newMessageContext.setAxisService(referenceMessage.getAxisService());
       
        if (referenceMessage.getServiceContext()!=null) {
          newMessageContext.setServiceContext(referenceMessage.getServiceContext());
          newMessageContext.setServiceContextID(referenceMessage.getServiceContextID());
        } else {
          ServiceContext serviceContext = new ServiceContext (referenceMessage.getAxisService(),newMessageContext.getServiceGroupContext());
          newMessageContext.setServiceContext(serviceContext);
        }
      }

      newMessageContext.setAxisOperation(operation);

      //The message created will basically be used as a outMessage, so setting the AxisMessage accordingly
      newMessageContext.setAxisMessage(operation.getMessage(WSDLConstants.MESSAGE_LABEL_OUT_VALUE));
     
      OperationContext operationContext = new OperationContext(operation, newMessageContext.getServiceContext());
      newMessageContext.setOperationContext(operationContext);
      operationContext.addMessageContext(newMessageContext);

      // adding a blank envelope
      SOAPFactory factory = SOAPAbstractFactory.getSOAPFactory(SandeshaUtil.getSOAPVersion(referenceMessage
          .getEnvelope()));
      newMessageContext.setEnvelope(factory.getDefaultEnvelope());

      newMessageContext.setTransportIn(referenceMessage.getTransportIn());
      newMessageContext.setTransportOut(referenceMessage.getTransportOut());

      // copying transport info.
      newMessageContext.setProperty(MessageContext.TRANSPORT_OUT, referenceMessage
          .getProperty(MessageContext.TRANSPORT_OUT));

      newMessageContext.setProperty(Constants.OUT_TRANSPORT_INFO, referenceMessage
          .getProperty(Constants.OUT_TRANSPORT_INFO));
      newMessageContext.setProperty(MessageContext.TRANSPORT_HEADERS, referenceMessage
          .getProperty(MessageContext.TRANSPORT_HEADERS));
      newMessageContext.setProperty(MessageContext.TRANSPORT_IN, referenceMessage
          .getProperty(MessageContext.TRANSPORT_IN));
      newMessageContext.setProperty(MessageContext.TRANSPORT_OUT, referenceMessage
          .getProperty(MessageContext.TRANSPORT_OUT));
     
      newMessageContext.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,
          referenceMessage.getProperty(AddressingConstants.WS_ADDRESSING_VERSION));
     
      copyConfiguredProperties (referenceMessage,newMessageContext);

      //copying the serverSide property
      newMessageContext.setServerSide(referenceMessage.isServerSide());
     
      //this had to be set here to avoid a double invocation.
      if (oldOptions!=null)
        newOptions.setUseSeparateListener(oldOptions.isUseSeparateListener());
View Full Code Here

TOP

Related Classes of org.apache.axis2.context.MessageContext

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.