ILIAS  trunk Revision v11.0_alpha-2645-g16283d3b3f8
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

 $fp
 
 $tryagain
 
 $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 2140 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 2187 of file nusoap.php.

References $url, ILIAS\GlobalScreen\Provider\__construct(), nusoap_base\appendDebug(), nusoap_base\debug(), and nusoap_base\varDump().

2188  {
2190  $this->debug("ctor url=$url use_curl=$use_curl curl_options:");
2191  $this->appendDebug($this->varDump($curl_options));
2192  $this->setURL($url);
2193  if (is_array($curl_options)) {
2194  $this->ch_options = $curl_options;
2195  }
2196  $this->use_curl = $use_curl;
2197  preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
2198  // begin-patch php8
2199  $this->setHeader('User-Agent', $this->title . '/' . $this->version . ' (' . ($rev[1] ?? '1.1') . ')');
2200  }
appendDebug($string)
adds debug data to the instance debug string without formatting
Definition: nusoap.php:263
setHeader($name, $value)
sets an HTTP header
Definition: nusoap.php:2223
setURL($url)
sets the URL to which to connect
Definition: nusoap.php:2249
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:250
varDump($data)
Returns a string with the output of var_dump.
Definition: nusoap.php:867
__construct(Container $dic, ilPlugin $plugin)
+ 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 2840 of file nusoap.php.

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

2841  {
2842  // Note: for cURL connections, $this->outgoing_payload is ignored,
2843  // as is the Content-Length header, but these are still created as
2844  // debugging guides.
2845 
2846  // add content-length header
2847  $this->setHeader('Content-Length', strlen($data));
2848 
2849  // start building outgoing payload:
2850  if ($this->proxy) {
2851  $uri = $this->url;
2852  } else {
2853  $uri = $this->uri;
2854  }
2855  $req = "$this->request_method $uri HTTP/$this->protocol_version";
2856  $this->debug("HTTP request: $req");
2857  $this->outgoing_payload = "$req\r\n";
2858 
2859  // loop thru headers, serializing
2860  foreach ($this->outgoing_headers as $k => $v) {
2861  $hdr = $k . ': ' . $v;
2862  $this->debug("HTTP header: $hdr");
2863  $this->outgoing_payload .= "$hdr\r\n";
2864  }
2865 
2866  // add any cookies
2867  if ($cookie_str != '') {
2868  $hdr = 'Cookie: ' . $cookie_str;
2869  $this->debug("HTTP header: $hdr");
2870  $this->outgoing_payload .= "$hdr\r\n";
2871  }
2872 
2873  // header/body separator
2874  $this->outgoing_payload .= "\r\n";
2875 
2876  // add data
2877  $this->outgoing_payload .= $data;
2878  }
setHeader($name, $value)
sets an HTTP header
Definition: nusoap.php:2223
catch(\Exception $e) $req
Definition: xapiproxy.php:91
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:250
+ 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 2313 of file nusoap.php.

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

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

References nusoap_base\debug().

2783  {
2784  // length := 0
2785  $length = 0;
2786  $new = '';
2787 
2788  // read chunk-size, chunk-extension (if any) and CRLF
2789  // get the position of the linebreak
2790  $chunkend = strpos($buffer, $lb);
2791  if ($chunkend == false) {
2792  $this->debug('no linebreak found in decodeChunked');
2793  return $new;
2794  }
2795  $temp = substr($buffer, 0, $chunkend);
2796  $chunk_size = hexdec(trim($temp));
2797  $chunkstart = $chunkend + strlen($lb);
2798  // while (chunk-size > 0) {
2799  while ($chunk_size > 0) {
2800  $this->debug("chunkstart: $chunkstart chunk_size: $chunk_size");
2801  $chunkend = strpos($buffer, $lb, $chunkstart + $chunk_size);
2802 
2803  // Just in case we got a broken connection
2804  if ($chunkend == false) {
2805  $chunk = substr($buffer, $chunkstart);
2806  // append chunk-data to entity-body
2807  $new .= $chunk;
2808  $length += strlen($chunk);
2809  break;
2810  }
2811 
2812  // read chunk-data and CRLF
2813  $chunk = substr($buffer, $chunkstart, $chunkend - $chunkstart);
2814  // append chunk-data to entity-body
2815  $new .= $chunk;
2816  // length := length + chunk-size
2817  $length += strlen($chunk);
2818  // read chunk-size and CRLF
2819  $chunkstart = $chunkend + strlen($lb);
2820 
2821  $chunkend = strpos($buffer, $lb, $chunkstart) + strlen($lb);
2822  if ($chunkend == false) {
2823  break; //Just in case we got a broken connection
2824  }
2825  $temp = substr($buffer, $chunkstart, $chunkend - $chunkstart);
2826  $chunk_size = hexdec(trim($temp));
2827  $chunkstart = $chunkend;
2828  }
2829  return $new;
2830  }
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:250
+ 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 3422 of file nusoap.php.

