package tutorial.sample7.client;

import java.io.IOException;

import javax.xml.rpc.ServiceException;

import javax.xml.rpc.holders.StringHolder;
import javax.xml.rpc.holders.IntHolder;

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();

      port.helloInParam( 10 );
      System.out.println( port.helloReturnValue() );

      StringHolder stringHolder = new StringHolder();
      port.helloOutParam( stringHolder );
      System.out.println( stringHolder.value );

      IntHolder intHolder = new IntHolder();
      intHolder.value = 100;
      port.helloInOutParam( intHolder );
      System.out.println( intHolder.value );
    }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 );
    }catch( Throwable e ){
      e.printStackTrace();
    }
  }
}

