function soap_transport_http::connect in Salesforce Suite 5
Same name in this branch
- 5 includes/nusoap.php \soap_transport_http::connect()
- 5 includes/nusoap.orig.php \soap_transport_http::connect()
Same name and namespace in other branches
- 5.2 includes/nusoap.php \soap_transport_http::connect()
- 5.2 includes/nusoap.orig.php \soap_transport_http::connect()
2 calls to soap_transport_http::connect()
- soap_transport_http::send in includes/nusoap.php
- * send the SOAP message via HTTP
*
*
- soap_transport_http::send in includes/nusoap.orig.php
- * send the SOAP message via HTTP
*
*
File
- includes/nusoap.orig.php, line 2082
Class
- soap_transport_http
- transport class for sending/receiving data via HTTP and HTTPS
NOTE: PHP must be compiled with the CURL extension for HTTPS support
Code
function connect($connection_timeout = 0, $response_timeout = 30) {
$this
->debug("connect connection_timeout {$connection_timeout}, response_timeout {$response_timeout}, scheme {$this->scheme}, host {$this->host}, port {$this->port}");
if ($this->scheme == 'http' || $this->scheme == 'ssl') {
if ($this->persistentConnection && isset($this->fp) && is_resource($this->fp)) {
if (!feof($this->fp)) {
$this
->debug('Re-use persistent connection');
return true;
}
fclose($this->fp);
$this
->debug('Closed persistent connection at EOF');
}
if ($this->scheme == 'ssl') {
$host = 'ssl://' . $this->host;
}
else {
$host = $this->host;
}
$this
->debug('calling fsockopen with host ' . $host . ' connection_timeout ' . $connection_timeout);
if ($connection_timeout > 0) {
$this->fp = @fsockopen($host, $this->port, $this->errno, $this->error_str, $connection_timeout);
}
else {
$this->fp = @fsockopen($host, $this->port, $this->errno, $this->error_str);
}
if (!$this->fp) {
$msg = 'Couldn\'t open socket connection to server ' . $this->url;
if ($this->errno) {
$msg .= ', Error (' . $this->errno . '): ' . $this->error_str;
}
else {
$msg .= ' prior to connect(). This is often a problem looking up the host name.';
}
$this
->debug($msg);
$this
->setError($msg);
return false;
}
$this
->debug('set response timeout to ' . $response_timeout);
socket_set_timeout($this->fp, $response_timeout);
$this
->debug('socket connected');
return true;
}
else {
if ($this->scheme == 'https') {
if (!extension_loaded('curl')) {
$this
->setError('CURL Extension, or OpenSSL extension w/ PHP version >= 4.3 is required for HTTPS');
return false;
}
$this
->debug('connect using https');
$this->ch = curl_init();
$hostURL = $this->port != '' ? "https://{$this->host}:{$this->port}" : "https://{$this->host}";
$hostURL .= $this->path;
curl_setopt($this->ch, CURLOPT_URL, $hostURL);
curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($this->ch, CURLOPT_HEADER, 1);
curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, 1);
if ($this->persistentConnection) {
$this->persistentConnection = false;
$this->outgoing_headers['Connection'] = 'close';
$this
->debug('set Connection: ' . $this->outgoing_headers['Connection']);
}
if ($connection_timeout != 0) {
curl_setopt($this->ch, CURLOPT_TIMEOUT, $connection_timeout);
}
curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, 0);
if ($this->authtype == 'certificate') {
if (isset($this->certRequest['cainfofile'])) {
curl_setopt($this->ch, CURLOPT_CAINFO, $this->certRequest['cainfofile']);
}
if (isset($this->certRequest['verifypeer'])) {
curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, $this->certRequest['verifypeer']);
}
else {
curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, 1);
}
if (isset($this->certRequest['verifyhost'])) {
curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, $this->certRequest['verifyhost']);
}
else {
curl_setopt($this->ch, CURLOPT_SSL_VERIFYHOST, 1);
}
if (isset($this->certRequest['sslcertfile'])) {
curl_setopt($this->ch, CURLOPT_SSLCERT, $this->certRequest['sslcertfile']);
}
if (isset($this->certRequest['sslkeyfile'])) {
curl_setopt($this->ch, CURLOPT_SSLKEY, $this->certRequest['sslkeyfile']);
}
if (isset($this->certRequest['passphrase'])) {
curl_setopt($this->ch, CURLOPT_SSLKEYPASSWD, $this->certRequest['passphrase']);
}
}
$this
->debug('cURL connection set up');
return true;
}
else {
$this
->setError('Unknown scheme ' . $this->scheme);
$this
->debug('Unknown scheme ' . $this->scheme);
return false;
}
}
}