package hello;

import java.net.URL;
import java.util.Vector;
import org.apache.soap.SOAPException;
import org.apache.soap.Constants;
import org.apache.soap.Fault;
import org.apache.soap.rpc.Call;
import org.apache.soap.rpc.Parameter;
import org.apache.soap.rpc.Response;
/*
 * Created by IntelliJ IDEA.
 * User: soniv
 * Date: Nov 29, 2001
 * Time: 5:34:39 PM
 * To change template for new class use 
 * Code Style | Class Templates options (Tools | IDE Options).
 */

public class Client {
    public static void main(String args[]) {
		try {
			URL url = new URL("http://localhost:5555/soap/servlet/rpcrouter");
			String name = "Vinod";

			// Build the Call
			Call call = new Call();
            call.setTargetObjectURI("urn:Hello");
            call.setMethodName("sayHelloTo");
            call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
			Vector params = new Vector();
            params.addElement(new Parameter("name", String.class, name, null));
            call.setParams(params);

            // Invoke the call
			Response response = call.invoke(url, "");
			if (!response.generatedFault()) {
                Parameter ret = response.getReturnValue();
                Object value = ret.getValue();
				System.out.println(value);
			} else {
                Fault fault = response.getFault();
                System.err.println("Generated Fault: ");
                System.out.println("Fault Code: " + fault.getFaultCode());
				System.out.println("Fault String: " + fault.getFaultString());
			}
		} catch (Exception e) {
			System.out.println(e);
		}



	}
}
