XFireHome DocumentationJavadocs QuicklinksAegis Binding DevelopersDeveloper Space |
Creating a serviceSteps
Assuming that you know how to do steps 1 and 2, lets pick up at step 3. Create your service class: package org.codehaus.xfire.xmlbeans; import net.webservicex.GetWeatherByZipCodeDocument; import net.webservicex.GetWeatherByZipCodeResponseDocument; import net.webservicex.WeatherForecasts; public class WeatherService { public GetWeatherByZipCodeResponseDocument GetWeatherByZipCode( GetWeatherByZipCodeDocument body ) { GetWeatherByZipCodeResponseDocument res = GetWeatherByZipCodeResponseDocument.Factory.newInstance(); WeatherForecasts weather = res.addNewGetWeatherByZipCodeResponse().addNewGetWeatherByZipCodeResult(); weather.setLatitude(1); weather.setLongitude(1); weather.setPlaceName("Grand Rapids, MI"); return res; } } Notice that we used the "Document" Types, not the "GetWeatherByZipCode" class. After you've created your service class you simply need to register it: XFire xfire = XFireFactory.newInstance().getXFire();
XmlBeansServiceFactory factory = new XmlBeansServiceFactory(xfire.getTransportManager());
Service service = factory.create(WeatherService.class);
xfire.getServiceRegistry().register(service);
XFire will not expose your service as the "WeatherService" and will generate WSDL for you automatically! |