Hi,
Following the Tutorial on XFire, I am facing problem testing the client. The server side went easy by following the example code given.
I am trying to test my web service through a sample client using xfire client feature.
Here is my code, that hits the service:
Code:
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 = "http://localhost:8080/webservice/services/Banking";
//String serviceUrl = "xfire.local://Banking";
IBankingService client = null;
try {
client = (IBankingService) factory.create(serviceModel, serviceUrl);
System.out.println(client.getClass().getName());
} catch (MalformedURLException e) {
System.out.println("WsClient.callWebService(): EXCEPTION: " + e.toString());
}
catch(Exception e ){
e.printStackTrace();
}
//Invoke the service
String serviceResponse = "";
try {
serviceResponse = client.transferFunds("FROMACCOUNT", "TOACCOUNT", 100.0, "Dollars");
} catch (Exception e){
System.out.println("WsClient.callWebService(): EXCEPTION: " + e.toString());
serviceResponse = e.toString();
}
System.out.println("WsClient.callWebService(): status=" + serviceResponse);
//Return the response
}
I am getting the following exception when I try running this method as a stand alone program.
Code:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/servlet/ServletOutputStream
at org.codehaus.xfire.transport.http.HttpTransport.createNewChannel(HttpTransport.java:36)
at org.codehaus.xfire.transport.AbstractTransport.createChannel(AbstractTransport.java:47)
at org.codehaus.xfire.transport.AbstractTransport.createChannel(AbstractTransport.java:38)
at org.codehaus.xfire.client.Client.getOutChannel(Client.java:410)
at org.codehaus.xfire.client.Client.invoke(Client.java:240)
at org.codehaus.xfire.client.XFireProxy.handleRequest(XFireProxy.java:77)
at org.codehaus.xfire.client.XFireProxy.invoke(XFireProxy.java:57)
at $Proxy0.transferFunds(Unknown Source)
at com.banking.WSClient.main(WSClient.java:52)
Could any one help me to understand whats going on.? It seems the host is not found.
When I try checking the service by typing the same URL in the browser, it works by displaying the wsdl xml.
Thanks for your help.
Anand