Package org.apache.axis2.client

Examples of org.apache.axis2.client.Options


        }
        return result;
    }

    public static void executeClient() throws Exception {
        Options options = new Options();
        ServiceClient serviceClient;
        ConfigurationContext configContext = null;

        String addUrl = getProperty("addurl", "http://localhost:8280/services/EventingProxy");
        String repo = getProperty("repository", "client_repo");
        String symbol = getProperty("symbol", "GOOG");
        String price = getProperty("price", "10.10");
        String qty = getProperty("qty", "1000");
        String topic = getProperty("topic", "synapse/event/test");
        String action = getProperty("action", "urn:event");
        String topicns = getProperty("topicns", "http://apache.org/aip");

        if (repo != null && !"null".equals(repo)) {
            configContext =
                    ConfigurationContextFactory.
                            createConfigurationContextFromFileSystem(repo,
                                    repo + File.separator + "conf" + File.separator + "axis2.xml");
            serviceClient = new ServiceClient(configContext, null);
        } else {
            serviceClient = new ServiceClient();
        }
        OMFactory factory = OMAbstractFactory.getOMFactory();

        OMNamespace nsaip = factory.createOMNamespace(topicns, "aip");

        // set the target topic
        OMElement topicOm = factory.createOMElement("Topic", nsaip);
        factory.createOMText(topicOm, topic);

        // set addressing, transport and proxy url

        serviceClient.engageModule("addressing");
        options.setTo(new EndpointReference(addUrl));
        options.setAction(action);
        options.setProperty(MessageContext.CLIENT_API_NON_BLOCKING,
                Boolean.FALSE); // set for fire and foget
        serviceClient.setOptions(options);
        serviceClient.addHeader(topicOm);
        OMElement payload =
                AXIOMUtil.stringToOM("<m:placeOrder xmlns:m=\"http://services.samples\">\n" +
View Full Code Here


        }
        return result;
    }

    public static void executeClient() throws Exception {
        Options options = new Options();
        ServiceClient serviceClient;
        ConfigurationContext configContext = null;

        String addUrl = getProperty("addurl", "http://localhost:8280/services/JSONProxy");
        String trpUrl = getProperty("trpurl", null);
        String prxUrl = getProperty("prxurl", null);
        String repo = getProperty("repository", "client_repo");
        String symbol = getProperty("symbol", "IBM");

        if (repo != null && !"null".equals(repo)) {
            configContext =
                    ConfigurationContextFactory.
                            createConfigurationContextFromFileSystem(repo,
                                    repo + File.separator + "conf" + File.separator + "axis2.xml");
            serviceClient = new ServiceClient(configContext, null);
        } else {
            serviceClient = new ServiceClient();
        }

        if (trpUrl != null && !"null".equals(trpUrl)) {
            options.setProperty(Constants.Configuration.TRANSPORT_URL, trpUrl);
        }
        if (prxUrl != null && !"null".equals(prxUrl)) {
            HttpTransportProperties.ProxyProperties proxyProperties =
                    new HttpTransportProperties.ProxyProperties();
            URL url = new URL(prxUrl);
            proxyProperties.setProxyName(url.getHost());
            proxyProperties.setProxyPort(url.getPort());
            proxyProperties.setUserName("");
            proxyProperties.setPassWord("");
            proxyProperties.setDomain("");
            options.setProperty(HTTPConstants.PROXY, proxyProperties);
        }

        serviceClient.engageModule("addressing");
        options.setTo(new EndpointReference(addUrl));
        options.setAction("urn:getQuote");
        options.setProperty(Constants.Configuration.MESSAGE_TYPE, "application/json");
        serviceClient.setOptions(options);
        OMElement payload =
                AXIOMUtil.stringToOM("<getQuote><request><symbol>" + symbol + "</symbol>" +
                        "</request></getQuote>");
View Full Code Here

    private void initOperationClient(OperationClient opClient, MessageContext requestMsgCtx) {
        org.apache.axis2.context.MessageContext axisRequest = requestMsgCtx.getAxisMessageContext();
        setupProperties(requestMsgCtx);//, axisRequest.getOptions());

        if (opClient != null) {
            Options options = opClient.getOptions();
           
            // Get the target endpoint address and setup the TO endpoint
            // reference.  This tells us where the request is going.
            EndpointReference toEPR = axisRequest.getTo();

            if (toEPR == null) {
                String targetUrl = (String)requestMsgCtx.getProperty(
                        BindingProvider.ENDPOINT_ADDRESS_PROPERTY);
                toEPR = new EndpointReference(targetUrl);
            }
           
            options.setTo(toEPR);

            // Get the SOAP Action (if needed)
            String soapAction = ClientUtils.findSOAPAction(requestMsgCtx);
            options.setAction(soapAction);
            // get the timeout from the request message context options as it may have been
            // set by the user; if it was not set by the user we will just be setting the
            // timeout on the operation client to the default so it will not have a negative
            // effect; this logic is reliant on the fact the JAX-WS MessageContext is delegating
            // to the Axis2 Options object and not storing its own property bag
            long timeout = axisRequest.getOptions().getTimeOutInMilliSeconds();
            options.setTimeOutInMilliSeconds(timeout);

            // Use the OperationClient to send the request and put the contents
            // of the response in the response MessageContext.
            try {
                // Set the Axis2 request MessageContext
View Full Code Here

    
    ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_CLIENT_PATH,axis2_xml);

    ServiceClient serviceClient = new ServiceClient (configContext,null)
   
    Options clientOptions = new Options ();
   
    clientOptions.setTo(new EndpointReference (toEPR));
   
//    String acksTo = serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress() + "/" + ServiceClient.ANON_OUT_IN_OP;
//    clientOptions.setProperty(SandeshaClientConstants.AcksTo,acksTo);
//    clientOptions.setProperty(MessageContextConstants.CHUNKED,Constants.VALUE_FALSE);   //uncomment this to send messages without chunking.
   
    String sequenceKey = SandeshaUtil.getUUID()//sequence key for thie sequence.
    clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
   
    clientOptions.setReplyTo(new EndpointReference (AddressingConstants.Submission.WSA_ANONYMOUS_URL));
   
    clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportToEPR);
   
    clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);   //uncomment this to send messages in SOAP 1.2
   
    clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1)//uncomment this to send the messages according to the v1_1 spec.
   
    clientOptions.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,AddressingConstants.Submission.WSA_NAMESPACE);
    clientOptions.setProperty(SandeshaClientConstants.OFFERED_SEQUENCE_ID,SandeshaUtil.getUUID())//Uncomment this to offer a sequenceID for the incoming sequence.
    clientOptions.setAction("urn:wsrm:EchoString");
   
    //You must set the following two properties in the request-reply case.
    clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);

    //This asks Axis2 not to start a listner.
    clientOptions.setUseSeparateListener(true);
   
    serviceClient.setOptions(clientOptions);

    Callback callback1 = new TestCallback ("Callback 1");
    serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo1",sequenceKey),callback1);
View Full Code Here

    }
   
    String axis2_xml = AXIS2_CLIENT_PATH + "client_axis2.xml";
    ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_CLIENT_PATH,axis2_xml);
   
    Options clientOptions = new Options ()
    clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportToEPR);
    clientOptions.setTo(new EndpointReference (toEPR));
   
    String sequenceKey = SandeshaUtil.getUUID();// "sequence2";
    clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
     
//    clientOptions.setProperty(MessageContextConstants.CHUNKED,Constants.VALUE_FALSE);   //uncomment this to send messages without chunking.
    clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);   //uncomment this to send messages in SOAP 1.2
//    clientOptions.setProperty(SandeshaClient.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1);  //uncomment this to send the messages according to the v1_1 spec.
//    clientOptions.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,AddressingConstants.Submission.WSA_NAMESPACE);
   
    clientOptions.setProperty(SandeshaClientConstants.SANDESHA_LISTENER, new SandeshaListenerImpl ());
    ServiceClient serviceClient = new ServiceClient (configContext,null);
    serviceClient.engageModule(new QName ("sandesha2"));
   
    clientOptions.setAction("urn:wsrm:Ping");
    serviceClient.setOptions(clientOptions);
   
    clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");

    serviceClient.fireAndForget(getPingOMBlock());
    SandeshaClient.waitUntilSequenceCompleted(serviceClient);
   
    serviceClient.cleanup();
