package gov.maine.node.client;
import oracle.soap.transport.http.OracleSOAPHTTPConnection;
import org.apache.soap.encoding.soapenc.BeanSerializer;
import org.apache.soap.encoding.SOAPMappingRegistry;
import org.apache.soap.util.xml.QName;
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 gov.maine.node.client.NodeDocument;
import java.util.Vector;
import java.util.Properties;
/**
 * Generated by the Oracle9i JDeveloper Web Services Stub/Skeleton Generator.
 * Date Created: Tue Nov 25 12:53:11 EST 2003
 * WSDL URL: 
 */

public class NetworkNodeStub 
{
  public NetworkNodeStub(String returnURL)//String returnURL
  {
    m_httpConnection = new OracleSOAPHTTPConnection();
    m_smr = new SOAPMappingRegistry();

    BeanSerializer beanSer = new BeanSerializer();
    m_smr.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("http://www.ExchangeNetwork.net/schema/v1.0/node.xsd", "NodeDocument"), gov.maine.node.client.NodeDocument.class, beanSer, beanSer);

    // *** Oracle SSL Workaround ***********************************  //
    // The next few lines are what makes SSL work for this Client
    System.setProperty("ssl.SocketFactory.provider","oracle.security.ssl.OracleSSLSocketFactoryImpl"); 
    System.setProperty("ssl.ServerSocketFactory.provider","oracle.security.ssl.OracleSSLServerSocketFactoryImpl"); 
    System.setProperty("java.protocol.handler.pkgs","HTTPClient");
    System.setProperty("oracle.wallet.location","<wallet_path_from_app_serv_admin>/<exported_wallet_file_name>"); 
    System.setProperty("oracle.wallet.password","<wallet_password>"); 
    // End of SSL code
    // **************************************************************  //    

