private void runStubBased() throws Exception { String targetEndpoint = toEPR; ConfigurationContext configurationContext = generateConfigContext(); RMInteropServiceStub stub = new RMInteropServiceStub(configurationContext, targetEndpoint); ServiceClient stubServiceClient = stub._getServiceClient(); String acksToAddress = stubServiceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress(); setUpOptions(stubServiceClient.getOptions(), acksToAddress); Ping ping = new Ping(); ping.setText("ping1"); stub.ping(ping); ping = new Ping(); ping.setText("ping2"); stub.ping(ping); ping = new Ping(); ping.setText("ping3"); stub.ping(ping); SequenceReport sequenceReport = null; boolean complete = false; while (!complete) { sequenceReport = SandeshaClient.getOutgoingSequenceReport(stubServiceClient); if (sequenceReport != null && sequenceReport.getCompletedMessages().size() == 3) complete = true; else { try { Thread.sleep(1000); } catch (InterruptedException e1) { e1.printStackTrace(); } } } Thread.sleep(3000); SandeshaClient.terminateSequence(stubServiceClient); Thread.sleep(6000); stub._getServiceClient().cleanup(); }
private void run() throws Exception { ConfigurationContext configurationContext = generateConfigContext(); ServiceClient serviceClient = new ServiceClient(configurationContext, null); // String replyAddress = serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress() + "/" + // ServiceClient.ANON_OUT_ONLY_OP; String acksToAddress = serviceClient.getMyEPR(Constants.TRANSPORT_HTTP).getAddress(); Options clientOptions = new Options(); setUpOptions(clientOptions, acksToAddress); serviceClient.setOptions(clientOptions); serviceClient.fireAndForget(getPingOMBlock("ping1")); serviceClient.fireAndForget(getPingOMBlock("ping2")); serviceClient.fireAndForget(getPingOMBlock("ping3")); boolean complete = false; while (!complete) { SequenceReport sequenceReport = SandeshaClient.getOutgoingSequenceReport(serviceClient); if (sequenceReport != null && sequenceReport.getCompletedMessages().size() == 3) complete = true; else { try { Thread.sleep(1000); } catch (InterruptedException e1) { e1.printStackTrace(); } } } SandeshaClient.terminateSequence(serviceClient); Thread.sleep(3000); configurationContext.getListenerManager().stop(); serviceClient.cleanup(); }
private void run() throws Exception { if ("<SANDESHA2_HOME>".equals(SANDESHA2_HOME)) { System.out.println( "ERROR: Please set the directory you unzipped Sandesha2 as the first option."); return; } 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 = "sequence4"; clientOptions.setProperty(SandeshaClientConstants.SEQUENCE_KEY, sequenceKey); clientOptions.setProperty(Configuration.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); Thread.sleep(4000); }