You are here

function soap_server::register in Salesforce Suite 5

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

* register a service function with the server * *

Parameters

string $name the name of the PHP function, class.method or class..method: * @param array $in assoc array of input values: key = param name, value = param type * @param array $out assoc array of output values: key = param name, value = param type * @param mixed $namespace the element namespace for the method or false * @param mixed $soapaction the soapaction for the method or false * @param mixed $style optional (rpc|document) or false Note: when 'document' is specified, parameter and return wrappers are created for you automatically * @param mixed $use optional (encoded|literal) or false * @param string $documentation optional Description to include in WSDL * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) * @access public

File

includes/nusoap.php, line 3915

Class

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

Code

function register($name, $in = [], $out = [], $namespace = false, $soapaction = false, $style = false, $use = false, $documentation = '', $encodingStyle = '') {
  global $HTTP_SERVER_VARS;
  if ($this->externalWSDLURL) {
    die('You cannot bind to an external WSDL file, and register methods outside of it! Please choose either WSDL or no WSDL.');
  }
  if (!$name) {
    die('You must specify a name when you register an operation');
  }
  if (!is_array($in)) {
    die('You must provide an array for operation inputs');
  }
  if (!is_array($out)) {
    die('You must provide an array for operation outputs');
  }
  if (false == $namespace) {
  }
  if (false == $soapaction) {
    if (isset($_SERVER)) {
      $SERVER_NAME = $_SERVER['SERVER_NAME'];
      $SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME'];
    }
    elseif (isset($HTTP_SERVER_VARS)) {
      $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME'];
      $SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];
    }
    else {
      $this
        ->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
    }
    $soapaction = "http://{$SERVER_NAME}{$SCRIPT_NAME}/{$name}";
  }
  if (false == $style) {
    $style = "rpc";
  }
  if (false == $use) {
    $use = "encoded";
  }
  if ($use == 'encoded' && ($encodingStyle = '')) {
    $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
  }
  $this->operations[$name] = array(
    'name' => $name,
    'in' => $in,
    'out' => $out,
    'namespace' => $namespace,
    'soapaction' => $soapaction,
    'style' => $style,
  );
  if ($this->wsdl) {
    $this->wsdl
      ->addOperation($name, $in, $out, $namespace, $soapaction, $style, $use, $documentation, $encodingStyle);
  }
  return true;
}