Package org.apache.axis2.context

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


     */
    private void dispatchResponse(SOAPEnvelope soapEnvelope,
                                  String responseAction,
                                  MessageContext mc,
                                  boolean faultMessage) throws AxisFault {
        MessageContext rmc = MessageContextBuilder.createOutMessageContext(mc);
        rmc.getOperationContext().addMessageContext(rmc);
        rmc.setEnvelope(soapEnvelope);
        rmc.setWSAAction(responseAction);
        rmc.setSoapAction(responseAction);
        rmc.setProperty(SynapseConstants.ISRESPONSE_PROPERTY, Boolean.TRUE);
        if (faultMessage) {
            AxisEngine.sendFault(rmc);
        } else {
            AxisEngine.send(rmc);
        }
View Full Code Here

                "    <wse:Filter xmlns:ow=\"http://www.example.org/oceanwatch\"\n" +
                "              Dialect=\"" + filterDialect + "\" >" + filter +"</wse:Filter>\n" +
                "</wse:Subscribe>";

        try {
            MessageContext msgCtx = TestUtils.getAxis2MessageContext(message, null).
                    getAxis2MessageContext();
            msgCtx.setTo(new EndpointReference(subManUrl));

            SynapseSubscription sub = SubscriptionMessageBuilder.createSubscription(msgCtx);
            assertEquals(subManUrl, sub.getSubManUrl());
            assertEquals(addressUrl, sub.getAddressUrl());
            assertEquals(addressUrl, sub.getEndpointUrl());
View Full Code Here

    public void testSubscriptionMessageBuilderScenarioTwo() {
        String addressUrl = "http://synapse.test.com/eventing/subscriptions";

        String message = "<wse:Unsubscribe xmlns:wse=\"http://schemas.xmlsoap.org/ws/2004/08/eventing\"/>";
        try {
            MessageContext msgCtx = TestUtils.getAxis2MessageContext(message, null).
                        getAxis2MessageContext();
            msgCtx.setTo(new EndpointReference(addressUrl));
            String id = addIdentifierHeader(msgCtx);

            SynapseSubscription sub = SubscriptionMessageBuilder.createUnSubscribeMessage(msgCtx);
            assertEquals(id, sub.getId());
            assertEquals(addressUrl, sub.getAddressUrl());
View Full Code Here

        String message =
                "<wse:Renew xmlns:wse=\"http://schemas.xmlsoap.org/ws/2004/08/eventing\">\n" +
                "   <wse:Expires>" + ConverterUtil.convertToString(cal) + "</wse:Expires>\n" +
                "</wse:Renew>";
        try {
            MessageContext msgCtx = TestUtils.getAxis2MessageContext(message, null).
                        getAxis2MessageContext();
            msgCtx.setTo(new EndpointReference(addressUrl));
            String id = addIdentifierHeader(msgCtx);

            SynapseSubscription sub = SubscriptionMessageBuilder.
                    createRenewSubscribeMessage(msgCtx);
            assertEquals(id, sub.getId());
View Full Code Here

        String addressUrl = "http://synapse.test.com/eventing/subscriptions";

        String message =
                "<wse:GetStatus xmlns:wse=\"http://schemas.xmlsoap.org/ws/2004/08/eventing\"/>";
        try {
            MessageContext msgCtx = TestUtils.getAxis2MessageContext(message, null).
                        getAxis2MessageContext();
            msgCtx.setTo(new EndpointReference(addressUrl));
            String id = addIdentifierHeader(msgCtx);

            SynapseSubscription sub = SubscriptionMessageBuilder.createGetStatusMessage(msgCtx);
            assertEquals(id, sub.getId());
            assertEquals(addressUrl, sub.getAddressUrl());
View Full Code Here

        String message =
                "<wse:Renew xmlns:wse=\"http://schemas.xmlsoap.org/ws/2004/08/eventing\">\n" +
                "   <wse:Expires>2004-06-26T21:07:00.000-08:00</wse:Expires>\n" +
                "</wse:Renew>";
        try {
            MessageContext msgCtx = TestUtils.getAxis2MessageContext(message, null).
                        getAxis2MessageContext();
            msgCtx.setTo(new EndpointReference(addressUrl));
            String id = addIdentifierHeader(msgCtx);

            SynapseSubscription sub = SubscriptionMessageBuilder.
                    createRenewSubscribeMessage(msgCtx);
            assertNull(id, sub.getId());
View Full Code Here

*/
public class MessageHelperTest extends TestCase {

    public void testClonePartially() throws Exception {
        String key = "propKey";
        MessageContext origMc = new MessageContext();
        origMc.setProperty(key, "propValue");
        MessageContext newMc = MessageHelper.clonePartially(origMc);
        Object result = newMc.getProperty(key);
        assertEquals(result, "propValue");
    }
View Full Code Here

        assertEquals(result, "propValue");
    }
   
    // Regression test for SYNAPSE-309
    public void testClonePartiallyWithAttachments() throws Exception {
        MessageContext origMc = new MessageContext();
        String contentId = origMc.addAttachment(new DataHandler("test", "text/html"));
        MessageContext newMc = MessageHelper.clonePartially(origMc);
        DataHandler dh = newMc.getAttachment(contentId);
        assertNotNull(dh);
        assertEquals("test", dh.getContent());
    }
View Full Code Here

            }
        }
    }
   
    private SyslogMessage test(String message) throws Exception {
        MessageContext msgContext = new MessageContext();
        ByteArrayInputStream in = new ByteArrayInputStream(message.getBytes("us-ascii"));
        OMElement element = new SyslogMessageBuilder().processDocument(in, null, msgContext);
        SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
        Schema schema = factory.newSchema(new StreamSource(SyslogMessageBuilderTest.class.getResource("schema.xsd").toExternalForm()));
        Validator validator = schema.newValidator();
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.