XFire

Home
Bug/Issue Reporting
Download
FAQ
Get Involved
License
News
Performance
Stack Comparison
Support
Who uses XFire\?
XFire Team

Documentation

Javadocs
Reports
User's Guide
Release Notes

Quicklinks

Aegis Binding
Client
JAXB 2.0
JSR 181 Annotations
Spring

Developers

Developer Space
CVS
Building
Architecture
Interesting Projects
Roadmap
Release Process
JAX\-WS

Creating a service

Steps

  1. Create your Schema
  2. Create your XMLBeans
  3. Create your Service
  4. Register your service

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!