.. xws4j
welcome
license (LGPL)


.. SourceForge
project page
download
mailing lists

SourceForge.net Logo Bioclipse.net Logo


.. docu
javadoc
dependencies


.. tutorial
server - 3 minutes
client - 1 minute
binding tutorial

three minute server tutorial



This is a very quick introduction to xws4j. Skim read it to get an idea of how simple it is to create a XMPP IO Data service. I'm sure you'll have questions afterwards.


The server side of xws4j is a connecting component for XMPP servers. Please refer to your XMPP server manual to configure your XMPP server to accept connections from connecting component.

To create a default configuration file for your xws4j connecting component:

java -classpath "xws4j-current.jar:jso-full.jar" net.bioclipse.xws.component.Component new-cfg xws-component.cfg

To run the xws4j connecting component:

java -classpath "jso-full.jar:xws4j-current.jar" net.bioclipse.xws.component.Component run xws-component.cfg


Create a Java project. The project must have a class with the name Functions. This class must be located in package net.bioclipse.xws.component.functions, and must implement interface IFunctions. The method getFunctions() returns an array with all the function classes provided to the service component. The xws4j connecting component will host and publish the provided functions to the XMPP network.

Example:
package net.bioclipse.xws.component.functions;

import coffee.machine.*;
import net.bioclipse.xws.component.functions.IFunctions;

public class Functions implements IFunctions {

   public Class[] getFunctions() {
      return new Class[] {
         GetCoffeeCanStatus.class, // a synchronous sample function
         MakeNewCoffee.class,      // an asynchronous sample function
      };
   }
}


The provided function classes must implement interface IFunction. The method getFunctionInformation() returns an object that holds a description of this function, including function's input and output XML Schemata. The method run(IProcessStatus ps, Element input) performs the calculation.

Example:
package coffee.machine;

import net.bioclipse.xws.component.adhoc.function.FunctionInformation;
import net.bioclipse.xws.component.adhoc.function.IFunction;
import net.bioclipse.xws.component.xmpp.process.IProcessStatus;
import org.w3c.dom.Element;

public class GetCoffeeCanStatus implements IFunction {
   
   public FunctionInformation getFunctionInformation() {
      FunctionInformation info = new FunctionInformation(
         "getCoffeeCanStatus",                                                    // The name of the function
         "Returns the amount of coffee left in the can.",                         // A description of the function
         "Returns the amount of coffee left in the can. Requires no input.",      // A detailed description
         "<xs:schema targetNamespace ='urn:xws:getCoffeeCanStatus:input' .../>",  // W3C XML Schema of input
         "<xs:schema targetNamespace ='urn:xws:getCoffeeCanStatus:output' .../>", // W3C XML Schema of output
         false);                // true if this is a time-consuming (session-based
                                // and asynchronous) IO Data service.
      return info;
   }

   public void run(IProcessStatus ps, Element input) {
      
      // elaborate the result here ...
      
      ps.setResult(output, "The coffee can is full!"); // set the result and finish.
   }
}
Now create a similar class for the second supported function "makeNewCoffee" yourself.

Export the project as a .jar and add the file's location to xws4j component's configuration file.