package tutorial.sample3.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.getCrazyWorld();

      World headerWorld = new World();
      headerWorld.setName( "crazy world" );

      String id = "ID-12345";

      World bodyWorld = port.helloHeaderWorld( headerWorld, id );

      System.out.println( bodyWorld );

      port.helloOnewayWorld( "How are you?" );
    }catch( IOException e ){
      System.out.println( "Failed to create web service client:" + e );
    }catch( ServiceException e ){
      System.out.println( "Failed to create web service client:" + e );
    }
  }
}