References $path, and nusoap_base\debug().

3423  {
3424  $cookie_str = '';
3425  if ((! is_null($cookies)) && (is_array($cookies))) {
3426  foreach ($cookies as $cookie) {
3427  if (! is_array($cookie)) {
3428  continue;
3429  }
3430  $this->debug("check cookie for validity: " . $cookie['name'] . '=' . $cookie['value']);
3431  if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
3432  if (strtotime($cookie['expires']) <= time()) {
3433  $this->debug('cookie has expired');
3434  continue;
3435  }
3436  }
3437  if ((isset($cookie['domain'])) && (! empty($cookie['domain']))) {
3438  $domain = preg_quote($cookie['domain']);
3439  if (! preg_match("'.*$domain$'i", $this->host)) {
3440  $this->debug('cookie has different domain');
3441  continue;
3442  }
3443  }
3444  if ((isset($cookie['path'])) && (! empty($cookie['path']))) {
3445  $path = preg_quote($cookie['path']);
3446  if (! preg_match("'^$path.*'i", $this->path)) {
3447  $this->debug('cookie is for a different path');
3448  continue;
3449  }
3450  }
3451  if ((! $secure) && (isset($cookie['secure'])) && ($cookie['secure'])) {
3452  $this->debug('cookie is secure, transport is not');
3453  continue;
3454  }
3455  $cookie_str .= $cookie['name'] . '=' . $cookie['value'] . '; ';
3456  $this->debug('add cookie to Cookie-String: ' . $cookie['name'] . '=' . $cookie['value']);
3457  }
3458  }
3459  return $cookie_str;
3460  }
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:250
+ 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 2946 of file nusoap.php.

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

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

2295  {
2296  if ($this->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'ntlm') || ($this->scheme == 'http' && is_array($this->proxy) && $this->proxy['authtype'] == 'ntlm')) {
2297  return 'curl';
2298  }
2299  if (($this->scheme == 'http' || $this->scheme == 'ssl') && $this->authtype != 'ntlm' && (!is_array($this->proxy) || $this->proxy['authtype'] != 'ntlm')) {
2300  return 'socket';
2301  }
2302  return 'unknown';
2303  }

◆ 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 2752 of file nusoap.php.

References $data.

2753  {
2754  $skipHeaders = array( 'HTTP/1.1 100',
2755  'HTTP/1.0 301',
2756  'HTTP/1.1 301',
2757  'HTTP/1.0 302',
2758  'HTTP/1.1 302',
2759  'HTTP/1.0 401',
2760  'HTTP/1.1 401',
2761  'HTTP/1.0 200 Connection established');
2762  foreach ($skipHeaders as $hd) {
2763  $prefix = substr($data, 0, strlen($hd));
2764  if ($prefix == $hd) {
2765  return true;
2766  }
2767  }
2768 
2769  return false;
2770  }

◆ 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 3355 of file nusoap.php.

References $data, and $path.

3356  {
3357  $cookie_str = str_replace('; ', ';', $cookie_str) . ';';
3358  // begin-patch php8
3359  //$data = split(';', $cookie_str);
3360  $data = explode(';', $cookie_str);
3361  $value_str = $data[0];
3362 
3363  $cookie_param = 'domain=';
3364  $start = strpos($cookie_str, $cookie_param);
3365  if ($start > 0) {
3366  $domain = substr($cookie_str, $start + strlen($cookie_param));
3367  $domain = substr($domain, 0, strpos($domain, ';'));
3368  } else {
3369  $domain = '';
3370  }
3371 
3372  $cookie_param = 'expires=';
3373  $start = strpos($cookie_str, $cookie_param);
3374  if ($start > 0) {
3375  $expires = substr($cookie_str, $start + strlen($cookie_param));
3376  $expires = substr($expires, 0, strpos($expires, ';'));
3377  } else {
3378  $expires = '';
3379  }
3380 
3381  $cookie_param = 'path=';
3382  $start = strpos($cookie_str, $cookie_param);
3383  if ($start > 0) {
3384  $path = substr($cookie_str, $start + strlen($cookie_param));
3385  $path = substr($path, 0, strpos($path, ';'));
3386  } else {
3387  $path = '/';
3388  }
3389 
3390  $cookie_param = ';secure;';
3391  if (strpos($cookie_str, $cookie_param) !== false) {
3392  $secure = true;
3393  } else {
3394  $secure = false;
3395  }
3396 
3397  $sep_pos = strpos($value_str, '=');
3398 
3399  if ($sep_pos) {
3400  $name = substr($value_str, 0, $sep_pos);
3401  $value = substr($value_str, $sep_pos + 1);
3402  $cookie = array( 'name' => $name,
3403  'value' => $value,
3404  'domain' => $domain,
3405  'path' => $path,
3406  'expires' => $expires,
3407  'secure' => $secure
3408  );
3409  return $cookie;
3410  }
3411  return false;
3412  }

◆ 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 2556 of file nusoap.php.

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

2557  {
2558  $this->debug('entered send() with data of length: ' . strlen($data));
2559 
2560  $this->tryagain = true;
2561  $tries = 0;
2562  while ($this->tryagain) {
2563  $this->tryagain = false;
2564  if ($tries++ < 2) {
2565  // make connnection
2566  if (!$this->connect($timeout, $response_timeout)) {
2567  return false;
2568  }
2569 
2570  // send request
2571  if (!$this->sendRequest($data, $cookies)) {
2572  return false;
2573  }
2574 
2575  // get response
2576  $respdata = $this->getResponse();
2577  } else {
2578  $this->setError("Too many tries to get an OK response ($this->response_status_line)");
2579  }
2580  }
2581  $this->debug('end of send()');
2582  return $respdata;
2583  }
connect($connection_timeout=0, $response_timeout=30)
establish an HTTP connection
Definition: nusoap.php:2313
setError($str)
sets error string
Definition: nusoap.php:353
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:250
sendRequest($data, $cookies=null)
sends the SOAP request via HTTP[S]
Definition: nusoap.php:2888
getResponse()
gets the SOAP response via HTTP[S]
Definition: nusoap.php:2946
+ 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 2597 of file nusoap.php.

References $data, and send().

2598  {
2599  return $this->send($data, $timeout, $response_timeout, $cookies);
2600  }
send($data, $timeout=0, $response_timeout=30, $cookies=null)
sends the SOAP request and gets the SOAP response via HTTP[S]
Definition: nusoap.php:2556
+ 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 2888 of file nusoap.php.

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

2889  {
2890  // build cookie string
2891  $cookie_str = $this->getCookiesForRequest($cookies, (($this->scheme == 'ssl') || ($this->scheme == 'https')));
2892 
2893  // build payload
2894  $this->buildPayload($data, $cookie_str);
2895 
2896  if ($this->io_method() == 'socket') {
2897  // send payload
2898  if (!fputs($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) {
2899  $this->setError('couldn\'t write message data to socket');
2900  $this->debug('couldn\'t write message data to socket');
2901  return false;
2902  }
2903  $this->debug('wrote data to socket, length = ' . strlen($this->outgoing_payload));
2904  return true;
2905  } elseif ($this->io_method() == 'curl') {
2906  // set payload
2907  // cURL does say this should only be the verb, and in fact it
2908  // turns out that the URI and HTTP version are appended to this, which
2909  // some servers refuse to work with (so we no longer use this method!)
2910  //$this->setCurlOption(CURLOPT_CUSTOMREQUEST, $this->outgoing_payload);
2911  $curl_headers = array();
2912  foreach ($this->outgoing_headers as $k => $v) {
2913  if ($k == 'Connection' || $k == 'Content-Length' || $k == 'Host' || $k == 'Authorization' || $k == 'Proxy-Authorization') {
2914  $this->debug("Skip cURL header $k: $v");
2915  } else {
2916  $curl_headers[] = "$k: $v";
2917  }
2918  }
2919  if ($cookie_str != '') {
2920  $curl_headers[] = 'Cookie: ' . $cookie_str;
2921  }
2922  $this->setCurlOption(CURLOPT_HTTPHEADER, $curl_headers);
2923  $this->debug('set cURL HTTP headers');
2924  if ($this->request_method == "POST") {
2925  $this->setCurlOption(CURLOPT_POST, 1);
2926  $this->setCurlOption(CURLOPT_POSTFIELDS, $data);
2927  $this->debug('set cURL POST data');
2928  } else {
2929  }
2930  // insert custom user-set cURL options
2931  foreach ($this->ch_options as $key => $val) {
2932  $this->setCurlOption($key, $val);
2933  }
2934 
2935  $this->debug('set cURL payload');
2936  return true;
2937  }
2938  }
setError($str)
sets error string
Definition: nusoap.php:353
buildPayload($data, $cookie_str='')
Writes the payload, including HTTP headers, to $this->outgoing_payload.
Definition: nusoap.php:2840
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:250
setCurlOption($option, $value)
sets a cURL option
Definition: nusoap.php:2209
getCookiesForRequest($cookies, $secure=false)
sort out cookies for the current request
Definition: nusoap.php:3422
io_method()
gets the I/O method to use
Definition: nusoap.php:2294
+ 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 3323 of file nusoap.php.

3324  {
3325  $this->setHeader('Content-Type', $type . ($charset ? '; charset=' . $charset : ''));
3326  }
setHeader($name, $value)
sets an HTTP header
Definition: nusoap.php:2223

◆ 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 2612 of file nusoap.php.

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

2613  {
2614  $this->debug("setCredentials username=$username authtype=$authtype digestRequest=");
2615  $this->appendDebug($this->varDump($digestRequest));
2616  $this->debug("certRequest=");
2617  $this->appendDebug($this->varDump($certRequest));
2618  // cf. RFC 2617
2619  if ($authtype == 'basic') {
2620  $this->setHeader('Authorization', 'Basic ' . base64_encode(str_replace(':', '', $username) . ':' . $password));
2621  } elseif ($authtype == 'digest') {
2622  if (isset($digestRequest['nonce'])) {
2623  $digestRequest['nc'] = isset($digestRequest['nc']) ? $digestRequest['nc']++ : 1;
2624 
2625  // calculate the Digest hashes (calculate code based on digest implementation found at: http://www.rassoc.com/gregr/weblog/stories/2002/07/09/webServicesSecurityHttpDigestAuthenticationWithoutActiveDirectory.html)
2626 
2627  // A1 = unq(username-value) ":" unq(realm-value) ":" passwd
2628  $A1 = $username . ':' . (isset($digestRequest['realm']) ? $digestRequest['realm'] : '') . ':' . $password;
2629 
2630  // H(A1) = MD5(A1)
2631  $HA1 = md5($A1);
2632 
2633  // A2 = Method ":" digest-uri-value
2634  $A2 = $this->request_method . ':' . $this->digest_uri;
2635 
2636  // H(A2)
2637  $HA2 = md5($A2);
2638 
2639  // KD(secret, data) = H(concat(secret, ":", data))
2640  // if qop == auth:
2641  // request-digest = <"> < KD ( H(A1), unq(nonce-value)
2642  // ":" nc-value
2643  // ":" unq(cnonce-value)
2644  // ":" unq(qop-value)
2645  // ":" H(A2)
2646  // ) <">
2647  // if qop is missing,
2648  // request-digest = <"> < KD ( H(A1), unq(nonce-value) ":" H(A2) ) > <">
2649 
2650  $unhashedDigest = '';
2651  $nonce = isset($digestRequest['nonce']) ? $digestRequest['nonce'] : '';
2652  $cnonce = $nonce;
2653  if ($digestRequest['qop'] != '') {
2654  $unhashedDigest = $HA1 . ':' . $nonce . ':' . sprintf("%08d", $digestRequest['nc']) . ':' . $cnonce . ':' . $digestRequest['qop'] . ':' . $HA2;
2655  } else {
2656  $unhashedDigest = $HA1 . ':' . $nonce . ':' . $HA2;
2657  }
2658 
2659  $hashedDigest = md5($unhashedDigest);
2660 
2661  $opaque = '';
2662  if (isset($digestRequest['opaque'])) {
2663  $opaque = ', opaque="' . $digestRequest['opaque'] . '"';
2664  }
2665 
2666  $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 . '"');
2667  }
2668  } elseif ($authtype == 'certificate') {
2669  $this->certRequest = $certRequest;
2670  $this->debug('Authorization header not set for certificate');
2671  } elseif ($authtype == 'ntlm') {
2672  // do nothing
2673  $this->debug('Authorization header not set for ntlm');
2674  }
2675  $this->username = $username;
2676  $this->password = $password;
2677  $this->authtype = $authtype;
2678  $this->digestRequest = $digestRequest;
2679  }
appendDebug($string)
adds debug data to the instance debug string without formatting
Definition: nusoap.php:263
setHeader($name, $value)
sets an HTTP header
Definition: nusoap.php:2223
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:250
varDump($data)
Returns a string with the output of var_dump.
Definition: nusoap.php:867
+ 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 2209 of file nusoap.php.

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

