You are here

function wsdl::addOperation in Salesforce Suite 5.2

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

* register an operation with the server * *

Parameters

string $name operation (method) name: * @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 string $namespace optional The namespace for the operation * @param string $soapaction optional The soapaction for the operation * @param string $style (rpc|document) optional The style for the operation Note: when 'document' is specified, parameter and return wrappers are created for you automatically * @param string $use (encoded|literal) optional The use for the parameters (cannot mix right now) * @param string $documentation optional The description to include in the WSDL * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) * @access public

File

includes/nusoap.orig.php, line 5705

Class

wsdl
parses a WSDL file, allows access to it's data, other utility methods

Code

function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = '') {
  if ($use == 'encoded' && $encodingStyle == '') {
    $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
  }
  if ($style == 'document') {
    $elements = array();
    foreach ($in as $n => $t) {
      $elements[$n] = array(
        'name' => $n,
        'type' => $t,
      );
    }
    $this
      ->addComplexType($name . 'RequestType', 'complexType', 'struct', 'all', '', $elements);
    $this
      ->addElement(array(
      'name' => $name,
      'type' => $name . 'RequestType',
    ));
    $in = array(
      'parameters' => 'tns:' . $name,
    );
    $elements = array();
    foreach ($out as $n => $t) {
      $elements[$n] = array(
        'name' => $n,
        'type' => $t,
      );
    }
    $this
      ->addComplexType($name . 'ResponseType', 'complexType', 'struct', 'all', '', $elements);
    $this
      ->addElement(array(
      'name' => $name . 'Response',
      'type' => $name . 'ResponseType',
    ));
    $out = array(
      'parameters' => 'tns:' . $name . 'Response',
    );
  }

  // get binding
  $this->bindings[$this->serviceName . 'Binding']['operations'][$name] = array(
    'name' => $name,
    'binding' => $this->serviceName . 'Binding',
    'endpoint' => $this->endpoint,
    'soapAction' => $soapaction,
    'style' => $style,
    'input' => array(
      'use' => $use,
      'namespace' => $namespace,
      'encodingStyle' => $encodingStyle,
      'message' => $name . 'Request',
      'parts' => $in,
    ),
    'output' => array(
      'use' => $use,
      'namespace' => $namespace,
      'encodingStyle' => $encodingStyle,
      'message' => $name . 'Response',
      'parts' => $out,
    ),
    'namespace' => $namespace,
    'transport' => 'http://schemas.xmlsoap.org/soap/http',
    'documentation' => $documentation,
  );

  // add portTypes
  // add messages
  if ($in) {
    foreach ($in as $pName => $pType) {
      if (strpos($pType, ':')) {
        $pType = $this
          ->getNamespaceFromPrefix($this
          ->getPrefix($pType)) . ":" . $this
          ->getLocalPart($pType);
      }
      $this->messages[$name . 'Request'][$pName] = $pType;
    }
  }
  else {
    $this->messages[$name . 'Request'] = '0';
  }
  if ($out) {
    foreach ($out as $pName => $pType) {
      if (strpos($pType, ':')) {
        $pType = $this
          ->getNamespaceFromPrefix($this
          ->getPrefix($pType)) . ":" . $this
          ->getLocalPart($pType);
      }
      $this->messages[$name . 'Response'][$pName] = $pType;
    }
  }
  else {
    $this->messages[$name . 'Response'] = '0';
  }
  return true;
}