package tutorial.sample36.client;

import java.io.IOException;
import javax.xml.rpc.ServiceException;
import javax.xml.rpc.Stub;

import weblogic.webservice.binding.BindingInfo;

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();
      Stub stub = (Stub)port;

      BindingInfo info = (BindingInfo)stub._getProperty( 
        "weblogic.webservice.bindinginfo" );

      info.setCharset( "UTF-8" );
      //info.setAcceptCharset( "UTF-8" );

      String i18nString = "hi there·¶¸";
      World world = port.helloComplexWorld( i18nString );

      System.out.println( world );
    }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 );
    }
  }
}

