1 package org.astrogrid.ogsa.echo;
2
3 import java.net.URL;
4 import java.util.GregorianCalendar;
5 import org.astrogrid.ogsa.echo.EchoServiceLocator;
6 import org.astrogrid.ogsa.echo.EchoPortType;
7 import org.gridforum.ogsi.Factory;
8 import org.gridforum.ogsi.LocatorType;
9 import org.gridforum.ogsi.OGSIServiceLocator;
10 import org.globus.ogsa.utils.GridServiceFactory;
11
12 /***
13 * Exercises an echo service with a single invocation.
14 */
15 public class TestEcho {
16
17 public static void main (String[] args) throws Exception {
18
19 if (args.length != 2) {
20 System.err.println("usage: echo <string> <factory-URL>");
21 return;
22 }
23
24 try {
25
26
27
28 OGSIServiceLocator factoryLocator = new OGSIServiceLocator();
29 Factory factory = factoryLocator.getFactoryPort(new URL(args[1]));
30 GridServiceFactory gridFactory = new GridServiceFactory(factory);
31
32
33
34 GregorianCalendar timeout = new GregorianCalendar();
35 timeout.add(GregorianCalendar.MINUTE, 10);
36 LocatorType instanceLocator = gridFactory.createService(timeout);
37 EchoServiceGridLocator portLocator = new EchoServiceGridLocator();
38 EchoPortType port = portLocator.getEchoPortType(instanceLocator);
39
40
41 System.out.println(port.echo(args[0]));
42 }
43 catch (Exception e) {
44 System.out.println(e.getMessage());
45 }
46 }
47 }