FileDocCategorySizeDatePackage
DataFeedClient2.javaAPI DocExample1928Wed Feb 27 09:56:02 GMT 2002javasoap.book.ch6

DataFeedClient2

public class DataFeedClient2 extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

      
      URL url = 
        new URL(
          "http://georgetown:8080/soap/servlet/rpcrouter");
    
      Call call = new Call();
      
      BetterSOAPMappingRegistry smr = 
                        new BetterSOAPMappingRegistry();
      call.setTargetObjectURI("urn:DataFeedService");
      call.setMethodName("echoStocks");
      call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
      call.setSOAPMappingRegistry(smr);
      SparseArraySerializer arraySer = 
                        new SparseArraySerializer();
      // Map the array
      smr.mapTypes(Constants.NS_URI_SOAP_ENC,
                 new QName(Constants.NS_URI_SOAP_ENC, "Array"),
                 java.lang.reflect.Array.class, arraySer, 
                 arraySer);
      String[] stocks = new String[10];
      stocks[2] = "XYZ";
      stocks[5] = "ABC";
      Vector params = new Vector();
      params.addElement(new Parameter("msg", String[].class, 
                               stocks, null));
      call.setParams(params);
      
      try {
         Response resp = call.invoke(url, "");
         Parameter ret = resp.getReturnValue();
         String[] value = (String[])ret.getValue();
         int cnt = value.length;
         for (int i = 0; i < cnt; i++) {
            if (value[i] != null) {
               System.out.println("Item " + i + ": " + value[i]);
            }
         }
      }
      catch (SOAPException e) {
         System.err.println("Caught SOAPException (" +
                         e.getFaultCode() + "): " +
                         e.getMessage());
      }