import java.io.*;
import java.net.*;
import java.util.*;
import org.apache.soap.*;
import org.apache.soap.rpc.*;

/**
 */
public class getstate {
  public static void main (String[] args) throws Exception {
    if (args.length != 2) {
      System.err.println ("Usage: java " + getstate.class.getName () +
                          " SOAP-router-URL statecode");
      System.exit (1);
    }

    // Process the arguments.
    String encodingStyleURI = Constants.NS_URI_SOAP_ENC;
    URL url = new URL (args[0]);
    String statecode = args[1];
    String retparmname;
    String retparmvalue;

    if (statecode.length() != 2) {
      System.err.println ("State code must be 2 characters.");
      System.exit (1);
      }
    // Build the call.
    Call call = new Call ();
    call.setTargetObjectURI ("urn:iessoapd:soapwrap");
    call.setMethodName ("liststad");
    call.setEncodingStyleURI(encodingStyleURI);
    Vector params = new Vector ();
    params.addElement (new Parameter("statecode", String.class, statecode, null));
    call.setParams (params);

    // make the call: note that the action URI is empty because the 
    // XML-SOAP rpc router does not need this. This may change in the
    // future.
    Response resp = call.invoke (/* router URL */ url, /* actionURI */ "" );

    // Check the response.
    if (resp.generatedFault ()) {
      Fault fault = resp.getFault ();

      System.err.println("Generated fault: " + fault);
    } else {
      Parameter result = resp.getReturnValue ();
      System.out.println ("Response: " + result.getValue ());
    }
  }
}

