Examples of ServiceClient


Examples of org.apache.axis2.client.ServiceClient

 
  public static void main(String[] args) throws Exception {
   
    String axis2_xml = CLIENT_REPO_PATH + File.separator +"client_axis2.xml";
        ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(CLIENT_REPO_PATH,axis2_xml);
    ServiceClient serviceClient = new ServiceClient (configContext,null)
   
    Options clientOptions = new Options ();
    clientOptions.setTo(new EndpointReference (toEPR));
    clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
    clientOptions.setUseSeparateListener(true);
    serviceClient.setOptions(clientOptions);

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

    clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
    Callback callback3 = new TestCallback ("Callback 3");
    serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo3","sequence1"),callback3);
   
        while (!callback3.isComplete()) {
            Thread.sleep(1000);
        }
       
        Thread.sleep(4000);
       
        configContext.terminate();
        serviceClient.cleanup();
  }
View Full Code Here

Examples of org.apache.axis2.client.ServiceClient

    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);
   
    configContext.terminate();
    serviceClient.cleanup();
  }
View Full Code Here

Examples of org.apache.axis2.client.ServiceClient

    clientOptions.setTo(new EndpointReference (to));
   
    String sequenceKey = SandeshaUtil.getUUID();
    clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
   
    ServiceClient serviceClient = new ServiceClient (configContext,null);
    String acksTo = serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress();
    clientOptions.setProperty(SandeshaClientConstants.AcksTo,acksTo);
   
    clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
   

    serviceClient.setOptions(clientOptions);
    //serviceClient.
   
    clientOptions.setTransportInProtocol(Constants.TRANSPORT_HTTP);
    clientOptions.setUseSeparateListener(true);
   
    serviceClient.setOptions(clientOptions);
   
    TestCallback callback1 = new TestCallback ("Callback 1");
    serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo1",sequenceKey),callback1);
   
    TestCallback callback2 = new TestCallback ("Callback 2");
    serviceClient.sendReceiveNonBlocking (getEchoOMBlock("echo2",sequenceKey),callback2);

    long limit = System.currentTimeMillis() + waitTime;
    Error lastError = null;
    while(System.currentTimeMillis() < limit) {
      Thread.sleep(tickTime); // Try the assertions each tick interval, until they pass or we time out
     
      try {
            //testing outgoing sequence reports
        SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
        assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
        assertTrue(sequenceReport.getCompletedMessages().contains(new Long(2)));
        assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_ESTABLISHED);
        assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
       
        //testing incoming sequence reports
        ArrayList incomingSequenceReports = SandeshaClient.getIncomingSequenceReports(configContext);
        assertEquals(incomingSequenceReports.size(),1);
        SequenceReport incomingSequenceReport = (SequenceReport) incomingSequenceReports.get(0);
        assertEquals(incomingSequenceReport.getCompletedMessages().size(),2);
        assertNotNull(incomingSequenceReport.getSequenceID());
        assertEquals(incomingSequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_IN);
        assertNotNull(incomingSequenceReport.getInternalSequenceID());
       
        assertEquals(incomingSequenceReport.getSequenceID(),incomingSequenceReport.getInternalSequenceID())//for the incoming side, internalSequenceID==sequenceID

        lastError = null;
        break;
      } catch(Error e) {
        lastError = e;
      }
    }
    if(lastError != null) throw lastError;

    SandeshaClient.terminateSequence(serviceClient, sequenceKey);
    SandeshaClient.waitUntilSequenceCompleted(serviceClient, sequenceKey);
   
    SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
    assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
   
    configContext.getListenerManager().stop();
    serviceClient.cleanup();
  }
View Full Code Here

Examples of org.apache.axis2.client.ServiceClient

        if (repo != null && !"null".equals(repo)) {
            ConfigurationContext configContext =
                    ConfigurationContextFactory.
                            createConfigurationContextFromFileSystem(repo,
                                    repo + File.separator + "conf" + File.separator + "axis2.xml");
            return new ServiceClient(configContext, null);
        } else {
            return new ServiceClient();
        }
    }
View Full Code Here