View Full Code Here

        }
      }
    }

    // setting an options with properties copied from the old one.
    Options relatesMessageOptions = relatedMessage.getOptions();
    if (relatesMessageOptions != null) {
      Options newMessageOptions = newMessage.getOptions();
      if (newMessageOptions == null) {
        newMessageOptions = new Options();
        newMessage.setOptions(newMessageOptions);
      }

      Map relatedMessageProperties = relatesMessageOptions.getProperties();
      Iterator keys = relatedMessageProperties.keySet().iterator();
      while (keys.hasNext()) {
        String key = (String) keys.next();
        newMessageOptions.setProperty(key, relatedMessageProperties.get(key));
      }

      Options relatedMessageParentOptions = relatesMessageOptions.getParent();
      if (relatedMessageParentOptions != null) {
        Map relatedMessageParentProperties = relatedMessageParentOptions.getProperties();
        keys = relatedMessageParentProperties.keySet().iterator();
        while (keys.hasNext()) {
          String key = (String) keys.next();
          newMessageOptions.setProperty(key, relatedMessageParentProperties.get(key));
        }
View Full Code Here

    }
   
    String axis2_xml = AXIS2_CLIENT_PATH + "client_axis2.xml";
    ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_CLIENT_PATH,axis2_xml);
   
    Options clientOptions = new Options ()
    clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportToEPR);
    clientOptions.setTo(new EndpointReference (toEPR));
   
    String sequenceKey = SandeshaUtil.getUUID();// "sequence2";
    clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
     
//    clientOptions.setProperty(MessageContextConstants.CHUNKED,Constants.VALUE_FALSE);   //uncomment this to send messages without chunking.
   
//    clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);   //uncomment this to send messages in SOAP 1.2
   
//    clientOptions.setProperty(SandeshaClient.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1);  //uncomment this to send the messages according to the v1_1 spec.
   
//    clientOptions.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,AddressingConstants.Submission.WSA_NAMESPACE);
   
    clientOptions.setProperty(SandeshaClientConstants.SANDESHA_LISTENER, new SandeshaListenerImpl ());
    ServiceClient serviceClient = new ServiceClient (configContext,null);
//    serviceClient.engageModule(new QName ("sandesha2"));
   
    clientOptions.setAction("urn:wsrm:Ping");
    serviceClient.setOptions(clientOptions);
   
    serviceClient.fireAndForget(getPingOMBlock("ping1"));
    serviceClient.fireAndForget(getPingOMBlock("ping2"));
   
    clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
    serviceClient.fireAndForget(getPingOMBlock("ping3"));
   
    SequenceReport sequenceReport = null;
     
    boolean complete = false;
View Full Code Here

    
    ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_CLIENT_PATH,axis2_xml);

    ServiceClient serviceClient = new ServiceClient (configContext,null)
   
    Options clientOptions = new Options ();
   
    clientOptions.setTo(new EndpointReference (toEPR));
   
    String acksTo = serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress() + "/" + ServiceClient.ANON_OUT_IN_OP;
    clientOptions.setProperty(SandeshaClientConstants.AcksTo,acksTo);
   
    String sequenceKey = "sequence4";
    clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
   
    clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportToEPR);
   
//    clientOptions.setProperty(MessageContextConstants.CHUNKED,Constants.VALUE_FALSE);   //uncomment this to send messages without chunking.
   
    clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);   //uncomment this to send messages in SOAP 1.2
   
