package dt.soap.EchoService;

import java.io.*;
import org.w3c.dom.*;
import org.apache.soap.*;
import org.apache.soap.encoding.soapenc.*;
import org.apache.soap.rpc.*;
import org.apache.soap.util.*;
import org.apache.soap.util.xml.*;

import java.net.URL;
import dt.soap.EchoService.*;

public class MyClassDeserializer implements Deserializer
{
  public Bean unmarshall(String inScopeEncStyle, QName elementType, Node src,
                         XMLJavaMappingRegistry xjmr, SOAPContext ctx)
                          throws IllegalArgumentException
  {
      Element root = (Element)src;
      Element tempEl = DOMUtils.getFirstChildElement(root);
      MyClass mc = new MyClass();
      
      while (tempEl != null)
      {
	  Bean bean = xjmr.unmarshall(inScopeEncStyle, RPCConstants.Q_ELEM_PARAMETER, tempEl, ctx);
          Parameter param = (Parameter)bean.value;
          String tagName = tempEl.getTagName();
        
          if (tagName.equals("name"))
          {
	      mc.setName((String)param.getValue());
          }
                    
          if (tagName.equals("location"))
          {
	      mc.setLocation((URL)param.getValue());
          }
                   
          tempEl = DOMUtils.getNextSiblingElement(tempEl);
      }

      return new Bean(MyClass.class, mc);

  }
}