Examples of org.apache.axis2.client.ServiceClient

        Options options = new Options();
        options.setTo(new EndpointReference(targetEPR));
        options.setAction("urn:uploadFileUsingSwA");
        options.setProperty(Constants.Configuration.ENABLE_SWA, Constants.VALUE_TRUE);

        ServiceClient sender = createServiceClient();
        sender.setOptions(options);
        OperationClient mepClient = sender.createClient(ServiceClient.ANON_OUT_IN_OP);

        MessageContext mc = new MessageContext();

        System.out.println("Sending file : " + fileName + " as SwA");
        FileDataSource fileDataSource = new FileDataSource(new File(fileName));
View Full Code Here

Examples of org.apache.axis2.client.ServiceClient

        OMText textData = factory.createOMText(dataHandler, true);
        image.addChild(textData);
        request.addChild(image);
        payload.addChild(request);

        ServiceClient serviceClient = createServiceClient();
        Options options = new Options();
        options.setTo(new EndpointReference(targetEPR));
        options.setAction("urn:uploadFileUsingMTOM");
        options.setProperty(Constants.Configuration.ENABLE_MTOM, Constants.VALUE_TRUE);

        serviceClient.setOptions(options);
        OMElement response = serviceClient.sendReceive(payload);

        OMText binaryNode = (OMText) response.
                getFirstChildWithName(new QName("http://services.samples", "response")).
                getFirstChildWithName(new QName("http://services.samples", "image")).
                getFirstOMChild();
View Full Code Here

