File wsdl = new File(args[0]);
SOAPService ss = new SOAPService(wsdl.toURL(), SERVICE_NAME);
ExecutorService executor = Executors.newFixedThreadPool(5);
ss.setExecutor(executor);
GreeterAsync port = ss.getSoapPort();
String resp;
// callback method
TestAsyncHandler testAsyncHandler = new TestAsyncHandler();
System.out.println("Invoking greetMeSometimeAsync using callback object...");
Future<?> response = port.greetMeSometimeAsync(System.getProperty("user.name"), testAsyncHandler);
while (!response.isDone()) {
Thread.sleep(100);
}
resp = testAsyncHandler.getResponse();
System.out.println();
System.out.println("Server responded through callback with: " + resp);
System.out.println();
//polling method
System.out.println("Invoking greetMeSometimeAsync using polling...");
Response<GreetMeSometimeResponse> greetMeSomeTimeResp =
port.greetMeSometimeAsync(System.getProperty("user.name"));
while (!greetMeSomeTimeResp.isDone()) {
Thread.sleep(100);
}
GreetMeSometimeResponse reply = greetMeSomeTimeResp.get();
System.out.println("Server responded through polling with: " + reply.getResponseType());