package tutorial.sample43.client;

import java.io.IOException;

import javax.xml.rpc.ServiceException;

public class Main{

  public static void main( String[] args ){

    if( args.length == 1 ){
      new Main( args[0] );
    }else{
      throw new IllegalArgumentException( "URL of the service not specified" );
    }
  }

  public Main( String wsdlUrl ){
    try{
      HelloWorldService service = new HelloWorldService_Impl( wsdlUrl );
      HelloWorldServicePort port = service.getHelloWorldServicePort();

      World world = new World();
      world.setPopulation( 100L );
      world.setName("this world");
      String result = port.hello( world );
      System.out.println( result );
    }catch( IOException e ){
      System.out.println( "Failed to create web service client:" + e );
      e.printStackTrace();
    }catch( ServiceException e ){
      System.out.println( "Failed to create web service client:" + e );
      e.printStackTrace();
    }catch( Throwable e ){
      e.printStackTrace();
    }
  }
}

