You are here

function soap_server::service in Salesforce Suite 5

Same name in this branch
  1. 5 includes/nusoap.php \soap_server::service()
  2. 5 includes/nusoap.orig.php \soap_server::service()
Same name and namespace in other branches
  1. 5.2 includes/nusoap.php \soap_server::service()
  2. 5.2 includes/nusoap.orig.php \soap_server::service()

* processes request and returns response * *

Parameters

string $data usually is the value of $HTTP_RAW_POST_DATA: * @access public

File

includes/nusoap.orig.php, line 3251

Class

soap_server
soap_server allows the user to create a SOAP server that is capable of receiving messages and returning responses

Code

function service($data) {
  global $HTTP_SERVER_VARS;
  if (isset($_SERVER['QUERY_STRING'])) {
    $qs = $_SERVER['QUERY_STRING'];
  }
  elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
    $qs = $HTTP_SERVER_VARS['QUERY_STRING'];
  }
  else {
    $qs = '';
  }
  $this
    ->debug("In service, query string={$qs}");
  if (ereg('wsdl', $qs)) {
    $this
      ->debug("In service, this is a request for WSDL");
    if ($this->externalWSDLURL) {
      if (strpos($this->externalWSDLURL, "://") !== false) {

        // assume URL
        header('Location: ' . $this->externalWSDLURL);
      }
      else {

        // assume file
        header("Content-Type: text/xml\r\n");
        $fp = fopen($this->externalWSDLURL, 'r');
        fpassthru($fp);
      }
    }
    elseif ($this->wsdl) {
      header("Content-Type: text/xml; charset=ISO-8859-1\r\n");
      print $this->wsdl
        ->serialize($this->debug_flag);
      if ($this->debug_flag) {
        $this
          ->debug('wsdl:');
        $this
          ->appendDebug($this
          ->varDump($this->wsdl));
        print $this
          ->getDebugAsXMLComment();
      }
    }
    else {
      header("Content-Type: text/html; charset=ISO-8859-1\r\n");
      print "This service does not provide WSDL";
    }
  }
  elseif ($data == '' && $this->wsdl) {
    $this
      ->debug("In service, there is no data, so return Web description");
    print $this->wsdl
      ->webDescription();
  }
  else {
    $this
      ->debug("In service, invoke the request");
    $this
      ->parse_request($data);
    if (!$this->fault) {
      $this
        ->invoke_method();
    }
    if (!$this->fault) {
      $this
        ->serialize_return();
    }
    $this
      ->send_response();
  }
}