FileDocCategorySizeDatePackage
WeatherDiary.javaAPI DocExample1208Tue Jan 15 11:35:48 GMT 2002javasoap.book.ch8

WeatherDiary

public class WeatherDiary extends Object

Fields Summary
Hashtable
_diary
Constructors Summary
Methods Summary
public voidrecordTemperature(Envelope env, org.apache.soap.rpc.SOAPContext reqCtx, org.apache.soap.rpc.SOAPContext resCtx)


          
                       
              
   
      Vector v = env.getBody().getBodyEntries();      
      int cnt = v.size();
      String zipcode = null;
      String temperature = null;
      for (int i = 0; i < cnt; i++) {
         Element e = (Element)v.elementAt(i);
         String name = e.getTagName();
         if (name.equals("zipcode")) {
            zipcode = e.getFirstChild().getNodeValue();
         }
         else if (name.equals("temperature")) {
            temperature = e.getFirstChild().getNodeValue();
         }
      }

      if (zipcode == null || temperature == null) {
         throw new IllegalArgumentException(
               "ZIPCODE and/or TEMPERATURE Not Specified");
      }

      _diary.put(zipcode, temperature);

      resCtx.setRootPart("OK", "text/xml");