You are here

function wsdl::wsdl in Salesforce Suite 5

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

constructor

@access public

Parameters

string $wsdl WSDL document URL: * @param string $proxyhost * @param string $proxyport * @param string $proxyusername * @param string $proxypassword * @param integer $timeout set the connection timeout * @param integer $response_timeout set the response timeout

File

includes/nusoap.php, line 4120

Class

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

Code

function wsdl($wsdl = '', $proxyhost = false, $proxyport = false, $proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30) {
  parent::nusoap_base();
  $this->wsdl = $wsdl;
  $this->proxyhost = $proxyhost;
  $this->proxyport = $proxyport;
  $this->proxyusername = $proxyusername;
  $this->proxypassword = $proxypassword;
  $this->timeout = $timeout;
  $this->response_timeout = $response_timeout;

  // parse wsdl file
  if ($wsdl != "") {
    $this
      ->debug('initial wsdl URL: ' . $wsdl);
    $this
      ->parseWSDL($wsdl);
  }

  // imports
  // TODO: handle imports more properly, grabbing them in-line and nesting them
  $imported_urls = array();
  $imported = 1;
  while ($imported > 0) {
    $imported = 0;

    // Schema imports
    foreach ($this->schemas as $ns => $list) {
      foreach ($list as $xs) {
        $wsdlparts = parse_url($this->wsdl);

        // this is bogusly simple!
        foreach ($xs->imports as $ns2 => $list2) {
          for ($ii = 0; $ii < count($list2); $ii++) {
            if (!$list2[$ii]['loaded']) {
              $this->schemas[$ns]->imports[$ns2][$ii]['loaded'] = true;
              $url = $list2[$ii]['location'];
              if ($url != '') {
                $urlparts = parse_url($url);
                if (!isset($urlparts['host'])) {
                  $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' . $wsdlparts['port'] : '') . substr($wsdlparts['path'], 0, strrpos($wsdlparts['path'], '/') + 1) . $urlparts['path'];
                }
                if (!in_array($url, $imported_urls)) {
                  $this
                    ->parseWSDL($url);
                  $imported++;
                  $imported_urls[] = $url;
                }
              }
              else {
                $this
                  ->debug("Unexpected scenario: empty URL for unloaded import");
              }
            }
          }
        }
      }
    }

    // WSDL imports
    $wsdlparts = parse_url($this->wsdl);

    // this is bogusly simple!
    foreach ($this->import as $ns => $list) {
      for ($ii = 0; $ii < count($list); $ii++) {
        if (!$list[$ii]['loaded']) {
          $this->import[$ns][$ii]['loaded'] = true;
          $url = $list[$ii]['location'];
          if ($url != '') {
            $urlparts = parse_url($url);
            if (!isset($urlparts['host'])) {
              $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' . $wsdlparts['port'] : '') . substr($wsdlparts['path'], 0, strrpos($wsdlparts['path'], '/') + 1) . $urlparts['path'];
            }
            if (!in_array($url, $imported_urls)) {
              $this
                ->parseWSDL($url);
              $imported++;
              $imported_urls[] = $url;
            }
          }
          else {
            $this
              ->debug("Unexpected scenario: empty URL for unloaded import");
          }
        }
      }
    }
  }

  // add new data to operation data
  foreach ($this->bindings as $binding => $bindingData) {
    if (isset($bindingData['operations']) && is_array($bindingData['operations'])) {
      foreach ($bindingData['operations'] as $operation => $data) {
        $this
          ->debug('post-parse data gathering for ' . $operation);
        $this->bindings[$binding]['operations'][$operation]['input'] = isset($this->bindings[$binding]['operations'][$operation]['input']) ? array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[$bindingData['portType']][$operation]['input']) : $this->portTypes[$bindingData['portType']][$operation]['input'];
        $this->bindings[$binding]['operations'][$operation]['output'] = isset($this->bindings[$binding]['operations'][$operation]['output']) ? array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[$bindingData['portType']][$operation]['output']) : $this->portTypes[$bindingData['portType']][$operation]['output'];
        if (isset($this->messages[$this->bindings[$binding]['operations'][$operation]['input']['message']])) {
          $this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[$this->bindings[$binding]['operations'][$operation]['input']['message']];
        }
        if (isset($this->messages[$this->bindings[$binding]['operations'][$operation]['output']['message']])) {
          $this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[$this->bindings[$binding]['operations'][$operation]['output']['message']];
        }
        if (isset($bindingData['style'])) {
          $this->bindings[$binding]['operations'][$operation]['style'] = $bindingData['style'];
        }
        $this->bindings[$binding]['operations'][$operation]['transport'] = isset($bindingData['transport']) ? $bindingData['transport'] : '';
        $this->bindings[$binding]['operations'][$operation]['documentation'] = isset($this->portTypes[$bindingData['portType']][$operation]['documentation']) ? $this->portTypes[$bindingData['portType']][$operation]['documentation'] : '';
        $this->bindings[$binding]['operations'][$operation]['endpoint'] = isset($bindingData['endpoint']) ? $bindingData['endpoint'] : '';
      }
    }
  }
}