package examples.mega.client;

public class Main{

  private String host;
  private String port;

  public static void main( String[] args ){

    if( args.length != 2 ){
      throw new IllegalArgumentException( "usage: Main host port" );
    }

    Main main = new Main();
    main.host = args[0];
    main.port = args[1];


    try{
      main.doit();
    }catch( Throwable th ){
      th.printStackTrace( System.out );
    }
  }

  private void doit() throws Exception{
    doBasic();
    doSimple();
    doTemperature();
  }

  private void doSimple() throws Exception{
    String url = "http://" + host + ":" + port + 
      "/mega/SimpleTest?WSDL";

    SimpleTest service = new SimpleTest_Impl( url );
    SimpleTestSoap port = service.getSimpleTestSoap();
    System.out.println( port.echoString( "hi there" ) );

    new AsyncClient().invoke( port );
  }

  private void doTemperature() throws Exception{
    String url = "http://" + host + ":" + port + 
      "/mega/TemperatureService?WSDL";

    TemperatureService service = new TemperatureService_Impl( url );
    TemperatureServicePort port = service.getTemperatureServicePort();
    System.out.println( port.getTemp( "98374" ) );

    new JMSClient().invoke( url );
  }

  private void doBasic() throws Exception{

    String url = "http://" + host + ":" + port + 
      "/mega/MegaService?WSDL";

    MegaWebService service = new MegaWebService_Impl( url );
    MegaPort port = service.getMegaPort();

    new DynamicClient().invoke( url );
    new BindingProperties().invoke( port );
    new External().invoke( port );
    new BasicMethod().invoke( port );
    new DataTypes().invoke( port );
    new Exceptions().invoke( port );
    new Headers().invoke( port );
    new HandlerChain().invoke( port );
    new Attachment().invoke( port );
    new BrowserClient().invoke();
    new ClientHandler().invoke( url );
    new PerfClient().invoke( url );
    new WebServiceContextClient().invoke( service, port );
    new MultiThreadedPerfClient().invoke( url );
  }

}