2210  {
2211  $this->debug("setCurlOption option=$option, value=");
2212  $this->appendDebug($this->varDump($value));
2213  curl_setopt($this->ch, $option, $value);
2214  }
appendDebug($string)
adds debug data to the instance debug string without formatting
Definition: nusoap.php:263
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:250
varDump($data)
Returns a string with the output of var_dump.
Definition: nusoap.php:867
+ 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 2698 of file nusoap.php.

2699  {
2700  if (function_exists('gzdeflate')) {
2701  $this->protocol_version = '1.1';
2702  $this->setHeader('Accept-Encoding', $enc);
2703  if (!isset($this->outgoing_headers['Connection'])) {
2704  $this->setHeader('Connection', 'close');
2705  $this->persistentConnection = false;
2706  }
2707  #set_magic_quotes_runtime(0);
2708  // deprecated
2709  $this->encoding = $enc;
2710  }
2711  }
setHeader($name, $value)
sets an HTTP header
Definition: nusoap.php:2223

◆ 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 2223 of file nusoap.php.

References nusoap_base\debug().

2224  {
2225  $this->outgoing_headers[$name] = $value;
2226  $this->debug("set header $name: $value");
2227  }
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:250
+ 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 2723 of file nusoap.php.

References nusoap_base\debug(), and null.

2724  {
2725  if ($proxyhost) {
2726  $this->proxy = array(
2727  'host' => $proxyhost,
2728  'port' => $proxyport,
2729  'username' => $proxyusername,
2730  'password' => $proxypassword,
2731  'authtype' => $proxyauthtype
2732  );
2733  if ($proxyusername != '' && $proxypassword != '' && $proxyauthtype = 'basic') {
2734  $this->setHeader('Proxy-Authorization', ' Basic ' . base64_encode($proxyusername . ':' . $proxypassword));
2735  }
2736  } else {
2737  $this->debug('remove proxy');
2738  $proxy = null;
2739  unsetHeader('Proxy-Authorization');
2740  }
2741  }
setHeader($name, $value)
sets an HTTP header
Definition: nusoap.php:2223
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:250
unsetHeader($name)
unsets an HTTP header
Definition: nusoap.php:2235
+ Here is the call graph for this function:

◆ setSOAPAction()

soap_transport_http::setSOAPAction (   $soapaction)

set the soapaction value

Parameters
string$soapactionpublic

Definition at line 2687 of file nusoap.php.

2688  {
2689  $this->setHeader('SOAPAction', '"' . $soapaction . '"');
2690  }
setHeader($name, $value)
sets an HTTP header
Definition: nusoap.php:2223

◆ 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 2249 of file nusoap.php.

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

2250  {
2251  $this->url = $url;
2252 
2253  $u = parse_url($url);
2254  foreach ($u as $k => $v) {
2255  $this->debug("parsed URL $k = $v");
2256  $this->$k = $v;
2257  }
2258 
2259  // add any GET params to path
2260  if (isset($u['query']) && $u['query'] != '') {
2261  $this->path .= '?' . $u['query'];
2262  }
2263 
2264  // set default port
2265  if (!isset($u['port'])) {
2266  if ($u['scheme'] == 'https') {
2267  $this->port = 443;
2268  } else {
2269  $this->port = 80;
2270  }
2271  }
2272 
2273  $this->uri = $this->path;
2274  $this->digest_uri = $this->uri;
2275 
2276  // build headers
2277  if (!isset($u['port'])) {
2278  $this->setHeader('Host', $this->host);
2279  } else {
2280  $this->setHeader('Host', $this->host . ':' . $this->port);
2281  }
2282 
2283  if (isset($u['user']) && $u['user'] != '') {
2284  $this->setCredentials(urldecode($u['user']), isset($u['pass']) ? urldecode($u['pass']) : '');
2285  }
2286  }
setHeader($name, $value)
sets an HTTP header
Definition: nusoap.php:2223
setCredentials($username, $password, $authtype='basic', $digestRequest=array(), $certRequest=array())
if authenticating, set user credentials here
Definition: nusoap.php:2612
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:250
+ 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 2235 of file nusoap.php.