Examples of org.apache.axis2.client.ServiceClient

        String repo =  repoLocationProperty != null ? repoLocationProperty : DEFAULT_CLIENT_REPO;
        ConfigurationContext configContext =
                ConfigurationContextFactory.createConfigurationContextFromFileSystem(
                        repo, repo + File.separator + "conf" + File.separator + "axis2.xml");

        ServiceClient client = new ServiceClient(configContext, null);
        long timeout = Integer.parseInt(getProperty("timeout", "10000000"));
        System.out.println("timeout=" + timeout);
        options.setTimeOutInMilliSeconds(timeout);

        // set addressing, transport and proxy url
        if (addUrl != null && !"null".equals(addUrl)) {
            client.engageModule("addressing");
            options.setTo(new EndpointReference(addUrl));
        }
        if (trpUrl != null && !"null".equals(trpUrl)) {
            options.setProperty(Constants.Configuration.TRANSPORT_URL, trpUrl);
        } else {
            client.engageModule("addressing");
        }
        if (prxUrl != null && !"null".equals(prxUrl)) {
            HttpTransportProperties.ProxyProperties proxyProperties =
                    new HttpTransportProperties.ProxyProperties();
            try {
                URL url = new URL(prxUrl);
                proxyProperties.setProxyName(url.getHost());
                proxyProperties.setProxyPort(url.getPort());
                proxyProperties.setUserName("");
                proxyProperties.setPassWord("");
                proxyProperties.setDomain("");
                options.setProperty(HTTPConstants.PROXY, proxyProperties);
            } catch (MalformedURLException e) {
                throw new AxisFault("Error creating proxy URL", e);
            }
        }

        client.setOptions(options);
        String testString = "";

        long i = 0;
        while (i < iterations || infinite) {

            if (sleepTime != -1) {
                try {
                    Thread.sleep(sleepTime);
                } catch (InterruptedException ignored) {
                }
            }

            client.getOptions().setManageSession(true);
            OMElement responseElement = client.sendReceive(value);
            String response = responseElement.getText();

            i++;
            System.out.println("Request: " + i + " ==> " + response);
            testString = testString.concat(":" + i + ">" + response + ":");
View Full Code Here

Examples of org.apache.axis2.client.ServiceClient

            String repo =  repoLocationProperty != null ? repoLocationProperty : DEFAULT_CLIENT_REPO;
            ConfigurationContext configContext =
                    ConfigurationContextFactory.createConfigurationContextFromFileSystem(
                            repo, repo + File.separator + "conf" + File.separator + "axis2.xml");
           
            ServiceClient client = new ServiceClient(configContext, null);

            // set addressing, transport and proxy url
            if (addUrl != null && !"null".equals(addUrl)) {
                client.engageModule("addressing");
                options.setTo(new EndpointReference(addUrl));
            }
            if (trpUrl != null && !"null".equals(trpUrl)) {
                options.setProperty(Constants.Configuration.TRANSPORT_URL, trpUrl);
            } else {
                client.engageModule("addressing");
            }
            if (prxUrl != null && !"null".equals(prxUrl)) {
                HttpTransportProperties.ProxyProperties proxyProperties =
                        new HttpTransportProperties.ProxyProperties();
                try {
                    URL url = new URL(prxUrl);
                    proxyProperties.setProxyName(url.getHost());
                    proxyProperties.setProxyPort(url.getPort());
                    proxyProperties.setUserName("");
                    proxyProperties.setPassWord("");
                    proxyProperties.setDomain("");
                    options.setProperty(HTTPConstants.PROXY, proxyProperties);
                } catch (MalformedURLException e) {
                    throw new AxisFault("Error creating proxy URL", e);
                }
            }
            client.setOptions(options);

            int i = 0;
            int sessionNumber;
            String[] cookies = new String[3];
            boolean httpSession = session != null && "http".equals(session);
            int cookieNumber;
            while (i < iterations || infinite) {

                i++;
                if (sleepTime != -1) {
                    try {
                        Thread.sleep(sleepTime);
                    } catch (InterruptedException ignored) {
                    }
                }

                MessageContext messageContext = new MessageContext();
                sessionNumber = getSessionTurn(envelopes.length);


                messageContext.setEnvelope(envelopes[sessionNumber]);
                cookieNumber = getSessionTurn(cookies.length);
                String cookie = cookies[cookieNumber];
                if (httpSession) {
                    setSessionID(messageContext, cookie);
                }
                try {
                    OperationClient op = client.createClient(ServiceClient.ANON_OUT_IN_OP);
                    op.addMessageContext(messageContext);
                    op.execute(true);

                    MessageContext responseContext =
                            op.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
View Full Code Here

Examples of org.apache.axis2.client.ServiceClient

        int quantity = 0;
        ConfigurationContext configContext = null;

        Options options = new Options();
        OMElement payload = null;
        ServiceClient serviceClient;

        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 ("customquote".equals(mode)) {
            payload = StockQuoteHandler.createCustomQuoteRequest(symbol);
            options.setAction("urn:getQuote");
        } else if ("fullquote".equals(mode)) {
            payload = StockQuoteHandler.createFullQuoteRequest(symbol);
            options.setAction("urn:getFullQuote");
        } else if ("placeorder".equals(mode)) {
            price = getRandom(100, 0.9, true);
            quantity = (int) getRandom(10000, 1.0, true);
            payload = StockQuoteHandler.createPlaceOrderRequest(price, quantity, symbol);
            options.setAction("urn:placeOrder");
        } else if ("marketactivity".equals(mode)) {
            payload = StockQuoteHandler.createMarketActivityRequest();
            options.setAction("urn:getMarketActivity");
        } else if ("quote".equals(mode) || "dualquote".equals(mode)) {
            payload = StockQuoteHandler.createStandardQuoteRequest(
                    symbol, Integer.parseInt(itr));
            options.setAction("urn:getQuote");
            if ("dualquote".equals(mode)) {
                serviceClient.engageModule("addressing");
                options.setUseSeparateListener(true);
            }
        }

        // set addressing, transport and proxy url
        if (addUrl != null && !"null".equals(addUrl)) {
            serviceClient.engageModule("addressing");
            options.setTo(new EndpointReference(addUrl));
        }
        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);
        }

        // apply any service policies if any
        if (svcPolicy != null && !"null".equals(svcPolicy) && svcPolicy.length() > 0) {
            System.out.println("Using WS-Security");
            serviceClient.engageModule("addressing");
            serviceClient.engageModule("rampart");
            options.setProperty(
                    RampartMessageData.KEY_RAMPART_POLICY, loadPolicy(svcPolicy));
        }

        if (Boolean.parseBoolean(rest)) {
            System.out.println("Sending as REST");
            options.setProperty(Constants.Configuration.ENABLE_REST, Constants.VALUE_TRUE);
        }
        if (Boolean.parseBoolean(wsrm) || Boolean.parseBoolean(wsrm11)) {
            System.out.println("Using WS-RM");
            serviceClient.engageModule("sandesha2");
            if (Boolean.parseBoolean(wsrm11)){
               options.setProperty(SandeshaClientConstants.RM_SPEC_VERSION, Sandesha2Constants.SPEC_VERSIONS.v1_1);
            }
            options.setProperty(SandeshaClientConstants.LAST_MESSAGE, Constants.VALUE_TRUE);
            options.setProperty(SandeshaClientConstants.OFFERED_SEQUENCE_ID, UIDGenerator.generateURNString());
        }

        if ("soap12".equals(soapVer)) {
            options.setSoapVersionURI(SOAP12Constants. SOAP_ENVELOPE_NAMESPACE_URI);
        }

        serviceClient.setOptions(options);

        InnerStruct.MODE = mode;
        InnerStruct.SYMBOL = symbol;
        InnerStruct.PRICE = price;
        InnerStruct.QUANTITY = quantity;

        if ("placeorder".equals(mode)) {
            serviceClient.fireAndForget(payload);
            Thread.sleep(5000);

        } else if ("dualquote".equals(mode)) {
            serviceClient.sendReceiveNonBlocking(payload, new StockQuoteCallback());
            printResult();
        } else {
            long i = 0;
            while (i < iterations || infinite) {
                InnerStruct.RESULT = serviceClient.sendReceive(payload);
                i++;
                printResult();
                if (Boolean.parseBoolean(wsrm) || Boolean.parseBoolean(wsrm11)) {
                    // give some time for RM to terminate normally
                    if (Boolean.parseBoolean(wsrm11)){
                        SandeshaClient.terminateSequence(serviceClient);
                    }
                    Thread.sleep(5000);
                    if (configContext != null) {
                        configContext.getListenerManager().stop();
                    }
                    serviceClient.cleanup();
                }
            }
        }
    }
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/SampleEventSource");
        String trpUrl = getProperty("trpurl", null);
        String prxUrl = getProperty("prxurl", null);
        String repo = getProperty("repository", "client_repo");
        String topic = getProperty("topic", "synapse/event/test");
        String address =
                getProperty("address", "http://localhost:9000/services/SimpleStockQuoteService");
        String mode = getProperty("mode", "subscribe");
        String identifier = getProperty("identifier", "90000");
        String expires = getProperty("expires", "*"); //Format: 2020-12-31T21:07:00.000-08:00

        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();
        OMElement message = factory.createOMElement("message", null);

        OMNamespace nsxmlins =
                factory.createOMNamespace("http://www.w3.org/2001/XMLSchema", "xmlns");
        OMNamespace nss11 =
                factory.createOMNamespace("http://schemas.xmlsoap.org/soap/envelope", "s11");
        OMNamespace nswsa = factory.createOMNamespace(
                "http://schemas.xmlsoap.org/ws/2004/08/addressing", "wsa");
        OMNamespace nswse =
                factory.createOMNamespace("http://schemas.xmlsoap.org/ws/2004/08/eventing", "wse");

        if (mode.equals("subscribe")) {
            OMElement subscribeOm = factory.createOMElement("Subscribe", nswse);
            OMElement deliveryOm = factory.createOMElement("Delivery", nswse);
            deliveryOm.addAttribute(factory.createOMAttribute("Mode", null,
                    "http://schemas.xmlsoap.org/ws/2004/08/eventing/DeliveryModes/Push"));
            OMElement notifyToOm = factory.createOMElement("NotifyTo", nswse);
            OMElement addressOm = factory.createOMElement("Address", nswsa);
            factory.createOMText(addressOm, address);
            OMElement expiresOm = factory.createOMElement("Expires", nswse);
            factory.createOMText(expiresOm, expires);
            OMElement filterOm = factory.createOMElement("Filter", nswse);
            filterOm.addAttribute(factory.createOMAttribute("Dialect", null,
                    "http://synapse.apache.org/eventing/dialect/topicFilter"));
            factory.createOMText(filterOm, topic);


            notifyToOm.addChild(addressOm);
            deliveryOm.addChild(notifyToOm);
            subscribeOm.addChild(deliveryOm);
            if (!(expires.equals("*"))) {
                subscribeOm.addChild(expiresOm); // Add only if the value provided
            }
            subscribeOm.addChild(filterOm);

            // set addressing, transport and proxy url

            serviceClient.engageModule("addressing");
            options.setTo(new EndpointReference(addUrl));

            options.setAction("http://schemas.xmlsoap.org/ws/2004/08/eventing/Subscribe");
            serviceClient.setOptions(options);
            System.out.println("Subscribing \n" + subscribeOm.toString());
            try {
                OMElement response = serviceClient.sendReceive(subscribeOm);
                System.out.println("Subscribed to topic " + topic);
                Thread.sleep(1000);
                System.out.println("Response Received: " + response.toString());
                String subId =
                        response.getFirstChildWithName(
                                new QName(nswse.getNamespaceURI(), "SubscriptionManager"))
                                .getFirstChildWithName(
                                        new QName(nswsa.getNamespaceURI(), "ReferenceParameters"))
                                .getFirstChildWithName(
                                        new QName(nswse.getNamespaceURI(), "Identifier")).getText();
                System.out.println("Subscription identifier: " + subId);
            } catch (AxisFault e) {
                System.out.println("Fault Received : " + e.toString());
                System.out.println("Fault Code     : " + e.getFaultCode().toString());
            }
        } else if (mode.equals("unsubscribe")) {
            /** Send unsubscribe message
             (01) <s12:Envelope
             (02)     xmlns:s12="http://www.w3.org/2003/05/soap-envelope"
             (03)     xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
             (04)     xmlns:wse="http://schemas.xmlsoap.org/ws/2004/08/eventing"
             (05)     xmlns:ow="http://www.example.org/oceanwatch" >
             (06)   <s12:Header>
             (07)     <wsa:Action>
             (08)       http://schemas.xmlsoap.org/ws/2004/08/eventing/Unsubscribe
             (09)     </wsa:Action>
             (10)     <wsa:MessageID>
             (11)       uuid:2653f89f-25bc-4c2a-a7c4-620504f6b216
             (12)     </wsa:MessageID>
             (13)     <wsa:ReplyTo>
             (14)      <wsa:Address>http://www.example.com/MyEventSink</wsa:Address>
             (15)     </wsa:ReplyTo>
             (16)     <wsa:To>
             (17)       http://www.example.org/oceanwatch/SubscriptionManager
             (18)     </wsa:To>
             (19)     <wse:Identifier>
             (20)       uuid:22e8a584-0d18-4228-b2a8-3716fa2097fa
             (21)     </wse:Identifier>
             (22)   </s12:Header>
             (23)   <s12:Body>
             (24)     <wse:Unsubscribe />
             (25)   </s12:Body>
             (26) </s12:Envelope>*/
            OMElement subscribeOm = factory.createOMElement("Unsubscribe", nswse);
            serviceClient.engageModule("addressing");
            options.setTo(new EndpointReference(addUrl));
            options.setAction("http://schemas.xmlsoap.org/ws/2004/08/eventing/Unsubscribe");
            OMElement identifierOm = factory.createOMElement("Identifier", nswse);
            factory.createOMText(identifierOm, identifier);
            serviceClient.addHeader(identifierOm);
            serviceClient.setOptions(options);
            System.out.println("UnSubscribing \n" + subscribeOm.toString());
            try {
                OMElement response = serviceClient.sendReceive(subscribeOm);
                System.out.println("UnSubscribed to ID " + identifier);
                Thread.sleep(1000);
                System.out.println("UnSubscribe Response Received: " + response.toString());
            } catch (AxisFault e) {
                System.out.println("Fault Received : " + e.toString());
                System.out.println("Fault Code     : " + e.getFaultCode().toString());
            }

        } else if (mode.equals("renew")) {
            /**
             * (01) <s12:Envelope
             (02)     xmlns:s12="http://www.w3.org/2003/05/soap-envelope"
             (03)     xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
             (04)     xmlns:wse="http://schemas.xmlsoap.org/ws/2004/08/eventing"
             (05)     xmlns:ow="http://www.example.org/oceanwatch" >
             (06)   <s12:Header>
             (07)     <wsa:Action>
             (08)       http://schemas.xmlsoap.org/ws/2004/08/eventing/Renew
             (09)     </wsa:Action>
             (10)     <wsa:MessageID>
             (11)       uuid:bd88b3df-5db4-4392-9621-aee9160721f6
             (12)     </wsa:MessageID>
             (13)     <wsa:ReplyTo>
             (14)      <wsa:Address>http://www.example.com/MyEventSink</wsa:Address>
             (15)     </wsa:ReplyTo>
             (16)     <wsa:To>
             (17)       http://www.example.org/oceanwatch/SubscriptionManager
             (18)     </wsa:To>
             (19)     <wse:Identifier>
             (20)       uuid:22e8a584-0d18-4228-b2a8-3716fa2097fa
             (21)     </wse:Identifier>
             (22)   </s12:Header>
             (23)   <s12:Body>
             (24)     <wse:Renew>
             (25)       <wse:Expires>2004-06-26T21:07:00.000-08:00</wse:Expires>
             (26)     </wse:Renew>
             (27)   </s12:Body>
             (28) </s12:Envelope>
             */
            OMElement subscribeOm = factory.createOMElement("Renew", nswse);
            OMElement expiresOm = factory.createOMElement("Expires", nswse);
            factory.createOMText(expiresOm, expires);
            subscribeOm.addChild(expiresOm);
            serviceClient.engageModule("addressing");
            options.setTo(new EndpointReference(addUrl));
            options.setAction("http://schemas.xmlsoap.org/ws/2004/08/eventing/Renew");
            OMElement identifierOm = factory.createOMElement("Identifier", nswse);
            factory.createOMText(identifierOm, identifier);
            serviceClient.addHeader(identifierOm);
            serviceClient.setOptions(options);
            System.out.println("SynapseSubscription Renew \n" + subscribeOm.toString());
            try {
                OMElement response = serviceClient.sendReceive(subscribeOm);
                System.out.println("SynapseSubscription Renew to ID " + identifier);
                Thread.sleep(1000);
                System.out.println(
                        "SynapseSubscription Renew Response Received: " + response.toString());
            } catch (AxisFault e) {
                System.out.println("Fault Received : " + e.toString());
                System.out.println("Fault Code     : " + e.getFaultCode().toString());
            }

        } else if (mode.equals("getstatus")) {
            /**
             * (01) <s12:Envelope
             (02)     xmlns:s12="http://www.w3.org/2003/05/soap-envelope"
             (03)     xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
             (04)     xmlns:wse="http://schemas.xmlsoap.org/ws/2004/08/eventing"
             (05)     xmlns:ow="http://www.example.org/oceanwatch" >
             (06)   <s12:Header>
             (07)     <wsa:Action>
             (08)       http://schemas.xmlsoap.org/ws/2004/08/eventing/GetStatus
             (09)     </wsa:Action>
             (10)     <wsa:MessageID>
             (11)       uuid:bd88b3df-5db4-4392-9621-aee9160721f6
             (12)     </wsa:MessageID>
             (13)     <wsa:ReplyTo>
             (14)       <wsa:Address>http://www.example.com/MyEventSink</wsa:Address>
             (15)     </wsa:ReplyTo>
             (16)     <wsa:To>
             (17)       http://www.example.org/oceanwatch/SubscriptionManager
             (18)     </wsa:To>
             (19)     <wse:Identifier>
             (20)       uuid:22e8a584-0d18-4228-b2a8-3716fa2097fa
             (21)     </wse:Identifier>
             (22)   </s12:Header>
             (23)   <s12:Body>
             (24)     <wse:GetStatus />
             (25)   </s12:Body>
             (26) </s12:Envelope>
             */
            OMElement subscribeOm = factory.createOMElement("GetStatus", nswse);
            serviceClient.engageModule("addressing");
            options.setTo(new EndpointReference(addUrl));
            options.setAction("http://schemas.xmlsoap.org/ws/2004/08/eventing/GetStatus");
            OMElement identifierOm = factory.createOMElement("Identifier", nswse);
            factory.createOMText(identifierOm, identifier);
            serviceClient.addHeader(identifierOm);
            serviceClient.setOptions(options);
            System.out.println("GetStatus using \n" + subscribeOm.toString());
            try {
                OMElement response = serviceClient.sendReceive(subscribeOm);
                System.out.println("GetStatus to ID " + identifier);
                Thread.sleep(1000);
                System.out.println("GetStatus Response Received: " + response.toString());
            } catch (AxisFault e) {
                System.out.println("Fault Received : " + e.toString());
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.