<?php
include("nb_easyxml_lite.php");
include("nb_soapfuncs.php");

/********* Data structures used by this web service *********
*
* type GetHitResult{
*     ['factor']=>{
*     }
*     ['value']=>{
*     }
* }
*
*/

class service extends service_nbSOAP
{
    var $Url;

/**
* web service provider method GetHit
* 
* @param timeout : unsigned
* @return GetHitResult 
*/
    function GetHit($timeout)
    {
    	return new nbSOAPFault("unimplemented", "The GetHitservice has not been implemented yet", "");
        // Fill in web method fuctionality here.
        // return a GetHitResult
    }

}

/********************* Do not alter the generated code below ************************/

if($_SERVER['REQUEST_METHOD']=="GET")
{
  echo "information call, front page, WSDL or function info. ";
  echo "All this functionality still has to be written...";
}
else
{
    $in = file_get_contents("php://input");
    $action = $_SERVER['HTTP_SOAPACTION'];
    $action = str_replace("\\\"","",$action);
    $SoapClass = new service();
    $soapXML = $SoapClass->PerformSoapAction($in, $action);
    $soapXML = nbSOAP_Envelope($soapXML);
    header("Content-Type: text/xml; charset=utf-8");
    echo $soapXML;
}

class service_nbSOAP //extends nbSOAP
{
    function PerformSoapAction($in, $action)
    {
        $xml = nb_easyxmldoc($in);
        $body = $xml->findElement("Body", 0, "http://schemas.xmlsoap.org/soap/envelope/");
        if($body == false)
            return "<soap:Fault><faultstring>SOAP body not found</faultstring></soap:Fault>";
        $params = $xml->findChildElement($body);
        switch($action)
        {
        case "http://localhost:8080/dart/GetHit":
            // deserialize parameters
            $pidx = $xml->findChildElement($params, "timeout");
            if($pidx != false)
              $p_timeout = $this->desoap_unsigned($xml, $pidx, "timeout");
            else
                $p_timeout = null;
            // call the method
            $res = $this->GetHit($p_timeout);
            if(is_a($res,"nbSOAPFault"))
            {
                return "<soap:Body>\n" . $res->soapify() . "</soap:Body>";
            }
            // serialize the result
            $soapXML = $this->soapify_GetHitResult($res, "GetHit");
            $soapXML = "<GetHitResponse xmlns=\"http://localhost:8080/dart\">" . $soapXML;
            $soapXML .= "</GetHitResponse>";
            return "<soap:Body>\n" . $soapXML . "</soap:Body>";
            break;
        default:
            return "<soap:Fault><faultstring>Unrecognised SOAP action called.</faultstring></soap:Fault>";
            break;
        }
    }

}
?>