assertNotNull(wsdl);
HelloWorldQueueDecoupledOneWaysService service =
new HelloWorldQueueDecoupledOneWaysService(wsdl, serviceName);
assertNotNull(service);
Endpoint requestEndpoint = null;
Endpoint replyEndpoint = null;
try {
HelloWorldOneWayPort greeter = service.getPort(portName, HelloWorldOneWayPort.class);
GreeterImplQueueDecoupledOneWays requestServant = new GreeterImplQueueDecoupledOneWays();
requestEndpoint = Endpoint.publish("", requestServant);
GreeterImplQueueDecoupledOneWaysDeferredReply replyServant =
new GreeterImplQueueDecoupledOneWaysDeferredReply();
replyEndpoint = Endpoint.publish("", replyServant);
BindingProvider bp = (BindingProvider)greeter;
Map<String, Object> requestContext = bp.getRequestContext();
JMSMessageHeadersType requestHeader = new JMSMessageHeadersType();
requestHeader.setJMSReplyTo("dynamicQueues/test.jmstransport.oneway.with.set.replyto.reply");
requestContext.put(JMSConstants.JMS_CLIENT_REQUEST_HEADERS, requestHeader);
String expectedRequest = "JMS:Queue:Request";
greeter.greetMeOneWay(expectedRequest);
String request = requestServant.ackRequestReceived(5000);
if (request == null) {
if (requestServant.getException() != null) {
fail(requestServant.getException().getMessage());
} else {
fail("The oneway call didn't reach its intended endpoint");
}
}
assertEquals(expectedRequest, request);
requestServant.proceedWithReply();
String expectedReply = requestServant.ackReplySent(5000);
if (expectedReply == null) {
if (requestServant.getException() != null) {
fail(requestServant.getException().getMessage());
} else {
fail("The decoupled one-way reply was not sent");
}
}
String reply = replyServant.ackRequest(5000);
if (reply == null) {
if (replyServant.getException() != null) {
fail(replyServant.getException().getMessage());
} else {
fail("The decoupled one-way reply didn't reach its intended endpoint");
}
}
assertEquals(expectedReply, reply);
} catch (Exception ex) {
throw ex;
} finally {
if (requestEndpoint != null) {
requestEndpoint.stop();
}
if (replyEndpoint != null) {
replyEndpoint.stop();
}
}
}