Skip to content

Instantly share code, notes, and snippets.

@pdeva
Created July 14, 2015 21:20
Show Gist options
  • Save pdeva/c439ee119b366619f324 to your computer and use it in GitHub Desktop.
Save pdeva/c439ee119b366619f324 to your computer and use it in GitHub Desktop.
public String callWebService(String fromAccount, String toAccount, double amount, String currency)
throws MalformedURLException, Exception{
//create a metadata of the service
Service serviceModel = new ObjectServiceFactory().create(IBankingService.class);
System.out.println("callSoapServiceLocal(): got service model." );
//create a proxy for the deployed service
XFire xfire = XFireFactory.newInstance().getXFire();
XFireProxyFactory factory = new XFireProxyFactory(xfire);
//String serviceUrl = "xfire.local://Banking" ;
String serviceUrl = "http://localhost:8080/websvc/services/Banking";
IBankingService client = null;
try {
client = (IBankingService) factory.create(serviceModel, serviceUrl);
} catch (MalformedURLException e) {
log.error("WsClient.callWebService(): EXCEPTION: " + e.toString());
}
//invoke the service
String serviceResponse = "";
try {
serviceResponse = client.transferFunds(fromAccount, toAccount, amount, currency);
} catch (Exception e){
log.error("WsClient.callWebService(): EXCEPTION: " + e.toString());
serviceResponse = e.toString();
}
log.debug("WsClient.callWebService(): status=" + serviceResponse);
//return the response
return serviceResponse;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment