String str = uuidGen.nextUUID();
Service service = new Service();
Call echoCall = (Call) service.createCall();
SandeshaContext ctx = new SandeshaContext();
//------------------------ECHO--------------------------------------------
ctx.setAcksToURL("http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
ctx.setReplyToURL("http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
ctx.setSendOffer(true);
ctx.initCall(echoCall, targetURL, "urn:wsrm:echoString", Constants.ClientProperties.IN_OUT);
echoCall.setOperationName(new QName("http://tempuri.org/", "echoString"));
echoCall.addParameter("arg1", XMLType.XSD_STRING, ParameterMode.IN);
echoCall.addParameter("arg2", XMLType.XSD_STRING, ParameterMode.IN);
echoCall.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
//----------------------ECHO------------------------------------------------
//------------------------PING--------------------------------------------
Service pingService = new Service();
Call pingCall = (Call) pingService.createCall();
SandeshaContext pingCtx = new SandeshaContext();
pingCtx.setAcksToURL("http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
pingCtx.setReplyToURL("http://127.0.0.1:" + defaultClientPort + "/axis/services/RMService");
pingCtx.initCall(pingCall, targetURL, "urn:wsrm:Ping", Constants.ClientProperties.IN_ONLY);
pingCall.setOperationName(new QName("http://tempuri.org/", "ping"));
pingCall.addParameter("arg2", XMLType.XSD_STRING, ParameterMode.IN);
//----------------------PING------------------------------------------------
String ret = (String) echoCall.invoke(new Object[]{" Echo 1 ", str});
System.out.println(" The Response for First Messsage is :" + ret);
pingCall.invoke(new Object[]{ret});
ctx.setLastMessage(echoCall);
ret = (String) echoCall.invoke(new Object[]{" Echo 2 ", str});
System.out.println(" The Response for Second Messsage is :" + ret);
pingCall.invoke(new Object[]{ret});
pingCtx.setLastMessage(pingCall);
pingCall.invoke(new Object[]{ret});
RMReport echoReport = ctx.endSequence();
RMReport pingReport = pingCtx.endSequence();
assertEquals(echoReport.isAllAcked(), true);
assertEquals(echoReport.getNumberOfReturnMessages(), 2);
assertEquals(pingReport.isAllAcked(), true);