//    clientOptions.setProperty(SandeshaClient.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1);  //uncomment this to send the messages according to the v1_1 spec.
   
    clientOptions.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,AddressingConstants.Submission.WSA_NAMESPACE);
    clientOptions.setProperty(SandeshaClientConstants.OFFERED_SEQUENCE_ID,SandeshaUtil.getUUID())//Uncomment this to offer a sequenceID for the incoming sequence.
    clientOptions.setAction("urn:wsrm:EchoString");
   
    //You must set the following two properties in the request-reply case.
    clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
    clientOptions.setUseSeparateListener(true);
   
    serviceClient.setOptions(clientOptions);

    clientOptions.setTimeOutInMilliSeconds(40000);
   
    OMElement result = serviceClient.sendReceive (getEchoOMBlock("echo1",sequenceKey));
    showResult(result);
   
    result = serviceClient.sendReceive (getEchoOMBlock("echo2",sequenceKey));
    showResult(result);
   
    result = serviceClient.sendReceive(getEchoOMBlock("echo3",sequenceKey));
    showResult(result);
   
    result = serviceClient.sendReceive(getEchoOMBlock("echo4",sequenceKey));
    showResult(result);
   
    clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
    OMElement bodyElem = getEchoOMBlock("echo5",sequenceKey);
   
    result = serviceClient.sendReceive(bodyElem);
    showResult(result);
           
View Full Code Here

    
    ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_CLIENT_PATH,axis2_xml);

    ServiceClient serviceClient = new ServiceClient (configContext,null)
   
    Options clientOptions = new Options ();
   
    clientOptions.setTo(new EndpointReference (toEPR));
   
   
    String acksTo = serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress() + "/" + ServiceClient.ANON_OUT_IN_OP;
    clientOptions.setProperty(SandeshaClientConstants.AcksTo,acksTo);
   
    String sequenceKey = SandeshaUtil.getUUID()//sequence key for thie sequence.
    clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
   
//    clientOptions.setReplyTo(new EndpointReference (AddressingConstants.Final.WSA_ANONYMOUS_URL));
//    clientOptions.setProperty(MessageContextConstants.CHUNKED,Constants.VALUE_FALSE);   //uncomment this to send messages without chunking.
//    clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1);  //uncomment this to send the messages according to the v1_1 spec.
//    serviceClient.engageModule(new QName ("sandesha2"));

    clientOptions.setProperty(MessageContextConstants.TRANSPORT_URL,transportToEPR);
   
    clientOptions.setSoapVersionURI(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI);   //uncomment this to send messages in SOAP 1.2

    clientOptions.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,AddressingConstants.Submission.WSA_NAMESPACE);
    clientOptions.setProperty(SandeshaClientConstants.OFFERED_SEQUENCE_ID,SandeshaUtil.getUUID())//Uncomment this to offer a sequenceID for the incoming sequence.
    clientOptions.setAction("urn:wsrm:EchoString");
   
    //You must set the following two properties in the request-reply case.
    clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
   
    clientOptions.setUseSeparateListener(true);
   
    serviceClient.setOptions(clientOptions);

    Callback callback1 = new TestCallback ("Callback 1");
    serviceClient.sendReceiveNonBlocking (getEchoOMBlock("echo1",sequenceKey),callback1);
   
    Callback callback2 = new TestCallback ("Callback 2");
    serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo2",sequenceKey),callback2);

    clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
    Callback callback3 = new TestCallback ("Callback 3");
    serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo3",sequenceKey),callback3);
   
        while (!callback1.isComplete() &&
             !callback2.isComplete() &&
View Full Code Here

    if (log.isDebugEnabled())
      log.debug("Enter: AckRequestedProcessor::processOutgoingAckRequestMessage");

    MessageContext msgContext = ackRequestRMMsg.getMessageContext();
    ConfigurationContext configurationContext = msgContext.getConfigurationContext();
    Options options = msgContext.getOptions();

    StorageManager storageManager = SandeshaUtil.getSandeshaStorageManager(configurationContext,
        configurationContext.getAxisConfiguration());

    SequencePropertyBeanMgr seqPropMgr = storageManager.getSequencePropertyBeanMgr();

    String toAddress = ackRequestRMMsg.getTo().getAddress();
    String sequenceKey = (String) options.getProperty(SandeshaClientConstants.SEQUENCE_KEY);
    String internalSeqenceID = SandeshaUtil.getInternalSequenceID(toAddress, sequenceKey);

    String outSequenceID = SandeshaUtil.getSequenceProperty(internalSeqenceID,
        Sandesha2Constants.SequenceProperties.OUT_SEQUENCE_ID, storageManager);
    if (outSequenceID == null)
View Full Code Here

TOP

Related Classes of org.apache.axis2.client.Options

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.