Wednesday, November 16, 2016

consuming above webservice

consuming above webservice

we can consume in two way

Way 1 :

XFireClientFactoryBean client=new XFireClientFactoryBean();
try{
client.setServiceClass(Class.forName("com.optrasystems.mvc.TestInterface"));
client.setWsdlDocumentUrl("http://192.168.100.151:8089/thorlabs/app/citationService?WSDL");
client.afterPropertiesSet();
client.getObject();
TestInterface lTestInterface=(TestInterface)(client.getObject()));
String str=lTestInterface.sayHello();
request.getSession().setAttribute("webservice", str);
}catch(java.lang.Exception e){
e.printStackTrace();
}

Way 2 : (this using Axies web service)

// create proxy object
WeatherSoapProxy lWeatherSoapProxy=new WeatherSoapProxy();

//invoke method
WeatherDescription[] lWeatherDescription=lWeatherSoapProxy.getWeatherInformation();
for(WeatherDescription lWeatherDesc: lWeatherDescription){

System.out.println(lWeatherDesc.getDescription());
System.out.println(lWeatherDesc.getPictureURL());
System.out.println(lWeatherDesc.getWeatherID());
}

No comments: