ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
soap_transport_http Class Reference

transport class for sending/receiving data via HTTP and HTTPS NOTE: PHP must be compiled with the CURL extension for HTTPS support More...

+ Inheritance diagram for soap_transport_http:
+ Collaboration diagram for soap_transport_http:

Public Member Functions

 __construct ($url, $curl_options=null, $use_curl=false)
 constructor More...
 
 setCurlOption ($option, $value)
 sets a cURL option More...
 
 setHeader ($name, $value)
 sets an HTTP header More...
 
 unsetHeader ($name)
 unsets an HTTP header More...
 
 setURL ($url)
 sets the URL to which to connect More...
 
 io_method ()
 gets the I/O method to use More...
 
 connect ($connection_timeout=0, $response_timeout=30)
 establish an HTTP connection More...
 
 send ($data, $timeout=0, $response_timeout=30, $cookies=null)
 sends the SOAP request and gets the SOAP response via HTTP[S] More...
 
 sendHTTPS ($data, $timeout=0, $response_timeout=30, $cookies=null)
 sends the SOAP request and gets the SOAP response via HTTPS using CURL More...
 
 setCredentials ($username, $password, $authtype='basic', $digestRequest=array(), $certRequest=array())
 if authenticating, set user credentials here More...
 
 setSOAPAction ($soapaction)
 set the soapaction value More...
 
 setEncoding ($enc='gzip, deflate')
 use http encoding More...
 
 setProxy ($proxyhost, $proxyport, $proxyusername='', $proxypassword='', $proxyauthtype='basic')
 set proxy info here More...
 
 isSkippableCurlHeader (&$data)
 Test if the given string starts with a header that is to be skipped. More...
 
 decodeChunked ($buffer, $lb)
 decode a string that is encoded w/ "chunked' transfer encoding as defined in RFC2068 19.4.6 More...
 
 buildPayload ($data, $cookie_str='')
 Writes the payload, including HTTP headers, to $this->outgoing_payload. More...
 
 sendRequest ($data, $cookies=null)
 sends the SOAP request via HTTP[S] More...
 
 getResponse ()
 gets the SOAP response via HTTP[S] More...
 
 setContentType ($type, $charset=false)
 sets the content-type for the SOAP message to be sent More...
 
 usePersistentConnection ()
 specifies that an HTTP persistent connection should be used More...
 
 parseCookie ($cookie_str)
 parse an incoming Cookie into it's parts More...
 
 getCookiesForRequest ($cookies, $secure=false)
 sort out cookies for the current request More...
 
- Public Member Functions inherited from nusoap_base
 __construct ()
 constructor More...
 
 getGlobalDebugLevel ()
 gets the global debug level, which applies to future instances More...
 
 setGlobalDebugLevel ($level)
 sets the global debug level, which applies to future instances More...
 
 getDebugLevel ()
 gets the debug level for this instance More...
 
 setDebugLevel ($level)
 sets the debug level for this instance More...
 
 debug ($string)
 adds debug data to the instance debug string with formatting More...
 
 appendDebug ($string)
 adds debug data to the instance debug string without formatting More...
 
 clearDebug ()
 clears the current debug data for this instance More...
 
getDebug ()
 gets the current debug data for this instance More...
 
getDebugAsXMLComment ()
 gets the current debug data for this instance as an XML comment this may change the contents of the debug data More...
 
 expandEntities ($val)
 expands entities, e.g. More...
 
 getError ()
 returns error string if present More...
 
 setError ($str)
 sets error string More...
 
 isArraySimpleOrStruct ($val)
 detect if array is a simple array or a struct (associative array) More...
 
 serialize_val ($val, $name=false, $type=false, $name_ns=false, $type_ns=false, $attributes=false, $use='encoded', $soapval=false)
 serializes PHP values in accordance w/ section 5. More...
 
 serializeEnvelope ($body, $headers=false, $namespaces=array(), $style='rpc', $use='encoded', $encodingStyle='http://schemas.xmlsoap.org/soap/encoding/')
 serializes a message More...
 
 formatDump ($str)
 formats a string to be inserted into an HTML stream More...
 
 contractQname ($qname)
 contracts (changes namespace to prefix) a qualified name More...
 
 expandQname ($qname)
 expands (changes prefix to namespace) a qualified name More...
 
 getLocalPart ($str)
 returns the local part of a prefixed string returns the original string, if not prefixed More...
 
 getPrefix ($str)
 returns the prefix part of a prefixed string returns false, if not prefixed More...
 
 getNamespaceFromPrefix ($prefix)
 pass it a prefix, it returns a namespace More...
 
 getPrefixFromNamespace ($ns)
 returns the prefix for a given namespace (or prefix) or false if no prefixes registered for the given namespace More...
 
 getmicrotime ()
 returns the time in ODBC canonical form with microseconds More...
 
 varDump ($data)
 Returns a string with the output of var_dump. More...
 
 __toString ()
 represents the object as a string More...
 

Data Fields

 $url = ''
 
 $uri = ''
 
 $digest_uri = ''
 
 $scheme = ''
 
 $host = ''
 
 $port = ''
 
 $path = ''
 
 $request_method = 'POST'
 
 $protocol_version = '1.0'
 
 $encoding = ''
 
 $outgoing_headers = array()
 
 $incoming_headers = array()
 
 $incoming_cookies = array()
 
 $outgoing_payload = ''
 
 $incoming_payload = ''
 
 $response_status_line
 
 $useSOAPAction = true
 
 $persistentConnection = false
 
 $ch = false
 
 $ch_options = array()
 
 $use_curl = false
 
 $proxy = null
 
 $username = ''
 
 $password = ''
 
 $authtype = ''
 
 $digestRequest = array()
 
 $certRequest = array()
 
- Data Fields inherited from nusoap_base
 $title = 'NuSOAP'
 
 $version = '0.7.3'
 
 $revision = '$Revision$'
 
 $error_str = ''
 
 $debug_str = ''
 
 $charencoding = true
 
 $debugLevel
 
 $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema'
 
 $soap_defencoding = 'UTF-8'
 
 $namespaces
 
 $usedNamespaces = array()
 
 $typemap
 
 $xmlEntities
 

Detailed Description

transport class for sending/receiving data via HTTP and HTTPS NOTE: PHP must be compiled with the CURL extension for HTTPS support

Author
Dietrich Ayala dietr.nosp@m.ich@.nosp@m.ganx4.nosp@m..com
Scott Nichol snich.nosp@m.ol@u.nosp@m.sers..nosp@m.sour.nosp@m.cefor.nosp@m.ge.n.nosp@m.et
Version
$Id$ public

Definition at line 2185 of file nusoap.php.

Constructor & Destructor Documentation

◆ __construct()

soap_transport_http::__construct (   $url,
  $curl_options = null,
  $use_curl = false 
)

constructor

Parameters
string$urlThe URL to which to connect
array$curl_optionsUser-specified cURL options
boolean$use_curlWhether to try to force cURL use public

Definition at line 2230 of file nusoap.php.

References $url, ILIAS\MetaData\Repository\Validation\Data\__construct(), nusoap_base\appendDebug(), nusoap_base\debug(), and nusoap_base\varDump().

2231  {
2233  $this->debug("ctor url=$url use_curl=$use_curl curl_options:");
2234  $this->appendDebug($this->varDump($curl_options));
2235  $this->setURL($url);
2236  if (is_array($curl_options)) {
2237  $this->ch_options = $curl_options;
2238  }
2239  $this->use_curl = $use_curl;
2240  preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
2241  // begin-patch php8
2242  $this->setHeader('User-Agent', $this->title . '/' . $this->version . ' (' . ($rev[1] ?? '1.1') . ')');
2243  }
appendDebug($string)
adds debug data to the instance debug string without formatting
Definition: nusoap.php:305
setHeader($name, $value)
sets an HTTP header
Definition: nusoap.php:2266
setURL($url)
sets the URL to which to connect
Definition: nusoap.php:2292
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:292
__construct(VocabulariesInterface $vocabularies)
varDump($data)
Returns a string with the output of var_dump.
Definition: nusoap.php:909
+ Here is the call graph for this function:

Member Function Documentation

◆ buildPayload()

soap_transport_http::buildPayload (   $data,
  $cookie_str = '' 
)

Writes the payload, including HTTP headers, to $this->outgoing_payload.

Parameters
string$dataHTTP body
string$cookie_strdata for HTTP Cookie header
Returns
void private

Definition at line 2883 of file nusoap.php.

References $data, XapiProxy\$req, $url, and nusoap_base\debug().

2884  {
2885  // Note: for cURL connections, $this->outgoing_payload is ignored,
2886  // as is the Content-Length header, but these are still created as
2887  // debugging guides.
2888 
2889  // add content-length header
2890  $this->setHeader('Content-Length', strlen($data));
2891 
2892  // start building outgoing payload:
2893  if ($this->proxy) {
2894  $uri = $this->url;
2895  } else {
2896  $uri = $this->uri;
2897  }
2898  $req = "$this->request_method $uri HTTP/$this->protocol_version";
2899  $this->debug("HTTP request: $req");
2900  $this->outgoing_payload = "$req\r\n";
2901 
2902  // loop thru headers, serializing
2903  foreach ($this->outgoing_headers as $k => $v) {
2904  $hdr = $k . ': ' . $v;
2905  $this->debug("HTTP header: $hdr");
2906  $this->outgoing_payload .= "$hdr\r\n";
2907  }
2908 
2909  // add any cookies
2910  if ($cookie_str != '') {
2911  $hdr = 'Cookie: ' . $cookie_str;
2912  $this->debug("HTTP header: $hdr");
2913  $this->outgoing_payload .= "$hdr\r\n";
2914  }
2915 
2916  // header/body separator
2917  $this->outgoing_payload .= "\r\n";
2918 
2919  // add data
2920  $this->outgoing_payload .= $data;
2921  }
setHeader($name, $value)
sets an HTTP header
Definition: nusoap.php:2266
catch(\Exception $e) $req
Definition: xapiproxy.php:93
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:292
+ Here is the call graph for this function:

◆ connect()

soap_transport_http::connect (   $connection_timeout = 0,
  $response_timeout = 30 
)

establish an HTTP connection

Parameters
integer$timeoutset connection timeout in seconds
integer$response_timeoutset response timeout in seconds
Returns
boolean true if connected, false if not private

Definition at line 2356 of file nusoap.php.

References nusoap_base\$error_str, $path, $url, nusoap_base\appendDebug(), nusoap_base\debug(), nusoap_base\setError(), and nusoap_base\varDump().

2357  {
2358  // For PHP 4.3 with OpenSSL, change https scheme to ssl, then treat like
2359  // "regular" socket.
2360  // TODO: disabled for now because OpenSSL must be *compiled* in (not just
2361  // loaded), and until PHP5 stream_get_wrappers is not available.
2362  // if ($this->scheme == 'https') {
2363  // if (version_compare(phpversion(), '4.3.0') >= 0) {
2364  // if (extension_loaded('openssl')) {
2365  // $this->scheme = 'ssl';
2366  // $this->debug('Using SSL over OpenSSL');
2367  // }
2368  // }
2369  // }
2370  $this->debug("connect connection_timeout $connection_timeout, response_timeout $response_timeout, scheme $this->scheme, host $this->host, port $this->port");
2371  if ($this->io_method() == 'socket') {
2372  if (!is_array($this->proxy)) {
2373  $host = $this->host;
2374  $port = $this->port;
2375  } else {
2376  $host = $this->proxy['host'];
2377  $port = $this->proxy['port'];
2378  }
2379 
2380  // use persistent connection
2381  if ($this->persistentConnection && isset($this->fp) && is_resource($this->fp)) {
2382  if (!feof($this->fp)) {
2383  $this->debug('Re-use persistent connection');
2384  return true;
2385  }
2386  fclose($this->fp);
2387  $this->debug('Closed persistent connection at EOF');
2388  }
2389 
2390  // munge host if using OpenSSL
2391  if ($this->scheme == 'ssl') {
2392  $host = 'ssl://' . $host;
2393  }
2394  $this->debug('calling fsockopen with host ' . $host . ' connection_timeout ' . $connection_timeout);
2395 
2396  // open socket
2397  if ($connection_timeout > 0) {
2398  $this->fp = @fsockopen($host, $this->port, $this->errno, $this->error_str, $connection_timeout);
2399  } else {
2400  $this->fp = @fsockopen($host, $this->port, $this->errno, $this->error_str);
2401  }
2402 
2403  // test pointer
2404  if (!$this->fp) {
2405  $msg = 'Couldn\'t open socket connection to server ' . $this->url;
2406  if ($this->errno) {
2407  $msg .= ', Error (' . $this->errno . '): ' . $this->error_str;
2408  } else {
2409  $msg .= ' prior to connect(). This is often a problem looking up the host name.';
2410  }
2411  $this->debug($msg);
2412  $this->setError($msg);
2413  return false;
2414  }
2415 
2416  // set response timeout
2417  $this->debug('set response timeout to ' . $response_timeout);
2418  socket_set_timeout($this->fp, $response_timeout);
2419 
2420  $this->debug('socket connected');
2421  return true;
2422  } elseif ($this->io_method() == 'curl') {
2423  if (!extension_loaded('curl')) {
2424  // $this->setError('cURL Extension, or OpenSSL extension w/ PHP version >= 4.3 is required for HTTPS');
2425  $this->setError('The PHP cURL Extension is required for HTTPS or NLTM. You will need to re-build or update your PHP to included cURL.');
2426  return false;
2427  }
2428  // Avoid warnings when PHP does not have these options
2429  if (defined('CURLOPT_CONNECTIONTIMEOUT')) {
2430  $CURLOPT_CONNECTIONTIMEOUT = CURLOPT_CONNECTIONTIMEOUT;
2431  } else {
2432  $CURLOPT_CONNECTIONTIMEOUT = 78;
2433  }
2434  if (defined('CURLOPT_HTTPAUTH')) {
2435  $CURLOPT_HTTPAUTH = CURLOPT_HTTPAUTH;
2436  } else {
2437  $CURLOPT_HTTPAUTH = 107;
2438  }
2439  if (defined('CURLOPT_PROXYAUTH')) {
2440  $CURLOPT_PROXYAUTH = CURLOPT_PROXYAUTH;
2441  } else {
2442  $CURLOPT_PROXYAUTH = 111;
2443  }
2444  if (defined('CURLAUTH_BASIC')) {
2445  $CURLAUTH_BASIC = CURLAUTH_BASIC;
2446  } else {
2447  $CURLAUTH_BASIC = 1;
2448  }
2449  if (defined('CURLAUTH_DIGEST')) {
2450  $CURLAUTH_DIGEST = CURLAUTH_DIGEST;
2451  } else {
2452  $CURLAUTH_DIGEST = 2;
2453  }
2454  if (defined('CURLAUTH_NTLM')) {
2455  $CURLAUTH_NTLM = CURLAUTH_NTLM;
2456  } else {
2457  $CURLAUTH_NTLM = 8;
2458  }
2459 
2460  $this->debug('connect using cURL');
2461  // init CURL
2462  $this->ch = curl_init();
2463  // set url
2464  $hostURL = ($this->port != '') ? "$this->scheme://$this->host:$this->port" : "$this->scheme://$this->host";
2465  // add path
2466  $hostURL .= $this->path;
2467  $this->setCurlOption(CURLOPT_URL, $hostURL);
2468  // follow location headers (re-directs)
2469  if (ini_get('safe_mode') || ini_get('open_basedir')) {
2470  $this->debug('safe_mode or open_basedir set, so do not set CURLOPT_FOLLOWLOCATION');
2471  $this->debug('safe_mode = ');
2472  $this->appendDebug($this->varDump(ini_get('safe_mode')));
2473  $this->debug('open_basedir = ');
2474  $this->appendDebug($this->varDump(ini_get('open_basedir')));
2475  } else {
2476  $this->setCurlOption(CURLOPT_FOLLOWLOCATION, 1);
2477  }
2478  // ask for headers in the response output
2479  $this->setCurlOption(CURLOPT_HEADER, 1);
2480  // ask for the response output as the return value
2481  $this->setCurlOption(CURLOPT_RETURNTRANSFER, 1);
2482  // encode
2483  // We manage this ourselves through headers and encoding
2484  // if(function_exists('gzuncompress')){
2485  // $this->setCurlOption(CURLOPT_ENCODING, 'deflate');
2486  // }
2487  // persistent connection
2488  if ($this->persistentConnection) {
2489  // I believe the following comment is now bogus, having applied to
2490  // the code when it used CURLOPT_CUSTOMREQUEST to send the request.
2491  // The way we send data, we cannot use persistent connections, since
2492  // there will be some "junk" at the end of our request.
2493  //$this->setCurlOption(CURL_HTTP_VERSION_1_1, true);
2494  $this->persistentConnection = false;
2495  $this->setHeader('Connection', 'close');
2496  }
2497  // set timeouts
2498  if ($connection_timeout != 0) {
2499  $this->setCurlOption($CURLOPT_CONNECTIONTIMEOUT, $connection_timeout);
2500  }
2501  if ($response_timeout != 0) {
2502  $this->setCurlOption(CURLOPT_TIMEOUT, $response_timeout);
2503  }
2504 
2505  if ($this->scheme == 'https') {
2506  $this->debug('set cURL SSL verify options');
2507  // recent versions of cURL turn on peer/host checking by default,
2508  // while PHP binaries are not compiled with a default location for the
2509  // CA cert bundle, so disable peer/host checking.
2510  //$this->setCurlOption(CURLOPT_CAINFO, 'f:\php-4.3.2-win32\extensions\curl-ca-bundle.crt');
2511  $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 0);
2512  $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 0);
2513 
2514  // support client certificates (thanks Tobias Boes, Doug Anarino, Eryan Ariobowo)
2515  if ($this->authtype == 'certificate') {
2516  $this->debug('set cURL certificate options');
2517  if (isset($this->certRequest['cainfofile'])) {
2518  $this->setCurlOption(CURLOPT_CAINFO, $this->certRequest['cainfofile']);
2519  }
2520  if (isset($this->certRequest['verifypeer'])) {
2521  $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, $this->certRequest['verifypeer']);
2522  } else {
2523  $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 1);
2524  }
2525  if (isset($this->certRequest['verifyhost'])) {
2526  $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, $this->certRequest['verifyhost']);
2527  } else {
2528  $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 1);
2529  }
2530  if (isset($this->certRequest['sslcertfile'])) {
2531  $this->setCurlOption(CURLOPT_SSLCERT, $this->certRequest['sslcertfile']);
2532  }
2533  if (isset($this->certRequest['sslkeyfile'])) {
2534  $this->setCurlOption(CURLOPT_SSLKEY, $this->certRequest['sslkeyfile']);
2535  }
2536  if (isset($this->certRequest['passphrase'])) {
2537  $this->setCurlOption(CURLOPT_SSLKEYPASSWD, $this->certRequest['passphrase']);
2538  }
2539  if (isset($this->certRequest['certpassword'])) {
2540  $this->setCurlOption(CURLOPT_SSLCERTPASSWD, $this->certRequest['certpassword']);
2541  }
2542  }
2543  }
2544  if ($this->authtype && ($this->authtype != 'certificate')) {
2545  if ($this->username) {
2546  $this->debug('set cURL username/password');
2547  $this->setCurlOption(CURLOPT_USERPWD, "$this->username:$this->password");
2548  }
2549  if ($this->authtype == 'basic') {
2550  $this->debug('set cURL for Basic authentication');
2551  $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_BASIC);
2552  }
2553  if ($this->authtype == 'digest') {
2554  $this->debug('set cURL for digest authentication');
2555  $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_DIGEST);
2556  }
2557  if ($this->authtype == 'ntlm') {
2558  $this->debug('set cURL for NTLM authentication');
2559  $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_NTLM);
2560  }
2561  }
2562  if (is_array($this->proxy)) {
2563  $this->debug('set cURL proxy options');
2564  if ($this->proxy['port'] != '') {
2565  $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host'] . ':' . $this->proxy['port']);
2566  } else {
2567  $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host']);
2568  }
2569  if ($this->proxy['username'] || $this->proxy['password']) {
2570  $this->debug('set cURL proxy authentication options');
2571  $this->setCurlOption(CURLOPT_PROXYUSERPWD, $this->proxy['username'] . ':' . $this->proxy['password']);
2572  if ($this->proxy['authtype'] == 'basic') {
2573  $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_BASIC);
2574  }
2575  if ($this->proxy['authtype'] == 'ntlm') {
2576  $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_NTLM);
2577  }
2578  }
2579  }
2580  $this->debug('cURL connection set up');
2581  return true;
2582  } else {
2583  $this->setError('Unknown scheme ' . $this->scheme);
2584  $this->debug('Unknown scheme ' . $this->scheme);
2585  return false;
2586  }
2587  }
appendDebug($string)
adds debug data to the instance debug string without formatting
Definition: nusoap.php:305
setHeader($name, $value)
sets an HTTP header
Definition: nusoap.php:2266
setError($str)
sets error string
Definition: nusoap.php:395
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:292
setCurlOption($option, $value)
sets a cURL option
Definition: nusoap.php:2252
varDump($data)
Returns a string with the output of var_dump.
Definition: nusoap.php:909
io_method()
gets the I/O method to use
Definition: nusoap.php:2337
+ Here is the call graph for this function:

◆ decodeChunked()

soap_transport_http::decodeChunked (   $buffer,
  $lb 
)

decode a string that is encoded w/ "chunked' transfer encoding as defined in RFC2068 19.4.6

Parameters
string$buffer
string$lb
Returns
string public
Deprecated:

Definition at line 2825 of file nusoap.php.

References nusoap_base\debug().

2826  {
2827  // length := 0
2828  $length = 0;
2829  $new = '';
2830 
2831  // read chunk-size, chunk-extension (if any) and CRLF
2832  // get the position of the linebreak
2833  $chunkend = strpos($buffer, $lb);
2834  if ($chunkend == false) {
2835  $this->debug('no linebreak found in decodeChunked');
2836  return $new;
2837  }
2838  $temp = substr($buffer, 0, $chunkend);
2839  $chunk_size = hexdec(trim($temp));
2840  $chunkstart = $chunkend + strlen($lb);
2841  // while (chunk-size > 0) {
2842  while ($chunk_size > 0) {
2843  $this->debug("chunkstart: $chunkstart chunk_size: $chunk_size");
2844  $chunkend = strpos($buffer, $lb, $chunkstart + $chunk_size);
2845 
2846  // Just in case we got a broken connection
2847  if ($chunkend == false) {
2848  $chunk = substr($buffer, $chunkstart);
2849  // append chunk-data to entity-body
2850  $new .= $chunk;
2851  $length += strlen($chunk);
2852  break;
2853  }
2854 
2855  // read chunk-data and CRLF
2856  $chunk = substr($buffer, $chunkstart, $chunkend-$chunkstart);
2857  // append chunk-data to entity-body
2858  $new .= $chunk;
2859  // length := length + chunk-size
2860  $length += strlen($chunk);
2861  // read chunk-size and CRLF
2862  $chunkstart = $chunkend + strlen($lb);
2863 
2864  $chunkend = strpos($buffer, $lb, $chunkstart) + strlen($lb);
2865  if ($chunkend == false) {
2866  break; //Just in case we got a broken connection
2867  }
2868  $temp = substr($buffer, $chunkstart, $chunkend-$chunkstart);
2869  $chunk_size = hexdec(trim($temp));
2870  $chunkstart = $chunkend;
2871  }
2872  return $new;
2873  }
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:292
+ Here is the call graph for this function:

◆ getCookiesForRequest()

soap_transport_http::getCookiesForRequest (   $cookies,
  $secure = false 
)

sort out cookies for the current request

Parameters
array$cookiesarray with all cookies
boolean$secureis the send-content secure or not?
Returns
string for Cookie-HTTP-Header private

Definition at line 3465 of file nusoap.php.

References $path, and nusoap_base\debug().

