Created
July 14, 2015 21:20
-
-
Save pdeva/c439ee119b366619f324 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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