Hello Service Example

The following is an example application using Jockey that invokes a HelloWorld service and prints the response.

public class HelloServiceExample implements PeerMessageListener
{
    public void HelloServiceExample()
    {
	//
	// -- 1. Register App
	//
	HelloWorldDescriptor descriptor = new HelloWorldDescriptor();
	HelloWorldAuthority authority = new HelloWorldAuthority();

	sessionToken_ = PeerPlatform.getInstance().startPeerSession(descriptor);
	PeerPlatform.getInstance().addAuthority(authority);

	//
	// -- 2. Find the service
	//
	GroupToken appGroup = PeerPlatform.getInstance().getDefaultGroup();
	ServiceManager manager = ServiceManager.getInstance(appGroup);
	ServiceProxy proxy = manager.findService(ServiceManager.SERVICE_NAME, "HelloWorldService");

	//
	// -- 3. Invoke the service
	//
	String args[] = new String[0];
	ServiceCall serviceCall = new ServiceCall();
	serviceCall.setParameters(args);
	ServiceResponse response = proxy.invoke(serviceCall, 5000);
	System.out.println("Response from service: "+response.getResponse();

	//
	// -- 4. End session
	//
	PeerPlatform.getInstance().endSession(sessionToken_);
    }

    public static void main(String args[])
    {
	new HelloServiceExample();
    }

    private PeerToken sessionToken_;
}
	

$Id: HelloService.html,v 1.2 2001/07/27 17:20:59 james Exp $