You are here

function soap_server::serialize_return in Salesforce Suite 5.2

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

* serializes the return value from a PHP function into a full SOAP Envelope * * The following fields are set by this function (when successful) * * responseSOAP * * This sets the fault field on error * * @access private

2 calls to soap_server::serialize_return()
soap_server::service in includes/nusoap.php
* processes request and returns response * *
soap_server::service in includes/nusoap.orig.php
* processes request and returns response * *

File

includes/nusoap.php, line 3625

Class

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

Code

function serialize_return() {
  $this
    ->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);

  // if fault
  if (isset($this->methodreturn) && get_class($this->methodreturn) == 'soap_fault') {
    $this
      ->debug('got a fault object from method');
    $this->fault = $this->methodreturn;
    return;
  }
  elseif ($this->methodreturnisliteralxml) {
    $return_val = $this->methodreturn;

    // returned value(s)
  }
  else {
    $this
      ->debug('got a(n) ' . gettype($this->methodreturn) . ' from method');
    $this
      ->debug('serializing return value');
    if ($this->wsdl) {

      // weak attempt at supporting multiple output params
      if (sizeof($this->opData['output']['parts']) > 1) {
        $opParams = $this->methodreturn;
      }
      else {

        // TODO: is this really necessary?
        $opParams = array(
          $this->methodreturn,
        );
      }
      $return_val = $this->wsdl
        ->serializeRPCParameters($this->methodname, 'output', $opParams);
      $this
        ->appendDebug($this->wsdl
        ->getDebug());
      $this->wsdl
        ->clearDebug();
      if ($errstr = $this->wsdl
        ->getError()) {
        $this
          ->debug('got wsdl error: ' . $errstr);
        $this
          ->fault('Server', 'unable to serialize result');
        return;
      }
    }
    else {
      if (isset($this->methodreturn)) {
        $return_val = $this
          ->serialize_val($this->methodreturn, 'return');
      }
      else {
        $return_val = '';
        $this
          ->debug('in absence of WSDL, assume void return for backward compatibility');
      }
    }
  }
  $this
    ->debug('return value:');
  $this
    ->appendDebug($this
    ->varDump($return_val));
  $this
    ->debug('serializing response');
  if ($this->wsdl) {
    $this
      ->debug('have WSDL for serialization: style is ' . $this->opData['style']);
    if ($this->opData['style'] == 'rpc') {
      $this
        ->debug('style is rpc for serialization: use is ' . $this->opData['output']['use']);
      if ($this->opData['output']['use'] == 'literal') {
        $payload = '<' . $this->methodname . 'Response xmlns="' . $this->methodURI . '">' . $return_val . '</' . $this->methodname . "Response>";
      }
      else {
        $payload = '<ns1:' . $this->methodname . 'Response xmlns:ns1="' . $this->methodURI . '">' . $return_val . '</ns1:' . $this->methodname . "Response>";
      }
    }
    else {
      $this
        ->debug('style is not rpc for serialization: assume document');
      $payload = $return_val;
    }
  }
  else {
    $this
      ->debug('do not have WSDL for serialization: assume rpc/encoded');
    $payload = '<ns1:' . $this->methodname . 'Response xmlns:ns1="' . $this->methodURI . '">' . $return_val . '</ns1:' . $this->methodname . "Response>";
  }
  $this->result = 'successful';
  if ($this->wsdl) {

    //if($this->debug_flag){
    $this
      ->appendDebug($this->wsdl
      ->getDebug());

    //	}
    if (isset($opData['output']['encodingStyle'])) {
      $encodingStyle = $opData['output']['encodingStyle'];
    }
    else {
      $encodingStyle = '';
    }

    // Added: In case we use a WSDL, return a serialized env. WITH the usedNamespaces.
    $this->responseSOAP = $this
      ->serializeEnvelope($payload, $this->responseHeaders, $this->wsdl->usedNamespaces, $this->opData['style'], $encodingStyle);
  }
  else {
    $this->responseSOAP = $this
      ->serializeEnvelope($payload, $this->responseHeaders);
  }
  $this
    ->debug("Leaving serialize_return");
}