    //switch the endpoint
    endpoint = returnURL;
  }

  public String endpoint = "https://test.epacdxnode.net/cdx/services/NetworkNodePortType_V10";
  private OracleSOAPHTTPConnection m_httpConnection = null;
  private SOAPMappingRegistry m_smr = null;

  public NodeDocument[] download(String securityToken, String transactionId, String dataflow, NodeDocument[] documents) throws Exception
  {
    NodeDocument[] returnVal = null;

    URL endpointURL = new URL(endpoint);
    Call call = new Call();
    call.setSOAPTransport(m_httpConnection);
    call.setTargetObjectURI("http://www.ExchangeNetwork.net/schema/v1.0/node.xsd");
    call.setMethodName("download");
    call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

    Vector params = new Vector();
    params.addElement(new Parameter("securityToken", java.lang.String.class, securityToken, null));
    params.addElement(new Parameter("transactionId", java.lang.String.class, transactionId, null));
    params.addElement(new Parameter("dataflow", java.lang.String.class, dataflow, null));
    params.addElement(new Parameter("documents", gov.maine.node.client.NodeDocument[].class, documents, null));
    call.setParams(params);

    call.setSOAPMappingRegistry(m_smr);

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

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

    return returnVal;
  }

  public String[] getServices(String securityToken, String serviceType) throws Exception
  {
    String[] returnVal = null;

    URL endpointURL = new URL(endpoint);
    Call call = new Call();
    call.setSOAPTransport(m_httpConnection);
    call.setTargetObjectURI("http://www.ExchangeNetwork.net/schema/v1.0/node.xsd");
    call.setMethodName("getServices");
    call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

    Vector params = new Vector();
    params.addElement(new Parameter("securityToken", java.lang.String.class, securityToken, null));
    params.addElement(new Parameter("serviceType", java.lang.String.class, serviceType, null));
    call.setParams(params);

    call.setSOAPMappingRegistry(m_smr);

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

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

    return returnVal;
  }

  public String authenticate(String userId, String credential, String authenticationMethod) throws Exception
  {
    String returnVal = null;

    URL endpointURL = new URL(endpoint);
    Call call = new Call();
    call.setSOAPTransport(m_httpConnection);
    call.setTargetObjectURI("http://www.ExchangeNetwork.net/schema/v1.0/node.xsd");
    call.setMethodName("authenticate");
    call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

    Vector params = new Vector();
    params.addElement(new Parameter("userId", java.lang.String.class, userId, null));
    params.addElement(new Parameter("credential", java.lang.String.class, credential, null));
    params.addElement(new Parameter("authenticationMethod", java.lang.String.class, authenticationMethod, null));
    call.setParams(params);

    call.setSOAPMappingRegistry(m_smr);

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

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

    return returnVal;
  }

  public String nodePing(String Hello) throws Exception
  {
    String returnVal = null;

    URL endpointURL = new URL(endpoint);
    Call call = new Call();
    call.setSOAPTransport(m_httpConnection);
    call.setTargetObjectURI("http://www.ExchangeNetwork.net/schema/v1.0/node.xsd");
    call.setMethodName("nodePing");
    call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

    Vector params = new Vector();
    params.addElement(new Parameter("Hello", java.lang.String.class, Hello, null));
    call.setParams(params);

    call.setSOAPMappingRegistry(m_smr);

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

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

    return returnVal;
  }

  public String submit(String securityToken, String transactionId, String dataflow, NodeDocument[] documents) throws Exception
  {
    String returnVal = null;
    
    URL endpointURL = new URL(endpoint);
    Call call = new Call();
    call.setSOAPTransport(m_httpConnection);
    call.setTargetObjectURI("http://www.ExchangeNetwork.net/schema/v1.0/node.xsd");
    call.setMethodName("submit");
    call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

    Vector params = new Vector();
    params.addElement(new Parameter("securityToken", java.lang.String.class, securityToken, null));
    params.addElement(new Parameter("transactionId", java.lang.String.class, transactionId, null));
    params.addElement(new Parameter("dataflow", java.lang.String.class, dataflow, null));
    params.addElement(new Parameter("documents", gov.maine.node.client.NodeDocument[].class, documents, null));
    call.setParams(params);

    call.setSOAPMappingRegistry(m_smr);

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

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

    return returnVal;
  }

  public String query(String securityToken, String request, Integer rowId, Integer maxRows, String[] parameters) throws Exception
  {
    String returnVal = null;

    URL endpointURL = new URL(endpoint);
    Call call = new Call();
    call.setSOAPTransport(m_httpConnection);
    call.setTargetObjectURI("http://www.ExchangeNetwork.net/schema/v1.0/node.xsd");
    call.setMethodName("query");
    call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

    Vector params = new Vector();
    params.addElement(new Parameter("securityToken", java.lang.String.class, securityToken, null));
    params.addElement(new Parameter("request", java.lang.String.class, request, null));
    params.addElement(new Parameter("rowId", java.lang.Integer.class, rowId, null));
    params.addElement(new Parameter("maxRows", java.lang.Integer.class, maxRows, null));
    params.addElement(new Parameter("parameters", java.lang.String[].class, parameters, null));
    call.setParams(params);

    call.setSOAPMappingRegistry(m_smr);

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

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

    return returnVal;
  }

  public String solicit(String securityToken, String returnURL, String request, String[] parameters) throws Exception
  {
    String returnVal = null;

    URL endpointURL = new URL(endpoint);
    Call call = new Call();
    call.setSOAPTransport(m_httpConnection);
    call.setTargetObjectURI("http://www.ExchangeNetwork.net/schema/v1.0/node.xsd");
    call.setMethodName("solicit");
    call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

    Vector params = new Vector();
    params.addElement(new Parameter("securityToken", java.lang.String.class, securityToken, null));
    params.addElement(new Parameter("returnURL", java.lang.String.class, returnURL, null));
    params.addElement(new Parameter("request", java.lang.String.class, request, null));
    params.addElement(new Parameter("parameters", java.lang.String[].class, parameters, null));
    call.setParams(params);

    call.setSOAPMappingRegistry(m_smr);

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

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

    return returnVal;
  }

  public String execute(String securityToken, String request, String[] parameters) throws Exception
  {
    String returnVal = null;

    URL endpointURL = new URL(endpoint);
    Call call = new Call();
    call.setSOAPTransport(m_httpConnection);
    call.setTargetObjectURI("http://www.ExchangeNetwork.net/schema/v1.0/node.xsd");
    call.setMethodName("execute");
    call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

    Vector params = new Vector();
    params.addElement(new Parameter("securityToken", java.lang.String.class, securityToken, null));
    params.addElement(new Parameter("request", java.lang.String.class, request, null));
    params.addElement(new Parameter("parameters", java.lang.String[].class, parameters, null));
    call.setParams(params);

    call.setSOAPMappingRegistry(m_smr);

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

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

    return returnVal;
  }

  public String notify(String securityToken, String nodeAddress, String dataflow, NodeDocument[] documents) throws Exception
  {
    String returnVal = null;

    URL endpointURL = new URL(endpoint);
    Call call = new Call();
    call.setSOAPTransport(m_httpConnection);
    call.setTargetObjectURI("http://www.ExchangeNetwork.net/schema/v1.0/node.xsd");
    call.setMethodName("notify");
    call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

    Vector params = new Vector();
    params.addElement(new Parameter("securityToken", java.lang.String.class, securityToken, null));
    params.addElement(new Parameter("nodeAddress", java.lang.String.class, nodeAddress, null));
    params.addElement(new Parameter("dataflow", java.lang.String.class, dataflow, null));
    params.addElement(new Parameter("documents", gov.maine.node.client.NodeDocument[].class, documents, null));
    call.setParams(params);

    call.setSOAPMappingRegistry(m_smr);

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

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

    return returnVal;
  }

  public String getStatus(String securityToken, String transactionId) throws Exception
  {
    String returnVal = null;

    URL endpointURL = new URL(endpoint);
    Call call = new Call();
    call.setSOAPTransport(m_httpConnection);
    call.setTargetObjectURI("http://www.ExchangeNetwork.net/schema/v1.0/node.xsd");
    call.setMethodName("getStatus");
    call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

    Vector params = new Vector();
    params.addElement(new Parameter("securityToken", java.lang.String.class, securityToken, null));
    params.addElement(new Parameter("transactionId", java.lang.String.class, transactionId, null));
    call.setParams(params);

    call.setSOAPMappingRegistry(m_smr);

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

    if (!response.generatedFault())
    {
      Parameter result = response.getReturnValue();
      returnVal = (String)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();
  }
}