References nusoap_base\debug().

2236  {
2237  if (isset($this->outgoing_headers[$name])) {
2238  $this->debug("unset header $name");
2239  unset($this->outgoing_headers[$name]);
2240  }
2241  }
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:250
+ 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 3334 of file nusoap.php.

3335  {
3336  if (isset($this->outgoing_headers['Accept-Encoding'])) {
3337  return false;
3338  }
3339  $this->protocol_version = '1.1';
3340  $this->persistentConnection = true;
3341  $this->setHeader('Connection', 'Keep-Alive');
3342  return true;
3343  }
setHeader($name, $value)
sets an HTTP header
Definition: nusoap.php:2223

Field Documentation

◆ $authtype

soap_transport_http::$authtype = ''

Definition at line 2168 of file nusoap.php.

◆ $certRequest

soap_transport_http::$certRequest = array()

Definition at line 2170 of file nusoap.php.

◆ $ch

soap_transport_http::$ch = false

Definition at line 2162 of file nusoap.php.

◆ $ch_options

soap_transport_http::$ch_options = array()

Definition at line 2163 of file nusoap.php.

◆ $digest_uri

soap_transport_http::$digest_uri = ''

Definition at line 2146 of file nusoap.php.

◆ $digestRequest

soap_transport_http::$digestRequest = array()

Definition at line 2169 of file nusoap.php.

◆ $encoding

soap_transport_http::$encoding = ''

Definition at line 2153 of file nusoap.php.

◆ $fp

soap_transport_http::$fp

Definition at line 2142 of file nusoap.php.

◆ $host

soap_transport_http::$host = ''

Definition at line 2148 of file nusoap.php.

◆ $incoming_cookies

soap_transport_http::$incoming_cookies = array()

Definition at line 2156 of file nusoap.php.

◆ $incoming_headers

soap_transport_http::$incoming_headers = array()

Definition at line 2155 of file nusoap.php.

◆ $incoming_payload

soap_transport_http::$incoming_payload = ''

Definition at line 2158 of file nusoap.php.

◆ $outgoing_headers

soap_transport_http::$outgoing_headers = array()

Definition at line 2154 of file nusoap.php.

◆ $outgoing_payload

soap_transport_http::$outgoing_payload = ''

Definition at line 2157 of file nusoap.php.

◆ $password

soap_transport_http::$password = ''

Definition at line 2167 of file nusoap.php.

◆ $path

soap_transport_http::$path = ''

Definition at line 2150 of file nusoap.php.

◆ $persistentConnection

soap_transport_http::$persistentConnection = false

Definition at line 2161 of file nusoap.php.

◆ $port

soap_transport_http::$port = ''

Definition at line 2149 of file nusoap.php.

◆ $protocol_version

soap_transport_http::$protocol_version = '1.0'

Definition at line 2152 of file nusoap.php.

◆ $proxy

soap_transport_http::$proxy = null

Definition at line 2165 of file nusoap.php.

◆ $request_method

soap_transport_http::$request_method = 'POST'

Definition at line 2151 of file nusoap.php.

◆ $response_status_line

soap_transport_http::$response_status_line

Definition at line 2159 of file nusoap.php.

◆ $scheme

soap_transport_http::$scheme = ''

Definition at line 2147 of file nusoap.php.

◆ $tryagain

soap_transport_http::$tryagain

Definition at line 2143 of file nusoap.php.

◆ $uri

soap_transport_http::$uri = ''

Definition at line 2145 of file nusoap.php.

◆ $url

soap_transport_http::$url = ''

Definition at line 2144 of file nusoap.php.

◆ $use_curl

soap_transport_http::$use_curl = false

Definition at line 2164 of file nusoap.php.

◆ $username

soap_transport_http::$username = ''

Definition at line 2166 of file nusoap.php.

◆ $useSOAPAction

soap_transport_http::$useSOAPAction = true

Definition at line 2160 of file nusoap.php.


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