import versionclient.*;
import java.net.URL;
import java.rmi.Remote;
import org.apache.axis.EngineConfiguration;
import org.apache.axis.SimpleTargetedChain;
import org.apache.axis.client.Service;
import org.apache.axis.client.Stub;
import org.apache.axis.configuration.SimpleProvider;
import org.globus.axis.transport.GSIHTTPSender;
import org.globus.axis.transport.GSIHTTPTransport;
import org.globus.axis.util.Util;
import org.ietf.jgss.GSSCredential;
import org.globus.gsi.gssapi.auth.Authorization;

/**
 * Calls a Version webservice. 
 */
public class CallVersion
{
   static SimpleProvider p;
   /**
    * Prepares httpg handler.
    */
   static {
    p = new SimpleProvider();
    p.deployTransport("httpg", new SimpleTargetedChain(new GSIHTTPSender()));
    Util.registerTransport();
   }

   public static void main(String [] args) throws Exception {
    String url="httpg://loni.ics.muni.cz:30443/axis/services/Version";
    VersionServiceLocator s = new VersionServiceLocator();
    s.setEngineConfiguration(p);
    Version v = s.getVersion(new URL(url));
    //preparePort(v,...);
    System.out.print("Version: "+v.getVersion());
  }

  /**
   * Sets properties of Call when default are not enough.
   */
  static void preparePort(Remote ws,GSSCredential proxy,Authorization auth) {
    Stub stub = (Stub) ws;
    stub._setProperty(GSIHTTPTransport.GSI_CREDENTIALS, proxy);
    stub._setProperty(GSIHTTPTransport.GSI_AUTHORIZATION, auth);
    stub._setProperty(GSIHTTPTransport.GSI_MODE, GSIHTTPTransport.GSI_MODE_NO_DELEG);
  }
}

