FileDocCategorySizeDatePackage
TestAsyncCall.javaAPI DocApache Axis 1.43924Sat Apr 22 18:57:28 BST 2006test.client

TestAsyncCall

public class TestAsyncCall extends TestCase

Fields Summary
Constructors Summary
public TestAsyncCall(String name)

        super(name);
    
Methods Summary
protected voidsetup()

    
public static junit.framework.Testsuite()

        return new TestSuite(TestAsyncCall.class);
    
public voidtestAsyncCallbackWeatherService()

        final Call call = new Call(new URL("http://live.capescience.com:80/ccx/GlobalWeather"));
        call.setUseSOAPAction(true);
        call.setSOAPActionURI("capeconnect:GlobalWeather:StationInfo#listCountries");
        call.setTimeout(new Integer(15 * 1000));
        call.setOperationName(new javax.xml.namespace.QName("capeconnect:GlobalWeather:StationInfo", "listCountries"));
        final AsyncCall ac = new AsyncCall(call, new IAsyncCallback() {
            public void onCompletion(IAsyncResult result) {
                Status status = result.getStatus();
                System.out.println(".....FINISHED");
                if (status == Status.COMPLETED) {
                    String[] c = (String[]) result.getResponse();
                    System.out.println(c.length);
                    for (int i = 0; i < c.length; i++) {
                        System.out.println(c[i]);
                    }
                } else if (status == Status.EXCEPTION) {
                    result.getException().printStackTrace();
                }
                synchronized (call) {
                    call.notifyAll();
                }
            }
        });
        IAsyncResult result = ac.invoke(new Object[]{});
        System.out.println("STARTED....");
        synchronized (call) {
            call.wait(0);
        }
    
public voidtestAsyncPollWeatherService()

        Call call = new Call(new URL("http://live.capescience.com:80/ccx/GlobalWeather"));
        call.setUseSOAPAction(true);
        call.setSOAPActionURI("capeconnect:GlobalWeather:StationInfo#listCountries");
        call.setTimeout(new Integer(15 * 1000));
        call.setOperationName(new javax.xml.namespace.QName("capeconnect:GlobalWeather:StationInfo", "listCountries"));
        AsyncCall ac = new AsyncCall(call);
        IAsyncResult result = ac.invoke(new Object[]{});
        System.out.println("STARTED");
        Status status = null;
        while ((status = result.getStatus()) == Status.NONE) {
            System.out.print('.");
            Thread.sleep(50);
        }
        System.out.println("FINISHED");
        if (status == Status.COMPLETED) {
            String[] c = (String[]) result.getResponse();
            System.out.println(c.length);
            for (int i = 0; i < c.length; i++) {
                System.out.println(c[i]);
            }
        } else if (status == Status.EXCEPTION) {
            result.getException().printStackTrace();
        }