3466  {
3467  $cookie_str = '';
3468  if ((! is_null($cookies)) && (is_array($cookies))) {
3469  foreach ($cookies as $cookie) {
3470  if (! is_array($cookie)) {
3471  continue;
3472  }
3473  $this->debug("check cookie for validity: " . $cookie['name'] . '=' . $cookie['value']);
3474  if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
3475  if (strtotime($cookie['expires']) <= time()) {
3476  $this->debug('cookie has expired');
3477  continue;
3478  }
3479  }
3480  if ((isset($cookie['domain'])) && (! empty($cookie['domain']))) {
3481  $domain = preg_quote($cookie['domain']);
3482  if (! preg_match("'.*$domain$'i", $this->host)) {
3483  $this->debug('cookie has different domain');
3484  continue;
3485  }
3486  }
3487  if ((isset($cookie['path'])) && (! empty($cookie['path']))) {
3488  $path = preg_quote($cookie['path']);
3489  if (! preg_match("'^$path.*'i", $this->path)) {
3490  $this->debug('cookie is for a different path');
3491  continue;
3492  }
3493  }
3494  if ((! $secure) && (isset($cookie['secure'])) && ($cookie['secure'])) {
3495  $this->debug('cookie is secure, transport is not');
3496  continue;
3497  }
3498  $cookie_str .= $cookie['name'] . '=' . $cookie['value'] . '; ';
3499  $this->debug('add cookie to Cookie-String: ' . $cookie['name'] . '=' . $cookie['value']);
3500  }
3501  }
3502  return $cookie_str;
3503  }
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:292
+ Here is the call graph for this function:

◆ getResponse()

soap_transport_http::getResponse ( )

gets the SOAP response via HTTP[S]

Returns
string the response (also sets member variables like incoming_payload) private

Definition at line 2989 of file nusoap.php.

References $data, nusoap_base\debug(), and nusoap_base\setError().

