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);
Callback callback3 = new TestCallback ("Callback 3");
serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo3",sequenceKey),callback3);
Callback callback4 = new TestCallback ("Callback 4");
serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo4",sequenceKey),callback4);
clientOptions.setProperty(SandeshaClientConstants.LAST_MESSAGE, "true");
Callback callback5 = new TestCallback ("Callback 5");
serviceClient.sendReceiveNonBlocking(getEchoOMBlock("echo5",sequenceKey),callback5);
while (!callback5.isComplete()) {
Thread.sleep(1000);
}
Thread.sleep(4000);
configContext.terminate();
serviceClient.cleanup();
}