return result;
}
public static void executeClient() throws Exception {
Options options = new Options();
ServiceClient serviceClient;
ConfigurationContext configContext = null;
String addUrl = getProperty("addurl", "http://localhost:8280/services/JSONProxy");
String trpUrl = getProperty("trpurl", null);
String prxUrl = getProperty("prxurl", null);
String repo = getProperty("repository", "client_repo");
String symbol = getProperty("symbol", "IBM");
if (repo != null && !"null".equals(repo)) {
configContext =
ConfigurationContextFactory.
createConfigurationContextFromFileSystem(repo,
repo + File.separator + "conf" + File.separator + "axis2.xml");
serviceClient = new ServiceClient(configContext, null);
} else {
serviceClient = new ServiceClient();
}
if (trpUrl != null && !"null".equals(trpUrl)) {
options.setProperty(Constants.Configuration.TRANSPORT_URL, trpUrl);
}
if (prxUrl != null && !"null".equals(prxUrl)) {
HttpTransportProperties.ProxyProperties proxyProperties =
new HttpTransportProperties.ProxyProperties();
URL url = new URL(prxUrl);
proxyProperties.setProxyName(url.getHost());
proxyProperties.setProxyPort(url.getPort());
proxyProperties.setUserName("");
proxyProperties.setPassWord("");
proxyProperties.setDomain("");
options.setProperty(HTTPConstants.PROXY, proxyProperties);
}
serviceClient.engageModule("addressing");
options.setTo(new EndpointReference(addUrl));
options.setAction("urn:getQuote");
options.setProperty(Constants.Configuration.MESSAGE_TYPE, "application/json");
serviceClient.setOptions(options);
OMElement payload =
AXIOMUtil.stringToOM("<getQuote><request><symbol>" + symbol + "</symbol>" +
"</request></getQuote>");
OMElement response = serviceClient.sendReceive(payload);
if (response.getLocalName().equals("getQuoteResponse")) {
OMElement last = response.getFirstElement().getFirstChildWithName(new QName("last"));
System.out.println("Standard :: Stock price = $" + last.getText());
} else {
throw new Exception("Unexpected response : " + response);