/*
 * Created on Aug 29, 2003
 *
 * To change the template for this generated file go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */
package SocioNet;

import org.apache.wsif.WSIFService;
import org.apache.wsif.WSIFServiceFactory;
import org.apache.wsif.WSIFException;
import java.rmi.RemoteException;

import com.transactionalweb.www.*;

/**
 * @author pmika
 *
 * To change the template for this generated type comment go to
 * Window - Preferences - Java - Code Generation - Code and Comments
 */

public class GeoClient {

	/**
	 * Simple class that Runs the SimpleSOAP sample using a pregenerated stub interface
	 * To use this class, provide a company stock symbol on the command line. WSIF 
	 * should then invoke the SOAP service with this information, returning with a recent 
	 * stockquote.
	 * @author Nirmal K. Mukhi (nmukhi@us.ibm.com)
	 */
	public static void main(String[] args) {
			try {

				if (args.length != 4) {
					System.out.println(
						"Usage: java SocioNet.GeoClient <wsdl location> <placename> <statecode> <country code>");
					System.exit(1);
				}

				// create a service factory
				WSIFServiceFactory factory = WSIFServiceFactory.newInstance();

				// parse WSDL
				WSIFService service =
					factory.getService(
						args[0],  
						"http://www.transactionalweb.com",
						"QueryInterfaceService",
						"http://www.transactionalweb.com",
					    "QueryInterface"
						);
				// create the stub
				//service.mapPackage("http://www.transactionalweb.com", "com.transactionalweb.www");
				//service.mapType(new QName("QueryInterface"), com.transactionalweb.www.QueryInterface.class);
				
				QueryInterface stub = (QueryInterface) service.getStub(QueryInterface.class);

				// do the invocation
				// args[1] is the name of the place
				// args[2] is the state code
				// args[3] is the country code
				Responsearray location = stub.doasearch(args[1], args[2], args[3]);
				System.out.println(location.getRecordarray().getRecord().getAdminarea1());

			} catch (WSIFException we) {
				System.out.println(
					"Error while executing sample, received an exception from WSIF; details:");
				we.printStackTrace();
			} catch (RemoteException re) {
				System.out.println(
					"Error while executing sample, received an exception due to remote invocation; details:");
				re.printStackTrace();
			} 
			/*catch (javax.xml.rpc.ServiceException se) {
					System.out.println(
						"Error while executing sample, received an exception due to service invocation; details:");
					se.printStackTrace();
			}*/
		}
	}