2990  {
2991  $this->incoming_payload = '';
2992 
2993  if ($this->io_method() == 'socket') {
2994  // loop until headers have been retrieved
2995  $data = '';
2996  while (!isset($lb)) {
2997  // We might EOF during header read.
2998  if (feof($this->fp)) {
2999  $this->incoming_payload = $data;
3000  $this->debug('found no headers before EOF after length ' . strlen($data));
3001  $this->debug("received before EOF:\n" . $data);
3002  $this->setError('server failed to send headers');
3003  return false;
3004  }
3005 
3006  $tmp = fgets($this->fp, 256);
3007  $tmplen = strlen($tmp);
3008  $this->debug("read line of $tmplen bytes: " . trim($tmp));
3009 
3010  if ($tmplen == 0) {
3011  $this->incoming_payload = $data;
3012  $this->debug('socket read of headers timed out after length ' . strlen($data));
3013  $this->debug("read before timeout: " . $data);
3014  $this->setError('socket read of headers timed out');
3015  return false;
3016  }
3017 
3018  $data .= $tmp;
3019  $pos = strpos($data, "\r\n\r\n");
3020  if ($pos > 1) {
3021  $lb = "\r\n";
3022  } else {
3023  $pos = strpos($data, "\n\n");
3024  if ($pos > 1) {
3025  $lb = "\n";
3026  }
3027  }
3028  // remove 100 headers
3029  if (isset($lb) && preg_match('/^HTTP\/1.1 100/', $data)) {
3030  unset($lb);
3031  $data = '';
3032  }//
3033  }
3034  // store header data
3035  $this->incoming_payload .= $data;
3036  $this->debug('found end of headers after length ' . strlen($data));
3037  // process headers
3038  $header_data = trim(substr($data, 0, $pos));
3039  $header_array = explode($lb, $header_data);
3040  $this->incoming_headers = array();
3041  $this->incoming_cookies = array();
3042  foreach ($header_array as $header_line) {
3043  $arr = explode(':', $header_line, 2);
3044  if (count($arr) > 1) {
3045  $header_name = strtolower(trim($arr[0]));
3046  $this->incoming_headers[$header_name] = trim($arr[1]);
3047  if ($header_name == 'set-cookie') {
3048  // TODO: allow multiple cookies from parseCookie
3049  $cookie = $this->parseCookie(trim($arr[1]));
3050  if ($cookie) {
3051  $this->incoming_cookies[] = $cookie;
3052  $this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
3053  } else {
3054  $this->debug('did not find cookie in ' . trim($arr[1]));
3055  }
3056  }
3057  } elseif (isset($header_name)) {
3058  // append continuation line to previous header
3059  $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
3060  }
3061  }
3062 
3063  // loop until msg has been received
3064  if (isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked') {
3065  $content_length = 2147483647; // ignore any content-length header
3066  $chunked = true;
3067  $this->debug("want to read chunked content");
3068  } elseif (isset($this->incoming_headers['content-length'])) {
3069  $content_length = $this->incoming_headers['content-length'];
3070  $chunked = false;
3071  $this->debug("want to read content of length $content_length");
3072  } else {
3073  $content_length = 2147483647;
3074  $chunked = false;
3075  $this->debug("want to read content to EOF");
3076  }
3077  $data = '';
3078  do {
3079  if ($chunked) {
3080  $tmp = fgets($this->fp, 256);
3081  $tmplen = strlen($tmp);
3082  $this->debug("read chunk line of $tmplen bytes");
3083  if ($tmplen == 0) {
3084  $this->incoming_payload = $data;
3085  $this->debug('socket read of chunk length timed out after length ' . strlen($data));
3086  $this->debug("read before timeout:\n" . $data);
3087  $this->setError('socket read of chunk length timed out');
3088  return false;
3089  }
3090  $content_length = hexdec(trim($tmp));
3091  $this->debug("chunk length $content_length");
3092  }
3093  $strlen = 0;
3094  while (($strlen < $content_length) && (!feof($this->fp))) {
3095  $readlen = min(8192, $content_length - $strlen);
3096  $tmp = fread($this->fp, $readlen);
3097  $tmplen = strlen($tmp);
3098  $this->debug("read buffer of $tmplen bytes");
3099  if (($tmplen == 0) && (!feof($this->fp))) {
3100  $this->incoming_payload = $data;
3101  $this->debug('socket read of body timed out after length ' . strlen($data));
3102  $this->debug("read before timeout:\n" . $data);
3103  $this->setError('socket read of body timed out');
3104  return false;
3105  }
3106  $strlen += $tmplen;
3107  $data .= $tmp;
3108  }
3109  if ($chunked && ($content_length > 0)) {
3110  $tmp = fgets($this->fp, 256);
3111  $tmplen = strlen($tmp);
3112  $this->debug("read chunk terminator of $tmplen bytes");
3113  if ($tmplen == 0) {
3114  $this->incoming_payload = $data;
3115  $this->debug('socket read of chunk terminator timed out after length ' . strlen($data));
3116  $this->debug("read before timeout:\n" . $data);
3117  $this->setError('socket read of chunk terminator timed out');
3118  return false;
3119  }
3120  }
3121  } while ($chunked && ($content_length > 0) && (!feof($this->fp)));
3122  if (feof($this->fp)) {
3123  $this->debug('read to EOF');
3124  }
3125  $this->debug('read body of length ' . strlen($data));
3126  $this->incoming_payload .= $data;
3127  $this->debug('received a total of ' . strlen($this->incoming_payload) . ' bytes of data from server');
3128 
3129  // close filepointer
3130  if (
3131  (isset($this->incoming_headers['connection']) && strtolower($this->incoming_headers['connection']) == 'close') ||
3132  (! $this->persistentConnection) || feof($this->fp)) {
3133  fclose($this->fp);
3134  $this->fp = false;
3135  $this->debug('closed socket');
3136  }
3137 
3138  // connection was closed unexpectedly
3139  if ($this->incoming_payload == '') {
3140  $this->setError('no response from server');
3141  return false;
3142  }
3143 
3144  // decode transfer-encoding
3145  // if(isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked'){
3146  // if(!$data = $this->decodeChunked($data, $lb)){
3147  // $this->setError('Decoding of chunked data failed');
3148  // return false;
3149  // }
3150  //print "<pre>\nde-chunked:\n---------------\n$data\n\n---------------\n</pre>";
3151  // set decoded payload
3152  // $this->incoming_payload = $header_data.$lb.$lb.$data;
3153  // }
3154  } elseif ($this->io_method() == 'curl') {
3155  // send and receive
3156  $this->debug('send and receive with cURL');
3157  $this->incoming_payload = curl_exec($this->ch);
3159 
3160  $cErr = curl_error($this->ch);
3161  if ($cErr != '') {
3162  $err = 'cURL ERROR: ' . curl_errno($this->ch) . ': ' . $cErr . '<br>';
3163  // TODO: there is a PHP bug that can cause this to SEGV for CURLINFO_CONTENT_TYPE
3164  foreach (curl_getinfo($this->ch) as $k => $v) {
3165  $err .= "$k: $v<br>";
3166  }
3167  $this->debug($err);
3168  $this->setError($err);
3169  curl_close($this->ch);
3170  return false;
3171  } else {
3172  //echo '<pre>';
3173  //var_dump(curl_getinfo($this->ch));
3174  //echo '</pre>';
3175  }
3176  // close curl
3177  $this->debug('No cURL error, closing cURL');
3178  curl_close($this->ch);
3179 
3180  // try removing skippable headers
3181  $savedata = $data;
3182  while ($this->isSkippableCurlHeader($data)) {
3183  $this->debug("Found HTTP header to skip");
3184  if ($pos = strpos($data, "\r\n\r\n")) {
3185  $data = ltrim(substr($data, $pos));
3186  } elseif ($pos = strpos($data, "\n\n")) {
3187  $data = ltrim(substr($data, $pos));
3188  }
3189  }
3190 
3191  if ($data == '') {
3192  // have nothing left; just remove 100 header(s)
3193  $data = $savedata;
3194  while (preg_match('/^HTTP\/1.1 100/', $data)) {
3195  if ($pos = strpos($data, "\r\n\r\n")) {
3196  $data = ltrim(substr($data, $pos));
3197  } elseif ($pos = strpos($data, "\n\n")) {
3198  $data = ltrim(substr($data, $pos));
3199  }
3200  }
3201  }
3202 
3203  // separate content from HTTP headers
3204  if ($pos = strpos($data, "\r\n\r\n")) {
3205  $lb = "\r\n";
3206  } elseif ($pos = strpos($data, "\n\n")) {
3207  $lb = "\n";
3208  } else {
3209  $this->debug('no proper separation of headers and document');
3210  $this->setError('no proper separation of headers and document');
3211  return false;
3212  }
3213  $header_data = trim(substr($data, 0, $pos));
3214  $header_array = explode($lb, $header_data);
3215  $data = ltrim(substr($data, $pos));
3216  $this->debug('found proper separation of headers and document');
3217  $this->debug('cleaned data, stringlen: ' . strlen($data));
3218  // clean headers
3219  foreach ($header_array as $header_line) {
3220  $arr = explode(':', $header_line, 2);
3221  if (count($arr) > 1) {
3222  $header_name = strtolower(trim($arr[0]));
3223  $this->incoming_headers[$header_name] = trim($arr[1]);
3224  if ($header_name == 'set-cookie') {
3225  // TODO: allow multiple cookies from parseCookie
3226  $cookie = $this->parseCookie(trim($arr[1]));
3227  if ($cookie) {
3228  $this->incoming_cookies[] = $cookie;
3229  $this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
3230  } else {
3231  $this->debug('did not find cookie in ' . trim($arr[1]));
3232  }
3233  }
3234  } elseif (isset($header_name)) {
3235  // append continuation line to previous header
3236  $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
3237  }
3238  }
3239  }
3240 
3241  $this->response_status_line = $header_array[0];
3242  $arr = explode(' ', $this->response_status_line, 3);
3243  $http_version = $arr[0];
3244  $http_status = intval($arr[1]);
3245  $http_reason = count($arr) > 2 ? $arr[2] : '';
3246 
3247  // see if we need to resend the request with http digest authentication
3248  if (isset($this->incoming_headers['location']) && ($http_status == 301 || $http_status == 302)) {
3249  $this->debug("Got $http_status $http_reason with Location: " . $this->incoming_headers['location']);
3250  $this->setURL($this->incoming_headers['location']);
3251  $this->tryagain = true;
3252  return false;
3253  }
3254 
3255  // see if we need to resend the request with http digest authentication
3256  if (isset($this->incoming_headers['www-authenticate']) && $http_status == 401) {
3257  $this->debug("Got 401 $http_reason with WWW-Authenticate: " . $this->incoming_headers['www-authenticate']);
3258  if (strstr($this->incoming_headers['www-authenticate'], "Digest ")) {
3259  $this->debug('Server wants digest authentication');
3260  // remove "Digest " from our elements
3261  $digestString = str_replace('Digest ', '', $this->incoming_headers['www-authenticate']);
3262 
3263  // parse elements into array
3264  $digestElements = explode(',', $digestString);
3265  foreach ($digestElements as $val) {
3266  $tempElement = explode('=', trim($val), 2);
3267  $digestRequest[$tempElement[0]] = str_replace("\"", '', $tempElement[1]);
3268  }
3269 
3270  // should have (at least) qop, realm, nonce
3271  if (isset($digestRequest['nonce'])) {
3272  $this->setCredentials($this->username, $this->password, 'digest', $digestRequest);
3273  $this->tryagain = true;
3274  return false;
3275  }
3276  }
3277  $this->debug('HTTP authentication failed');
3278  $this->setError('HTTP authentication failed');
3279  return false;
3280  }
3281 
3282  if (
3283  ($http_status >= 300 && $http_status <= 307) ||
3284  ($http_status >= 400 && $http_status <= 417) ||
3285  ($http_status >= 501 && $http_status <= 505)
3286  ) {
3287  $this->setError("Unsupported HTTP response status $http_status $http_reason (soapclient->response has contents of the response)");
3288  return false;
3289  }
3290 
3291  // decode content-encoding
3292  if (isset($this->incoming_headers['content-encoding']) && $this->incoming_headers['content-encoding'] != '') {
3293  if (strtolower($this->incoming_headers['content-encoding']) == 'deflate' || strtolower($this->incoming_headers['content-encoding']) == 'gzip') {
3294  // if decoding works, use it. else assume data wasn't gzencoded
3295  if (function_exists('gzinflate')) {
3296  //$timer->setMarker('starting decoding of gzip/deflated content');
3297  // IIS 5 requires gzinflate instead of gzuncompress (similar to IE 5 and gzdeflate v. gzcompress)
3298  // this means there are no Zlib headers, although there should be
3299  $this->debug('The gzinflate function exists');
3300  $datalen = strlen($data);
3301  if ($this->incoming_headers['content-encoding'] == 'deflate') {
3302  if ($degzdata = @gzinflate($data)) {
3303  $data = $degzdata;
3304  $this->debug('The payload has been inflated to ' . strlen($data) . ' bytes');
3305  if (strlen($data) < $datalen) {
3306  // test for the case that the payload has been compressed twice
3307  $this->debug('The inflated payload is smaller than the gzipped one; try again');
3308  if ($degzdata = @gzinflate($data)) {
3309  $data = $degzdata;
3310  $this->debug('The payload has been inflated again to ' . strlen($data) . ' bytes');
3311  }
3312  }
3313  } else {
3314  $this->debug('Error using gzinflate to inflate the payload');
3315  $this->setError('Error using gzinflate to inflate the payload');
3316  }
3317  } elseif ($this->incoming_headers['content-encoding'] == 'gzip') {
3318  if ($degzdata = @gzinflate(substr($data, 10))) { // do our best
3319  $data = $degzdata;
3320  $this->debug('The payload has been un-gzipped to ' . strlen($data) . ' bytes');
3321  if (strlen($data) < $datalen) {
3322  // test for the case that the payload has been compressed twice
3323  $this->debug('The un-gzipped payload is smaller than the gzipped one; try again');
3324  if ($degzdata = @gzinflate(substr($data, 10))) {
3325  $data = $degzdata;
3326  $this->debug('The payload has been un-gzipped again to ' . strlen($data) . ' bytes');
3327  }
3328  }
3329  } else {
3330  $this->debug('Error using gzinflate to un-gzip the payload');
3331  $this->setError('Error using gzinflate to un-gzip the payload');
3332  }
3333  }
3334  //$timer->setMarker('finished decoding of gzip/deflated content');
3335  //print "<xmp>\nde-inflated:\n---------------\n$data\n-------------\n</xmp>";
3336  // set decoded payload
3337  $this->incoming_payload = $header_data . $lb . $lb . $data;
3338  } else {
3339  $this->debug('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
3340  $this->setError('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
3341  }
3342  } else {
3343  $this->debug('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
3344  $this->setError('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
3345  }
3346  } else {
3347  $this->debug('No Content-Encoding header');
3348  }
3349 
3350  if (strlen($data) == 0) {
3351  $this->debug('no data after headers!');
3352  $this->setError('no data present after HTTP headers');
3353  return false;
3354  }
3355 
3356  return $data;
3357  }
setCredentials($username, $password, $authtype='basic', $digestRequest=array(), $certRequest=array())
if authenticating, set user credentials here
Definition: nusoap.php:2655
setError($str)
sets error string
Definition: nusoap.php:395
setURL($url)
sets the URL to which to connect
Definition: nusoap.php:2292
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:292
isSkippableCurlHeader(&$data)
Test if the given string starts with a header that is to be skipped.
Definition: nusoap.php:2795
parseCookie($cookie_str)
parse an incoming Cookie into it&#39;s parts
Definition: nusoap.php:3398
io_method()
gets the I/O method to use
Definition: nusoap.php:2337
+ Here is the call graph for this function:

◆ io_method()

soap_transport_http::io_method ( )

gets the I/O method to use

Returns
string I/O method to use (socket|curl|unknown) private

Definition at line 2337 of file nusoap.php.

2338  {
2339  if ($this->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'ntlm') || ($this->scheme == 'http' && is_array($this->proxy) && $this->proxy['authtype'] == 'ntlm')) {
2340  return 'curl';
2341  }
2342  if (($this->scheme == 'http' || $this->scheme == 'ssl') && $this->authtype != 'ntlm' && (!is_array($this->proxy) || $this->proxy['authtype'] != 'ntlm')) {
2343  return 'socket';
2344  }
2345  return 'unknown';
2346  }

◆ isSkippableCurlHeader()

soap_transport_http::isSkippableCurlHeader ( $data)

Test if the given string starts with a header that is to be skipped.

Skippable headers result from chunked transfer and proxy requests.

Parameters
string$dataThe string to check.
Returns
boolean Whether a skippable header was found. private

Definition at line 2795 of file nusoap.php.

References $data.

2796  {
2797  $skipHeaders = array( 'HTTP/1.1 100',
2798  'HTTP/1.0 301',
2799  'HTTP/1.1 301',
2800  'HTTP/1.0 302',
2801  'HTTP/1.1 302',
2802  'HTTP/1.0 401',
2803  'HTTP/1.1 401',
2804  'HTTP/1.0 200 Connection established');
2805  foreach ($skipHeaders as $hd) {
2806  $prefix = substr($data, 0, strlen($hd));
2807  if ($prefix == $hd) {
2808  return true;
2809  }
2810  }
2811 
2812  return false;
2813  }

◆ parseCookie()

soap_transport_http::parseCookie (   $cookie_str)

parse an incoming Cookie into it's parts

Parameters
string$cookie_strcontent of cookie
Returns
array with data of that cookie private

Definition at line 3398 of file nusoap.php.

References $data, and $path.

3399  {
3400  $cookie_str = str_replace('; ', ';', $cookie_str) . ';';
3401  // begin-patch php8
3402  //$data = split(';', $cookie_str);
3403  $data = explode(';', $cookie_str);
3404  $value_str = $data[0];
3405 
3406  $cookie_param = 'domain=';
3407  $start = strpos($cookie_str, $cookie_param);
3408  if ($start > 0) {
3409  $domain = substr($cookie_str, $start + strlen($cookie_param));
3410  $domain = substr($domain, 0, strpos($domain, ';'));
3411  } else {
3412  $domain = '';
3413  }
3414 
3415  $cookie_param = 'expires=';
3416  $start = strpos($cookie_str, $cookie_param);
3417  if ($start > 0) {
3418  $expires = substr($cookie_str, $start + strlen($cookie_param));
3419  $expires = substr($expires, 0, strpos($expires, ';'));
3420  } else {
3421  $expires = '';
3422  }
3423 
3424  $cookie_param = 'path=';
3425  $start = strpos($cookie_str, $cookie_param);
3426  if ($start > 0) {
3427  $path = substr($cookie_str, $start + strlen($cookie_param));
3428  $path = substr($path, 0, strpos($path, ';'));
3429  } else {
3430  $path = '/';
3431  }
3432 
3433  $cookie_param = ';secure;';
3434  if (strpos($cookie_str, $cookie_param) !== false) {
3435  $secure = true;
3436  } else {
3437  $secure = false;
3438  }
3439 
3440  $sep_pos = strpos($value_str, '=');
3441 
3442  if ($sep_pos) {
3443  $name = substr($value_str, 0, $sep_pos);
3444  $value = substr($value_str, $sep_pos + 1);
3445  $cookie= array( 'name' => $name,
3446  'value' => $value,
3447  'domain' => $domain,
3448  'path' => $path,
3449  'expires' => $expires,
3450  'secure' => $secure
3451  );
3452  return $cookie;
3453  }
3454  return false;
3455  }

◆ send()

soap_transport_http::send (   $data,
  $timeout = 0,
  $response_timeout = 30,
  $cookies = null 
)

sends the SOAP request and gets the SOAP response via HTTP[S]

Parameters
string$datamessage data
integer$timeoutset connection timeout in seconds
integer$response_timeoutset response timeout in seconds
array$cookiescookies to send
Returns
string data public

Definition at line 2599 of file nusoap.php.

References $data, nusoap_base\debug(), and nusoap_base\setError().

2600  {
2601  $this->debug('entered send() with data of length: ' . strlen($data));
2602 
2603  $this->tryagain = true;
2604  $tries = 0;
2605  while ($this->tryagain) {
2606  $this->tryagain = false;
2607  if ($tries++ < 2) {
2608  // make connnection
2609  if (!$this->connect($timeout, $response_timeout)) {
2610  return false;
2611  }
2612 
2613  // send request
2614  if (!$this->sendRequest($data, $cookies)) {
2615  return false;
2616  }
2617 
2618  // get response
2619  $respdata = $this->getResponse();
2620  } else {
2621  $this->setError("Too many tries to get an OK response ($this->response_status_line)");
2622  }
2623  }
2624  $this->debug('end of send()');
2625  return $respdata;
2626  }
connect($connection_timeout=0, $response_timeout=30)
establish an HTTP connection
Definition: nusoap.php:2356
setError($str)
sets error string
Definition: nusoap.php:395
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:292
sendRequest($data, $cookies=null)
sends the SOAP request via HTTP[S]
Definition: nusoap.php:2931
getResponse()
gets the SOAP response via HTTP[S]
Definition: nusoap.php:2989
+ Here is the call graph for this function:

◆ sendHTTPS()

soap_transport_http::sendHTTPS (   $data,
  $timeout = 0,
  $response_timeout = 30,
  $cookies = null 
)

sends the SOAP request and gets the SOAP response via HTTPS using CURL

Parameters
string$datamessage data
integer$timeoutset connection timeout in seconds
integer$response_timeoutset response timeout in seconds
array$cookiescookies to send
Returns
string data public
Deprecated:

Definition at line 2640 of file nusoap.php.

References $data, and send().

2641  {
2642  return $this->send($data, $timeout, $response_timeout, $cookies);
2643  }
send($data, $timeout=0, $response_timeout=30, $cookies=null)
sends the SOAP request and gets the SOAP response via HTTP[S]
Definition: nusoap.php:2599
+ Here is the call graph for this function:

◆ sendRequest()

soap_transport_http::sendRequest (   $data,
  $cookies = null 
)

sends the SOAP request via HTTP[S]

Parameters
string$datamessage data
array$cookiescookies to send
Returns
boolean true if OK, false if problem private

Definition at line 2931 of file nusoap.php.

References $data, ILIAS\LTI\ToolProvider\$key, nusoap_base\debug(), and nusoap_base\setError().

2932  {
2933  // build cookie string
2934  $cookie_str = $this->getCookiesForRequest($cookies, (($this->scheme == 'ssl') || ($this->scheme == 'https')));
2935 
2936  // build payload
2937  $this->buildPayload($data, $cookie_str);
2938 
2939  if ($this->io_method() == 'socket') {
2940  // send payload
2941  if (!fputs($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) {
2942  $this->setError('couldn\'t write message data to socket');
2943  $this->debug('couldn\'t write message data to socket');
2944  return false;
2945  }
2946  $this->debug('wrote data to socket, length = ' . strlen($this->outgoing_payload));
2947  return true;
2948  } elseif ($this->io_method() == 'curl') {
2949  // set payload
2950  // cURL does say this should only be the verb, and in fact it
2951  // turns out that the URI and HTTP version are appended to this, which
2952  // some servers refuse to work with (so we no longer use this method!)
2953  //$this->setCurlOption(CURLOPT_CUSTOMREQUEST, $this->outgoing_payload);
2954  $curl_headers = array();
2955  foreach ($this->outgoing_headers as $k => $v) {
2956  if ($k == 'Connection' || $k == 'Content-Length' || $k == 'Host' || $k == 'Authorization' || $k == 'Proxy-Authorization') {
2957  $this->debug("Skip cURL header $k: $v");
2958  } else {
2959  $curl_headers[] = "$k: $v";
2960  }
2961  }
2962  if ($cookie_str != '') {
2963  $curl_headers[] = 'Cookie: ' . $cookie_str;
2964  }
2965  $this->setCurlOption(CURLOPT_HTTPHEADER, $curl_headers);
2966  $this->debug('set cURL HTTP headers');
2967  if ($this->request_method == "POST") {
2968  $this->setCurlOption(CURLOPT_POST, 1);
2969  $this->setCurlOption(CURLOPT_POSTFIELDS, $data);
2970  $this->debug('set cURL POST data');
2971  } else {
2972  }
2973  // insert custom user-set cURL options
2974  foreach ($this->ch_options as $key => $val) {
2975  $this->setCurlOption($key, $val);
2976  }
2977 
2978  $this->debug('set cURL payload');
2979  return true;
2980  }
2981  }
setError($str)
sets error string
Definition: nusoap.php:395
buildPayload($data, $cookie_str='')
Writes the payload, including HTTP headers, to $this->outgoing_payload.
Definition: nusoap.php:2883
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:292
setCurlOption($option, $value)
sets a cURL option
Definition: nusoap.php:2252
getCookiesForRequest($cookies, $secure=false)
sort out cookies for the current request
Definition: nusoap.php:3465
string $key
Consumer key/client ID value.
Definition: System.php:193
io_method()
gets the I/O method to use
Definition: nusoap.php:2337
+ Here is the call graph for this function:

◆ setContentType()

soap_transport_http::setContentType (   $type,
  $charset = false 
)

sets the content-type for the SOAP message to be sent

Parameters
string$typethe content type, MIME style
mixed$charsetcharacter set used for encoding (or false) public

Definition at line 3366 of file nusoap.php.

3367  {
3368  $this->setHeader('Content-Type', $type . ($charset ? '; charset=' . $charset : ''));
3369  }
setHeader($name, $value)
sets an HTTP header
Definition: nusoap.php:2266

◆ setCredentials()

soap_transport_http::setCredentials (   $username,
  $password,
  $authtype = 'basic',
  $digestRequest = array(),
  $certRequest = array() 
)

if authenticating, set user credentials here

Parameters
string$username
string$password
string$authtype(basic|digest|certificate|ntlm)
array$digestRequest(keys must be nonce, nc, realm, qop)
array$certRequest(keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs) public

Definition at line 2655 of file nusoap.php.

References nusoap_base\appendDebug(), nusoap_base\debug(), and nusoap_base\varDump().

2656  {
2657  $this->debug("setCredentials username=$username authtype=$authtype digestRequest=");
2658  $this->appendDebug($this->varDump($digestRequest));
2659  $this->debug("certRequest=");
2660  $this->appendDebug($this->varDump($certRequest));
2661  // cf. RFC 2617
2662  if ($authtype == 'basic') {
2663  $this->setHeader('Authorization', 'Basic ' . base64_encode(str_replace(':', '', $username) . ':' . $password));
2664  } elseif ($authtype == 'digest') {
2665  if (isset($digestRequest['nonce'])) {
2666  $digestRequest['nc'] = isset($digestRequest['nc']) ? $digestRequest['nc']++ : 1;
2667 
2668  // calculate the Digest hashes (calculate code based on digest implementation found at: http://www.rassoc.com/gregr/weblog/stories/2002/07/09/webServicesSecurityHttpDigestAuthenticationWithoutActiveDirectory.html)
2669 
2670  // A1 = unq(username-value) ":" unq(realm-value) ":" passwd
2671  $A1 = $username . ':' . (isset($digestRequest['realm']) ? $digestRequest['realm'] : '') . ':' . $password;
2672 
2673  // H(A1) = MD5(A1)
2674  $HA1 = md5($A1);
2675 
2676  // A2 = Method ":" digest-uri-value
2677  $A2 = $this->request_method . ':' . $this->digest_uri;
2678 
2679  // H(A2)
2680  $HA2 = md5($A2);
2681 
2682  // KD(secret, data) = H(concat(secret, ":", data))
2683  // if qop == auth:
2684  // request-digest = <"> < KD ( H(A1), unq(nonce-value)
2685  // ":" nc-value
2686  // ":" unq(cnonce-value)
2687  // ":" unq(qop-value)
2688  // ":" H(A2)
2689  // ) <">
2690  // if qop is missing,
2691  // request-digest = <"> < KD ( H(A1), unq(nonce-value) ":" H(A2) ) > <">
2692 
2693  $unhashedDigest = '';
2694  $nonce = isset($digestRequest['nonce']) ? $digestRequest['nonce'] : '';
2695  $cnonce = $nonce;
2696  if ($digestRequest['qop'] != '') {
2697  $unhashedDigest = $HA1 . ':' . $nonce . ':' . sprintf("%08d", $digestRequest['nc']) . ':' . $cnonce . ':' . $digestRequest['qop'] . ':' . $HA2;
2698  } else {
2699  $unhashedDigest = $HA1 . ':' . $nonce . ':' . $HA2;
2700  }
2701 
2702  $hashedDigest = md5($unhashedDigest);
2703 
2704  $opaque = '';
2705  if (isset($digestRequest['opaque'])) {
2706  $opaque = ', opaque="' . $digestRequest['opaque'] . '"';
2707  }
2708 
2709  $this->setHeader('Authorization', 'Digest username="' . $username . '", realm="' . $digestRequest['realm'] . '", nonce="' . $nonce . '", uri="' . $this->digest_uri . $opaque . '", cnonce="' . $cnonce . '", nc=' . sprintf("%08x", $digestRequest['nc']) . ', qop="' . $digestRequest['qop'] . '", response="' . $hashedDigest . '"');
2710  }
2711  } elseif ($authtype == 'certificate') {
2712  $this->certRequest = $certRequest;
2713  $this->debug('Authorization header not set for certificate');
2714  } elseif ($authtype == 'ntlm') {
2715  // do nothing
2716  $this->debug('Authorization header not set for ntlm');
2717  }
2718  $this->username = $username;
2719  $this->password = $password;
2720  $this->authtype = $authtype;
2721  $this->digestRequest = $digestRequest;
2722  }
appendDebug($string)
adds debug data to the instance debug string without formatting
Definition: nusoap.php:305
setHeader($name, $value)
sets an HTTP header
Definition: nusoap.php:2266
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:292
varDump($data)
Returns a string with the output of var_dump.
Definition: nusoap.php:909
+ Here is the call graph for this function:

◆ setCurlOption()

soap_transport_http::setCurlOption (   $option,
  $value 
)

sets a cURL option

Parameters
mixed$optionThe cURL option (always integer?)
mixed$valueThe cURL option value private

Definition at line 2252 of file nusoap.php.

References nusoap_base\appendDebug(), nusoap_base\debug(), and nusoap_base\varDump().

2253  {
2254  $this->debug("setCurlOption option=$option, value=");
2255  $this->appendDebug($this->varDump($value));
2256  curl_setopt($this->ch, $option, $value);
2257  }
appendDebug($string)
adds debug data to the instance debug string without formatting
Definition: nusoap.php:305
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:292
varDump($data)
Returns a string with the output of var_dump.
Definition: nusoap.php:909
+ Here is the call graph for this function:

◆ setEncoding()

soap_transport_http::setEncoding (   $enc = 'gzip,
deflate'   
)

use http encoding

Parameters
string$encencoding style. supported values: gzip, deflate, or both public

Definition at line 2741 of file nusoap.php.

2742  {
2743  if (function_exists('gzdeflate')) {
2744  $this->protocol_version = '1.1';
2745  $this->setHeader('Accept-Encoding', $enc);
2746  if (!isset($this->outgoing_headers['Connection'])) {
2747  $this->setHeader('Connection', 'close');
2748  $this->persistentConnection = false;
2749  }
2750  #set_magic_quotes_runtime(0);
2751  // deprecated
2752  $this->encoding = $enc;
2753  }
2754  }
setHeader($name, $value)
sets an HTTP header
Definition: nusoap.php:2266

◆ setHeader()

soap_transport_http::setHeader (   $name,
  $value 
)

sets an HTTP header

Parameters
string$nameThe name of the header
string$valueThe value of the header private

Definition at line 2266 of file nusoap.php.

References nusoap_base\debug().

2267  {
2268  $this->outgoing_headers[$name] = $value;
2269  $this->debug("set header $name: $value");
2270  }
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:292
+ Here is the call graph for this function:

◆ setProxy()

soap_transport_http::setProxy (   $proxyhost,
  $proxyport,
  $proxyusername = '',
  $proxypassword = '',
  $proxyauthtype = 'basic' 
)

set proxy info here

Parameters
string$proxyhostuse an empty string to remove proxy
string$proxyport
string$proxyusername
string$proxypassword
string$proxyauthtype(basic|ntlm) public

Definition at line 2766 of file nusoap.php.

References nusoap_base\debug().

2767  {
2768  if ($proxyhost) {
2769  $this->proxy = array(
2770  'host' => $proxyhost,
2771  'port' => $proxyport,
2772  'username' => $proxyusername,
2773  'password' => $proxypassword,
2774  'authtype' => $proxyauthtype
2775  );
2776  if ($proxyusername != '' && $proxypassword != '' && $proxyauthtype = 'basic') {
2777  $this->setHeader('Proxy-Authorization', ' Basic ' . base64_encode($proxyusername . ':' . $proxypassword));
2778  }
2779  } else {
2780  $this->debug('remove proxy');
2781  $proxy = null;
2782  unsetHeader('Proxy-Authorization');
2783  }
2784  }
setHeader($name, $value)
sets an HTTP header
Definition: nusoap.php:2266
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:292
unsetHeader($name)
unsets an HTTP header
Definition: nusoap.php:2278
+ Here is the call graph for this function:

◆ setSOAPAction()

soap_transport_http::setSOAPAction (   $soapaction)

set the soapaction value

Parameters
string$soapactionpublic

Definition at line 2730 of file nusoap.php.

2731  {
2732  $this->setHeader('SOAPAction', '"' . $soapaction . '"');
2733  }
setHeader($name, $value)
sets an HTTP header
Definition: nusoap.php:2266

◆ setURL()

soap_transport_http::setURL (   $url)

sets the URL to which to connect

Parameters
string$urlThe URL to which to connect private

Definition at line 2292 of file nusoap.php.

References $path, $url, and nusoap_base\debug().

2293  {
2294  $this->url = $url;
2295 
2296  $u = parse_url($url);
2297  foreach ($u as $k => $v) {
2298  $this->debug("parsed URL $k = $v");
2299  $this->$k = $v;
2300  }
2301 
2302  // add any GET params to path
2303  if (isset($u['query']) && $u['query'] != '') {
2304  $this->path .= '?' . $u['query'];
2305  }
2306 
2307  // set default port
2308  if (!isset($u['port'])) {
2309  if ($u['scheme'] == 'https') {
2310  $this->port = 443;
2311  } else {
2312  $this->port = 80;
2313  }
2314  }
2315 
2316  $this->uri = $this->path;
2317  $this->digest_uri = $this->uri;
2318 
2319  // build headers
2320  if (!isset($u['port'])) {
2321  $this->setHeader('Host', $this->host);
2322  } else {
2323  $this->setHeader('Host', $this->host . ':' . $this->port);
2324  }
2325 
2326  if (isset($u['user']) && $u['user'] != '') {
2327  $this->setCredentials(urldecode($u['user']), isset($u['pass']) ? urldecode($u['pass']) : '');
2328  }
2329  }
setHeader($name, $value)
sets an HTTP header
Definition: nusoap.php:2266
setCredentials($username, $password, $authtype='basic', $digestRequest=array(), $certRequest=array())
if authenticating, set user credentials here
Definition: nusoap.php:2655
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:292
+ Here is the call graph for this function:

◆ unsetHeader()

soap_transport_http::unsetHeader (   $name)

unsets an HTTP header

Parameters
string$nameThe name of the header private

Definition at line 2278 of file nusoap.php.

References nusoap_base\debug().

2279  {
2280  if (isset($this->outgoing_headers[$name])) {
2281  $this->debug("unset header $name");
2282  unset($this->outgoing_headers[$name]);
2283  }
2284  }
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:292
+ Here is the call graph for this function:

◆ usePersistentConnection()

soap_transport_http::usePersistentConnection ( )

specifies that an HTTP persistent connection should be used

Returns
boolean whether the request was honored by this method. public

Definition at line 3377 of file nusoap.php.

3378  {
3379  if (isset($this->outgoing_headers['Accept-Encoding'])) {
3380  return false;
3381  }
3382  $this->protocol_version = '1.1';
3383  $this->persistentConnection = true;
3384  $this->setHeader('Connection', 'Keep-Alive');
3385  return true;
3386  }
setHeader($name, $value)
sets an HTTP header
Definition: nusoap.php:2266

Field Documentation

◆ $authtype

soap_transport_http::$authtype = ''

Definition at line 2211 of file nusoap.php.

◆ $certRequest

soap_transport_http::$certRequest = array()

Definition at line 2213 of file nusoap.php.

◆ $ch

soap_transport_http::$ch = false

Definition at line 2205 of file nusoap.php.

◆ $ch_options

soap_transport_http::$ch_options = array()

Definition at line 2206 of file nusoap.php.

◆ $digest_uri

soap_transport_http::$digest_uri = ''

Definition at line 2189 of file nusoap.php.

◆ $digestRequest

soap_transport_http::$digestRequest = array()

Definition at line 2212 of file nusoap.php.

◆ $encoding

soap_transport_http::$encoding = ''

Definition at line 2196 of file nusoap.php.

◆ $host

soap_transport_http::$host = ''

Definition at line 2191 of file nusoap.php.

◆ $incoming_cookies

soap_transport_http::$incoming_cookies = array()

Definition at line 2199 of file nusoap.php.

◆ $incoming_headers

soap_transport_http::$incoming_headers = array()

Definition at line 2198 of file nusoap.php.

◆ $incoming_payload

soap_transport_http::$incoming_payload = ''

Definition at line 2201 of file nusoap.php.

◆ $outgoing_headers

soap_transport_http::$outgoing_headers = array()

Definition at line 2197 of file nusoap.php.

◆ $outgoing_payload

soap_transport_http::$outgoing_payload = ''

Definition at line 2200 of file nusoap.php.

◆ $password

soap_transport_http::$password = ''

Definition at line 2210 of file nusoap.php.

◆ $path

soap_transport_http::$path = ''

Definition at line 2193 of file nusoap.php.

◆ $persistentConnection

soap_transport_http::$persistentConnection = false

Definition at line 2204 of file nusoap.php.

◆ $port

soap_transport_http::$port = ''

Definition at line 2192 of file nusoap.php.

◆ $protocol_version

soap_transport_http::$protocol_version = '1.0'

Definition at line 2195 of file nusoap.php.

◆ $proxy

soap_transport_http::$proxy = null

Definition at line 2208 of file nusoap.php.

◆ $request_method

soap_transport_http::$request_method = 'POST'

Definition at line 2194 of file nusoap.php.

◆ $response_status_line

soap_transport_http::$response_status_line

Definition at line 2202 of file nusoap.php.

◆ $scheme

soap_transport_http::$scheme = ''

Definition at line 2190 of file nusoap.php.

◆ $uri

soap_transport_http::$uri = ''

Definition at line 2188 of file nusoap.php.

◆ $url

soap_transport_http::$url = ''

Definition at line 2187 of file nusoap.php.

◆ $use_curl

soap_transport_http::$use_curl = false

Definition at line 2207 of file nusoap.php.

◆ $username

soap_transport_http::$username = ''

Definition at line 2209 of file nusoap.php.

◆ $useSOAPAction

soap_transport_http::$useSOAPAction = true

Definition at line 2203 of file nusoap.php.


The documentation for this class was generated from the following file: