/*
* Developed by the NTUA IRMOS TEAM
*/
package gr.ntua.irmos.clients.map;
import org.globus.axis.message.addressing.Address;
import org.globus.axis.message.addressing.EndpointReferenceType;
import org.globus.axis.transport.HTTPUtils;
import org.apache.axis.client.Stub;
import gr.ntua.irmos.stubs.MapService_instance.MapPortType;
import gr.ntua.irmos.stubs.MapService_instance.GetValueRP;
import gr.ntua.irmos.stubs.MapService_instance.service.MapServiceAddressingLocator;
import gr.ntua.irmos.stubs.MapService_instance.Estimate;
public class Client {
// Client program for accessing the Mapping Service
//critical to set the time out of the client according to the maximum value needed for the estimation method
public static void main(String[] args) {
MapServiceAddressingLocator locator = new MapServiceAddressingLocator();
try {
String serviceURI = args[0];
// Create endpoint reference to service
EndpointReferenceType endpoint = new EndpointReferenceType();
endpoint.setAddress(new Address(serviceURI));
MapPortType map = locator.getMapPortTypePort(endpoint);
// Get PortType
map = locator.getMapPortTypePort(endpoint);
//necessary to set the client timeout, so that it does not occur during the create model phase
HTTPUtils.setTimeout((Stub)map, 1000 * 60 * 120);
//examples from globus client documentation-can be used as indicatios of how many estimations are made-each estimation adds 10 to the resource
// Perform an addition
map.add(10);
// Perform another addition
map.add(5);
// Access value
System.out.println("Current value: "
+ map.getValueRP(new GetValueRP()));
// Perform a subtraction
map.subtract(5);
// Access value
System.out.println("Current value: "
+ map.getValueRP(new GetValueRP()));
Estimate input=new Estimate();
input.setAscid(args[1]);
//change dynamically to whatever input in the following format [input1;input2;...;inputn]
input.setHlinput("[1;1;1;1]");
String result=map.estimate(input);
System.out.println("Current result: "+result);
} catch (Exception e) {
e.printStackTrace();
}
}
}