Package org.apache.axis2.client

Examples of org.apache.axis2.client.ServiceClient


    String axis2_xml = AXIS2_CLIENT_PATH + "client_axis2.xml";
    
    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() &&
             !callback3.isComplete()) {
            Thread.sleep(1000);
        }
       
        Thread.sleep(6000);
       
        configContext.getListenerManager().stop();
        serviceClient.cleanup();
       
  }
View Full Code Here


            OMElement updatePayload = updatePayload("WSO", 123.42);
            Options options = new Options();
            options.setTo(targetEPR);
            options.setTransportInProtocol(Constants.TRANSPORT_HTTP);

            ServiceClient sender = new ServiceClient();
            sender.setOptions(options);

            sender.fireAndForget(updatePayload);
            System.err.println("done");
            Thread.sleep(3000);
            OMElement result = sender.sendReceive(getPricePayload);

            String response = result.getFirstElement().getText();
            System.err.println("Current price of WSO: " + response);

        } catch (Exception e) {
View Full Code Here

                configContext.setThreadPool(new ThreadPool(1, 5));
                configContext.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE);
                configContext.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
            }

            return new ServiceClient(configContext, axisService);

        } catch (AxisFault e) {
            throw new RuntimeException(e); // TODO: better exception
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
View Full Code Here

    }

    public void testN2N() throws Exception {
        // Creating the Simple Commodity Client
        System.getProperties().remove(org.apache.axis2.Constants.AXIS2_CONF);
        ServiceClient businessClient = new ServiceClient(null, null);
        Options options = new Options();
        options.setTo(
                new EndpointReference("http://127.0.0.1:10000/CommodityQuote"));
        businessClient.setOptions(options);

        OMElement response = businessClient.sendReceive(commodityPayload());

        assertNotNull(response);

        OMElement returnEle = response.getFirstChildWithName(new QName("return"));
View Full Code Here

                configContext.setThreadPool(new ThreadPool(1, 5));
                configContext.setProperty(HTTPConstants.REUSE_HTTP_CLIENT, Boolean.TRUE);
                configContext.setProperty(HTTPConstants.CACHED_HTTP_CLIENT, httpClient);
            }
   
            serviceClient = new ServiceClient(configContext, axisClientSideService);
   
        } catch (AxisFault e) {
            throw new RuntimeException(e); // TODO: better exception
        }
    }
View Full Code Here

    clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
   
    //setting the addressing version as submission
    clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_0);

    ServiceClient serviceClient = new ServiceClient (configContext,null);
    //serviceClient.
   
    serviceClient.setOptions(clientOptions);
   
    clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
    serviceClient.fireAndForget(getPingOMBlock("ping3"));

    Thread.sleep(10000);
       
    SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
    assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
    assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
    assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
 
    configContext.getListenerManager().stop();
    serviceClient.cleanup();
  }
View Full Code Here

    clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
   
    //setting the RM version as OASIS.
    clientOptions.setProperty(SandeshaClientConstants.RM_SPEC_VERSION,Sandesha2Constants.SPEC_VERSIONS.v1_1);
   
    ServiceClient serviceClient = new ServiceClient (configContext,null);
    //serviceClient.
   
    serviceClient.setOptions(clientOptions);
   
    serviceClient.fireAndForget(getPingOMBlock("ping3"));

    Thread.sleep(5000);
   
    SandeshaClient.terminateSequence(serviceClient);
   
    Thread.sleep(5000);
   
    SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
    assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
    assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
    assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
 
    configContext.getListenerManager().stop();
    serviceClient.cleanup();
  }
View Full Code Here

    clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
   
    //setting the addressing version as Final
    clientOptions.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,AddressingConstants.Final.WSA_NAMESPACE);

    ServiceClient serviceClient = new ServiceClient (configContext,null);
    //serviceClient.
   
    serviceClient.setOptions(clientOptions);
   
    clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
    serviceClient.fireAndForget(getPingOMBlock("ping3"));

    Thread.sleep(10000);
       
    SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
    assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
    assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
    assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
 
    configContext.getListenerManager().stop();
    serviceClient.cleanup();
  }
View Full Code Here

    clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY,sequenceKey);
   
    //setting the addressing version as Submission
    clientOptions.setProperty(AddressingConstants.WS_ADDRESSING_VERSION,AddressingConstants.Submission.WSA_NAMESPACE);

    ServiceClient serviceClient = new ServiceClient (configContext,null);
    //serviceClient.
   
    serviceClient.setOptions(clientOptions);
   
    clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
    serviceClient.fireAndForget(getPingOMBlock("ping3"));

    Thread.sleep(10000);
       
    SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient);
    assertTrue(sequenceReport.getCompletedMessages().contains(new Long(1)));
    assertEquals(sequenceReport.getSequenceStatus(),SequenceReport.SEQUENCE_STATUS_TERMINATED);
    assertEquals(sequenceReport.getSequenceDirection(),SequenceReport.SEQUENCE_DIRECTION_OUT);
 
    configContext.getListenerManager().stop();
    serviceClient.cleanup();
  }
View Full Code Here

    String axis2_xml = AXIS2_CLIENT_PATH + "client_axis2.xml";
    
    ConfigurationContext configContext = ConfigurationContextFactory.createConfigurationContextFromFileSystem(AXIS2_CLIENT_PATH,axis2_xml);

    ServiceClient serviceClient = new ServiceClient (configContext,null)
   
    Options clientOptions = new Options ();
   
    EndpointReference toEPR = new EndpointReference (toAddress);
    populateToEPRToRejectOffers(toEPR);
   
//    clientOptions.setManageSession(true); // without this reference params wont go.
    serviceClient.setTargetEPR(toEPR);
   
//    clientOptions.setProperty(Options.COPY_PROPERTIES,new Boolean (true));
    clientOptions.setTo(toEPR);
   
    clientOptions.setAction("urn:wsrm:EchoString");
   
    String acksTo = serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress();
    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(AddressingConstants.WS_ADDRESSING_VERSION,AddressingConstants.Submission.WSA_NAMESPACE);
    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(SandeshaClientConstants.OFFERED_SEQUENCE_ID,SandeshaUtil.getUUID())//single characted offers are declined by the server
   
    //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);

   
    Callback callback3 = new TestCallback ("Callback 3");
    serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo3",sequenceKey),callback3);
   
        while (!callback3.isComplete()) {
            Thread.sleep(1000);
        }
       
View Full Code Here

TOP

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

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.