// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
package ws.client;

import javax.xml.rpc.*;
import javax.xml.namespace.*;

public class TestTest {
    public static void add(String item) throws Exception {
        String endpoint = "http://localhost:8080/axis/services/TestService";
        ServiceFactory servfact = ServiceFactory.newInstance();
        Service serv = servfact.createService(new QName("localhost"));
        Call cal = serv.createCall();
        cal.setTargetEndpointAddress(endpoint);
        cal.setOperationName(new QName("add"));
        Object[] arg = new Object[1];
        arg[0] = item;
        cal.invoke(arg);
    }
    public static String[] getAll() throws Exception {
        String endpoint = "http://localhost:8080/axis/services/TestService";
        ServiceFactory servfact = ServiceFactory.newInstance();
        Service serv = servfact.createService(new QName("localhost"));
        Call cal = serv.createCall();
        cal.setTargetEndpointAddress(endpoint);
        cal.setOperationName(new QName("getAll"));
        Object[] arg = new Object[0];
        return (String[])cal.invoke(arg);
    }
    public static void main(String[] args) throws Exception {
        add("a");
        add("bb");
        add("ccc");
        String[] s = getAll();
        for(int i = 0; i < s.length; i++) {
            System.out.println(s[i]);
        }
    }
}
