String getResponseFromWebService() {
String responseFromWebService = "No message sent";
CXFConnection connection = null;
try {
connection = getServiceConnection();
Greeter greeter = connection.getService(Greeter.class);
if (operationName != null) {
if ("sayHi".equals(operationName)) {
responseFromWebService = greeter.sayHi();
} else if ("greetMe".equals(operationName)) {
responseFromWebService = greeter.greetMe(userName);
}
}
Map<String, Object> requestContext = ((BindingProvider)greeter).getRequestContext();
System.out.println("requestContext = " + requestContext);
} catch (Exception e) {
e.printStackTrace();
if (e.getCause() != null) {
e.getCause().printStackTrace();
}
responseFromWebService = e.toString();
} finally {
try {
if (connection != null) {
connection.close();
}
} catch (Exception e) {
// report error from close
}
}