| Warning This will probably not work for you. We are working hard on improved client support. If you would like to join the team, please contact us! |
Web service clients can be created from a WSDL file using an Ant task. Creating a client service is a two step process. First, you need to use XMLBeans to generate types from the WSDL document. Next, XFire's stub generator is used to create a client. Unfortunately, this process will not work for RPC/Encoded services, however rpc/encoded documents can still be constructed by hand using the method outlined in the previous section.
Generating XMLBeans
While, you may also find it helpful to read the XMLBeans documentation, a quick summary of how to generate XMLBeans is provided here.
Generating XMLBeans just requires a few lines in your Ant build file or your Maven "maven.xml".
This will output the XMLBeans classes into the directory "${destination.class.directory}". It looks in the "${basedir}/src/test-schemas" directory to find any WSDL and XSD files which it uses to generate types. You also need to have a path set up which has the XMLBeans jar on it - in this case it is called "task.path".
Its also possible to generate a jar for the XMLBeans classes like so:
where you replace "${output.dir}/output.jar" with the path name of where you want the resultant jar.
Generating a Client
Next, we need to add one more section your build file. This will generate your client.
This takes the "WeatherForecas.wsdl" file and generates a control interface in the package "org.codehaus.xfire.weather." The classpath "generate.path" needs to have both XMLBeans and the classes generated in the previous step in it. Source files will be generated in "${src.output.dir}".
Using the Client
Once you've generated your stub, the hard part is done. Operations for the service will appear as methods on the resultant client. To invoke the service, just invoke a method on the client.
Typical usage of a client would be like so:
