FileDocCategorySizeDatePackage
Apache2DotNet.javaAPI DocExample2417Tue Jan 15 12:14:48 GMT 2002javasoap.book.ch9.clients

Apache2DotNet

public class Apache2DotNet extends Object

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

      
      URL url = 
           new URL("http://mindstrm.com:8199/CorpDataService/Proxy.asmx");

      SOAPMappingRegistry smr = new SOAPMappingRegistry();

      BeanSerializer beanSer = new BeanSerializer();

      smr.mapTypes(Constants.NS_URI_SOAP_ENC,
new QName("http://www.themindelectric.com/package/javasoap.book.ch9.services/", 
                 "Quote"),
                 Quote.class, beanSer, beanSer);
    
      Call call = new Call();
      call.setSOAPMappingRegistry(smr);
      call.setTargetObjectURI("http://mindstrm.com/CorpDataService");
      call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

      String stock = args[0];

      Vector params = new Vector();
      params.addElement(new Parameter("symbol", 
                                 String.class, stock, null));
      call.setParams(params);
      
      try {
         call.setMethodName("getQuote");
         Response resp = call.invoke(url, 
               "http://mindstrm.com/CorpDataService/getQuote");

         if (resp.generatedFault()) {
            Fault fault = resp.getFault();
            String code = fault.getFaultCode();
            String desc = fault.getFaultString();
            System.out.println(code + ": " + desc);

            Vector v = fault.getDetailEntries();
            int cnt = v.size();
            for (int i = 0; i < cnt; i++) {
               Element n = (Element)v.elementAt(i);
               Node nd = n.getFirstChild();
               System.out.println(n.getNodeName() + ": " + 
                                                nd.getNodeValue());   
            }   
         }
         else { 
            Parameter ret = resp.getReturnValue();
            Quote value = (Quote)ret.getValue();
            System.out.println(value);
         }
      }
      catch (SOAPException e) {
         System.err.println("Caught SOAPException (" +
                         e.getFaultCode() + "): " +
                         e.getMessage());
      }