package oracle.portal.sample.v2.devguide.webservices;

import oracle.soap.transport.http.OracleSOAPHTTPConnection;
import java.net.URL;
import org.apache.soap.Constants;
import org.apache.soap.Fault;
import org.apache.soap.SOAPException;
import org.apache.soap.rpc.Call;
import org.apache.soap.rpc.Parameter;
import org.apache.soap.rpc.Response;
import java.util.Vector;
import java.util.Properties;
/**
 * Generated by the Oracle9i JDeveloper Web Services Stub/Skeleton Generator.
 * Date Created: Tue Mar 19 23:08:47 PST 2002
 * Note: One or more of the types described by the WSDL document was not
 * understood (please refer to the help for a list of supported types). The
 * types that were not understood have been mapped to the "UnknownType"
 * placeholder. Use the WSDL document which was used to generate this
 * stub/skeleton to perform the type mapping manually.
 */

public class WeatherRetrieverStub
{
  public String endpoint = "http://services.xmethods.net:80/soap/servlet/rpcrouter";
  private OracleSOAPHTTPConnection m_httpConnection = null;

  public WeatherRetrieverStub()
  {
    m_httpConnection = new OracleSOAPHTTPConnection();
  }

  public Float GetTemperature(String zipCode) throws Exception
  {
    Float returnVal = null;

    URL endpointURL = new URL(endpoint);
    Call call = new Call();
    call.setSOAPTransport(m_httpConnection);
    call.setTargetObjectURI("urn:xmethods-Temperature");
    call.setMethodName("getTemp");
    call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
    Vector params = new Vector();
    params.addElement(new Parameter("zipcode", String.class, zipCode, null));
    call.setParams(params);

    Response response = call.invoke(endpointURL, "");

    if (!response.generatedFault())
    {
      Parameter result = response.getReturnValue();
      returnVal = (Float)result.getValue();
    }
    else
    {
      Fault fault = response.getFault();
      throw new SOAPException(fault.getFaultCode(), fault.getFaultString());
    }

    return returnVal;
  }
  public void setMaintainSession(boolean maintainSession)
  {
    m_httpConnection.setMaintainSession(maintainSession);
  }

  public boolean getMaintainSession()
  {
    return m_httpConnection.getMaintainSession();
  }

  public void setTransportProperties(Properties props)
  {
    m_httpConnection.setProperties(props);
  }

  public Properties getTransportProperties()
  {
    return m_httpConnection.getProperties();
  }
}
