Examples of ServiceClient


Examples of org.apache.axis2.client.ServiceClient

        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" +
                        "    <m:order>\n" +
                        "        <m:price>" + price + "</m:price>\n" +
                        "        <m:quantity>" + qty + "</m:quantity>\n" +
                        "        <m:symbol>" + symbol + "</m:symbol>\n" +
                        "    </m:order>\n" +
                        "</m:placeOrder>");

        System.out.println("Sending Event : \n" + payload.toString());
        serviceClient.fireAndForget(payload);
        System.out.println("Event sent to topic " + topic);
        Thread.sleep(1000);
        if (configContext != null) {
            configContext.terminate();
        }
View Full Code Here

Examples of org.apache.axis2.client.ServiceClient

        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>");

        OMElement response = serviceClient.sendReceive(payload);
        if (response.getLocalName().equals("getQuoteResponse")) {
            OMElement last = response.getFirstElement().getFirstChildWithName(new QName("last"));
            System.out.println("Standard :: Stock price = $" + last.getText());
        } else {
            throw new Exception("Unexpected response : " + response);
View Full Code Here

Examples of org.glite.authz.pap.client.ServiceClient

     * @param url the URL, as <code>String</code> of the PAP to contact.
     */
    public PAPClient(String url) {

        ServiceClientFactory serviceClientFactory = ServiceClientFactory.getServiceClientFactory();
        ServiceClient serviceClient = serviceClientFactory.createServiceClient();

        if (!url.endsWith("/")) {
            url += "/";
        }

        this.url = url + serviceClient.getProvisioningServiceName();

        provisioningClient = serviceClient.getProvisioningService(this.url);

        xacmlPolicyQuery = makeStandardPAPQuery();
    }
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.