XMethods
Service List · Forums · About XMethods · Getting Started · Resources · Mailing List · Add a Service · Notes
Getting Started

GLUE is a distributed computing platform for Java built on top of the web service protocol stack

GLUE is a distributed computing platform for Java built on top of the web service protocol stack.  It’s produced by The Mind Electric, http://www.themindelectric.com  , and is freely downloadable and usable for most commercial and all non-commercial purposes.  In this guide, we take a quick look at how to get up and running very quickly.  The feature list of GLUE is impressive; check out the datasheet at

 

http://www.themindelectric.com/products/glue/datasheet.html

 

We only show how to write a very basic client and server in this quick-start, but hopefully you’ll take the time to investigate the world of GLUE further.

 

 

A Quick-Start Guide to GLUE (beta 4)

 

Installing GLUE

 

GLUE is packaged as a small 440K JAR file and requires the support of a few standard JARs from SUN; these JAR files are packaged with the GLUE distribution, so there’s no need to wander the net gathering the files you need.  GLUE works on both the UNIX and Windows environments, and requires the 1.1 version of the JDK.

 

First, visit the GLUE homepage at:

 

 http://www.themindelectric.com/products/glue/glue.html 

 

Click “Download” from the Menu.  To download GLUE, you first must fill in some basic information and agree to the TME license. 

 

Once you have done this, TME sends you an email with the download URL for the package.  Download the GLUE package of your choice; both a ZIP file as well as a tarball are provided for your convenience. 

 

 

 

 

At this point, you should be ready to go with GLUE!

 

 

Writing a GLUE Service

 

Publishing a GLUE service is extremely easy, as you will soon see. At its simplest, you take an existing Java class and an associated interface file and wrap them.

 

First, let’s create a very simple class that will be used  to deliver the service functionality.

 

 

public class Echo

{

                public String echoString(String inputString)

                {

                                return inputString;

                }

}

 

 

 

As you can see, it has no concept that it will “grow up” to become a GLUE service! So publishing services based on classes that you already have built is very easy.

 

Compile the Echo class.  Now, let’s publish the service, by creating the file EchoService.java :

 

 

import electric.registry.Registry;
import electric.server.http.HTTP;

 

public class EchoService {

                public static void main (String[] args) throws Exception

                {

                                HTTP.startup( “http://localhost:8888/glue”) ;

                                Registry.publish ( “urn:Echo”, new Echo() );

                }

}

 

 

 

Compile and run EchoService .   You’ll see something like the following:

 

 

 

C:\example> java EchoService

GLUE beta 4.0 © 2001 The Mind Electric

startup server on http://192.168.0.8:8888/glue

 

 

The server is now running!  Now point your browser at http://localhost:8888/glue/urn:Echo.wsdl .  You’ll see the auto-generated WSDL service description for the service.

 

Writing a GLUE Client

 

Now, let’s build a GLUE client that consumes the service we just built.  GLUE makes it extremely easy to make client calls to published web services.

 

First, it’s important to note that GLUE clients use WSDL descriptions to configure themselves for consuming a service. In some server toolkits, such as GLUE and .NET, the WSDL is automatically generated for a published service. In others, the WSDL document must be generated offline and hosted as a static document somewhere.

 

First, let’s use GLUE’s wsdl2java utility to read a WSDL file and generate the Java interface and helper class for our client.

 

wsdl2java http://localhost:8888/glue/urn:Echo.wsdl

 

Running this command results in two files being produced:

 

IEcho.java and Echo.java

 

IEcho.java is the interface file for the service  and Echo.java is the helper class. Once you compile these two files, it’s easy to invoke the service with the following code:

 

 

 

import electric.registry.Registry;

 

public class EchoClient

{

                public static void main(String[] args)

   throws Exception

{

                IEcho echo = EchoHelper.bind();

                String result = echo.echoString(“Hello”);

                System.out.println(“Got back “+result);

}

}

 

 

When this EchoClient class is created, we run it :

 

 

c:\example> java EchoClient

Got back Hello

 

 

Now, let’s try hitting one of the XMethods services, the XMethods Temperature Service This service has a single method, getTemp, with the following signature:

 

float getTemp(String zipcode)

 

It takes in a zipcode argument and returns back a floating point number representing the temperature in that zipcode, in Fahrenheit, at that moment.

 

First, we run the wsdl2java against the WSDL URL. The URL is available in the XMethods service listing for Temperature, found at http://www.xmethods.net/detail.html?id=8

 

 

 

c:\example> wsdl2java http://www.xmethods.net/sd/2001/TemperatureService.wsdl

 

 

This creates the two files ITemperatureService.java and TemperatureService.java .  Once we compile these two files, we write our client code:

 

 

import electric.registry.Registry;

 

public class TempClient

{

                public static void main(String[] args)

   throws Exception

{

                ITemperatureService temp = TemperatureServiceHelper.bind();

                float currentF = temp.getTemp(“94043”);

                System.out.println(“It’s “+currentF+”degrees F in Palo Alto”);

}

}

 

 

When we compile and run this client, we get:

 

 

c:\example> java TempClient

It’s 60.0 degrees F in Palo Alto

 

 

That’s it for our brief tour.  It’s important to realize that we’ve only scratched the surface of GLUE. Be sure to check out the GLUE user’s manual for a much more detailed look at what GLUE can do!

Copyright © 2001 XMethods   Comments and Suggestions are welcome. Terms of Use