PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Web Services » SOAP » Bug #7386

WSDL should use SOAP

Details

Submitted2006-04-13 03:19 UTC
Fromandrew dot meee at abr dot com dot au
Assignedyunosh
StatusWont fix
PackageSOAP
PHP Version4.4.1
OSAll
Roadmaps(Not assigned)

Comments

[2006-04-13 03:19 UTC] andrew dot meee at abr dot com dot au

Description:
------------
In the WSDL.php file it uses HTTP request which does not allow for advanced SSL request (The code comments state this...)
Attached is an example patch (that will need testing to improve this. It also handles using the old proxy params.

Test script:
---------------
Line 973 onwards...

if (isset($proxy_params['proxy_host'])){
$proxy_params[CURLOPT_PROXY]=$proxy_params['proxy_host'];
unset($proxy_params['proxy_host']);
}
if (isset($proxy_params['proxy_port'])){
$proxy_params[CURLOPT_PROXYPORT]=$proxy_params['proxy_port'];
unset($proxy_params['proxy_port']);
}
if (isset($proxy_params['proxy_user'])){
$proxy_params[CURLOPT_PROXYUSERPWD]=$proxy_params['proxy_user']
.':'.$proxy_params['proxy_pass'];
unset($proxy_params['proxy_user']);
unset($proxy_params['proxy_pass']);
}

$ch = curl_init($wsdl_fname);

foreach($proxy_params as $option=>$value)
{
curl_setopt($ch,$option,$value);
}
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_VERBOSE,1);

$file_data = curl_exec($ch);
if (!$file_data) {
return $this->_raiseSoapFault("Unable to retrieve WSDL $wsdl_fname, no http body", $wsdl_fname);
$result = curl_error($ch);
curl_close($ch);

if (PEAR::isError($result)) {
return $this->_raiseSoapFault("Unable to retrieve WSDL $wsdl_fname," . $rq->getResponseCode(), $wsdl_fname);
}

[2006-04-13 04:09 UTC] andrew dot meee at abr dot com dot au

Having a think about this further this change, as it does not match function _sendHTTPS($msg, $options) in HTTP.inc due to the $option['curl']. It may be better to work the options the same way or use a similar method to handle this.

[2006-04-13 04:21 UTC] andrew dot meee at abr dot com dot au

Here is an Improved Bug Fix...From Line 963 in WSDL.inc

---
if (!preg_match('/^(https?|file):\/\//', $wsdl_fname)) {
if (!file_exists($wsdl_fname)) {
return $this->_raiseSoapFault("Unable to read local WSDL $wsdl_fname", $wsdl_fname);
}
if (function_exists('file_get_contents')) {
$file_data = file_get_contents($wsdl_fname);
} else {
$file_data = implode('',file($wsdl_fname));
}
} else if (preg_match('/^https:\/\//', $wsdl_fname)) {
if (!extension_loaded('curl')) {
return $this->_raiseSoapFault('CURL Extension is required for HTTPS');
}

$ch = curl_init($wsdl_fname);

if (isset($proxy_params['proxy_host'])) {
$host = $proxy_params['proxy_host'];
$port = isset($proxy_params['proxy_port']) ? $proxy_params['proxy_port'] : 8080;
curl_setopt($ch, CURLOPT_PROXY, $host . ":" . $port);
}

if (isset($proxy_params['proxy_user'])) {
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxy_params['proxy_user'] . ':' . $proxy_params['proxy_pass']);
}

if (isset($proxy_params['user'])) {
curl_setopt($ch, CURLOPT_USERPWD, $proxy_params['user'] . ':' . $proxy_params['pass']);
}

if (!isset($proxy_params['soapaction'])) {
$proxy_params['soapaction'] = '';
}
curl_setopt($ch, CURLOPT_HTTPHEADER , array('Content-Type: text/xml;charset=' . $this->encoding, 'SOAPAction: "'.$proxy_params['soapaction'].'"'));
curl_setopt($ch, CURLOPT_USERAGENT , $this->_userAgent);

if ($this->timeout) {
curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout); //times out after 4s
}

curl_setopt($ch, CURLOPT_FAILONERROR, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
if (defined('CURLOPT_HTTP_VERSION')) {
curl_setopt($ch, CURLOPT_HTTP_VERSION, 1);
}

if (isset($options['curl'])) {
foreach ($proxy_params['curl'] as $key => $val) {
curl_setopt($ch, $key, $val);
}
}

$file_data = curl_exec($ch);
if (!$file_data) {
return $this->_raiseSoapFault("Unable to retrieve WSDL $wsdl_fname, no http body", $wsdl_fname);
$result = curl_error($ch);
curl_close($ch);

if (PEAR::isError($result)) {
return $this->_raiseSoapFault("Unable to retrieve WSDL $wsdl_fname," . $rq->getResponseCode(), $wsdl_fname);
}