diff --git a/lib/class.soap_server.php b/lib/class.soap_server.php index 8f11567..f6b37e3 100644 --- a/lib/class.soap_server.php +++ b/lib/class.soap_server.php @@ -174,16 +174,12 @@ function __construct($wsdl=false){ parent::__construct(); // turn on debugging? global $debug; - global $HTTP_SERVER_VARS; if (isset($_SERVER)) { $this->debug("_SERVER is defined:"); $this->appendDebug($this->varDump($_SERVER)); - } elseif (isset($HTTP_SERVER_VARS)) { - $this->debug("HTTP_SERVER_VARS is defined:"); - $this->appendDebug($this->varDump($HTTP_SERVER_VARS)); } else { - $this->debug("Neither _SERVER nor HTTP_SERVER_VARS is defined."); + $this->debug("_SERVER is not defined."); } if (isset($debug)) { @@ -197,16 +193,7 @@ function __construct($wsdl=false){ $this->debug_flag = substr($v, 6); } } - } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) { - $qs = explode('&', $HTTP_SERVER_VARS['QUERY_STRING']); - foreach ($qs as $v) { - if (substr($v, 0, 6) == 'debug=') { - $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #2"); - $this->debug_flag = substr($v, 6); - } - } } - // wsdl if($wsdl){ $this->debug("In nusoap_server, WSDL is specified"); @@ -234,20 +221,14 @@ function __construct($wsdl=false){ * @access public */ function service($data){ - global $HTTP_SERVER_VARS; - if (isset($_SERVER['REQUEST_METHOD'])) { $rm = $_SERVER['REQUEST_METHOD']; - } elseif (isset($HTTP_SERVER_VARS['REQUEST_METHOD'])) { - $rm = $HTTP_SERVER_VARS['REQUEST_METHOD']; } else { $rm = ''; } if (isset($_SERVER['QUERY_STRING'])) { $qs = $_SERVER['QUERY_STRING']; - } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) { - $qs = $HTTP_SERVER_VARS['QUERY_STRING']; } else { $qs = ''; } @@ -318,8 +299,6 @@ function service($data){ * @access private */ function parse_http_headers() { - global $HTTP_SERVER_VARS; - $this->request = ''; $this->SOAPAction = ''; if(function_exists('getallheaders')){ @@ -381,40 +360,6 @@ function parse_http_headers() { $this->request .= "$k: $v\r\n"; $this->debug("$k: $v"); } - } elseif (is_array($HTTP_SERVER_VARS)) { - $this->debug("In parse_http_headers, use HTTP_SERVER_VARS"); - foreach ($HTTP_SERVER_VARS as $k => $v) { - if (substr($k, 0, 5) == 'HTTP_') { - $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); $k = strtolower(substr($k, 5)); - } else { - $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k))); $k = strtolower($k); - } - if ($k == 'soapaction') { - // get SOAPAction header - $k = 'SOAPAction'; - $v = str_replace('"', '', $v); - $v = str_replace('\\', '', $v); - $this->SOAPAction = $v; - } else if ($k == 'content-type') { - // get the character encoding of the incoming request - if (strpos($v, '=')) { - $enc = substr(strstr($v, '='), 1); - $enc = str_replace('"', '', $enc); - $enc = str_replace('\\', '', $enc); - if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) { - $this->xml_encoding = strtoupper($enc); - } else { - $this->xml_encoding = 'US-ASCII'; - } - } else { - // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 - $this->xml_encoding = 'ISO-8859-1'; - } - } - $this->headers[$k] = $v; - $this->request .= "$k: $v\r\n"; - $this->debug("$k: $v"); - } } else { $this->debug("In parse_http_headers, HTTP headers not accessible"); $this->setError("HTTP headers not accessible"); @@ -777,7 +722,7 @@ function send_response() { //begin code to compress payload - by John // NOTE: there is no way to know whether the Web server will also compress // this data. - if (strlen($payload) > 1024 && isset($this->headers) && isset($this->headers['accept-encoding'])) { + if (strlen($payload) > 1024 && isset($this->headers) && isset($this->headers['accept-encoding'])) { if (strstr($this->headers['accept-encoding'], 'gzip')) { if (function_exists('gzencode')) { if (isset($this->debug_flag) && $this->debug_flag) { @@ -904,7 +849,7 @@ function parseRequest($headers, $data) { function getHTTPBody($soapmsg) { return $soapmsg; } - + /** * gets the HTTP content type for the current response. * @@ -916,7 +861,7 @@ function getHTTPBody($soapmsg) { function getHTTPContentType() { return 'text/xml'; } - + /** * gets the HTTP content type charset for the current response. * returns false for non-text content types. @@ -958,8 +903,6 @@ function add_to_map($methodname,$in,$out){ * @access public */ function register($name,$in=array(),$out=array(),$namespace=false,$soapaction=false,$style=false,$use=false,$documentation='',$encodingStyle=''){ - global $HTTP_SERVER_VARS; - if($this->externalWSDLURL){ die('You cannot bind to an external WSDL file, and register methods outside of it! Please choose either WSDL or no WSDL.'); } @@ -978,13 +921,9 @@ function register($name,$in=array(),$out=array(),$namespace=false,$soapaction=fa if (isset($_SERVER)) { $SERVER_NAME = $_SERVER['SERVER_NAME']; $SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']; - $HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off'); - } elseif (isset($HTTP_SERVER_VARS)) { - $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME']; - $SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME']; - $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off'; + $HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : 'off'; } else { - $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available"); + $this->setError("_SERVER is not available"); } if ($HTTPS == '1' || $HTTPS == 'on') { $SCHEME = 'https'; @@ -1047,20 +986,13 @@ function fault($faultcode,$faultstring,$faultactor='',$faultdetail=''){ */ function configureWSDL($serviceName,$namespace = false,$endpoint = false,$style='rpc', $transport = 'http://schemas.xmlsoap.org/soap/http', $schemaTargetNamespace = false) { - global $HTTP_SERVER_VARS; - if (isset($_SERVER)) { $SERVER_NAME = $_SERVER['SERVER_NAME']; $SERVER_PORT = $_SERVER['SERVER_PORT']; $SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']; - $HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off'); - } elseif (isset($HTTP_SERVER_VARS)) { - $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME']; - $SERVER_PORT = $HTTP_SERVER_VARS['SERVER_PORT']; - $SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME']; - $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off'; + $HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : 'off'; } else { - $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available"); + $this->setError("_SERVER is not available"); } // If server name has port number attached then strip it (else port number gets duplicated in WSDL output) (occurred using lighttpd and FastCGI) $colon = strpos($SERVER_NAME,":"); @@ -1075,7 +1007,7 @@ function configureWSDL($serviceName,$namespace = false,$endpoint = false,$style= if(false == $namespace) { $namespace = "http://$SERVER_NAME/soap/$serviceName"; } - + if(false == $endpoint) { if ($HTTPS == '1' || $HTTPS == 'on') { $SCHEME = 'https'; @@ -1084,11 +1016,11 @@ function configureWSDL($serviceName,$namespace = false,$endpoint = false,$style= } $endpoint = "$SCHEME://$SERVER_NAME$SERVER_PORT$SCRIPT_NAME"; } - + if(false == $schemaTargetNamespace) { $schemaTargetNamespace = $namespace; } - + $this->wsdl = new wsdl; $this->wsdl->serviceName = $serviceName; $this->wsdl->endpoint = $endpoint; @@ -1124,4 +1056,4 @@ class soap_server extends nusoap_server { } -?> \ No newline at end of file +?> diff --git a/lib/class.soap_transport_http.php b/lib/class.soap_transport_http.php index cb1c7da..5ca3c50 100644 --- a/lib/class.soap_transport_http.php +++ b/lib/class.soap_transport_http.php @@ -122,12 +122,12 @@ function setURL($url) { $this->debug("parsed URL $k = $v"); $this->$k = $v; } - + // add any GET params to path if(isset($u['query']) && $u['query'] != ''){ $this->path .= '?' . $u['query']; } - + // set default port if(!isset($u['port'])){ if($u['scheme'] == 'https'){ @@ -136,10 +136,10 @@ function setURL($url) { $this->port = 80; } } - + $this->uri = $this->path; $this->digest_uri = $this->uri; - + // build headers if (!isset($u['port'])) { $this->setHeader('Host', $this->host); @@ -219,7 +219,7 @@ function connect($connection_timeout=0,$response_timeout=30){ } else { $this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str); } - + // test pointer if(!$this->fp) { $msg = 'Couldn\'t open socket connection to server ' . $this->url; @@ -232,7 +232,7 @@ function connect($connection_timeout=0,$response_timeout=30){ $this->setError($msg); return false; } - + // set response timeout $this->debug('set response timeout to ' . $response_timeout); socket_set_timeout( $this->fp, $response_timeout); @@ -280,10 +280,8 @@ function connect($connection_timeout=0,$response_timeout=30){ $hostURL .= $this->path; $this->setCurlOption(CURLOPT_URL, $hostURL); // follow location headers (re-directs) - if (ini_get('safe_mode') || ini_get('open_basedir')) { + if (ini_get('open_basedir')) { $this->debug('safe_mode or open_basedir set, so do not set CURLOPT_FOLLOWLOCATION'); - $this->debug('safe_mode = '); - $this->appendDebug($this->varDump(ini_get('safe_mode'))); $this->debug('open_basedir = '); $this->appendDebug($this->varDump(ini_get('open_basedir'))); } else { @@ -321,10 +319,10 @@ function connect($connection_timeout=0,$response_timeout=30){ // recent versions of cURL turn on peer/host checking by default, // while PHP binaries are not compiled with a default location for the // CA cert bundle, so disable peer/host checking. - //$this->setCurlOption(CURLOPT_CAINFO, 'f:\php-4.3.2-win32\extensions\curl-ca-bundle.crt'); + //$this->setCurlOption(CURLOPT_CAINFO, 'f:\php-4.3.2-win32\extensions\curl-ca-bundle.crt'); $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 0); $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 0); - + // support client certificates (thanks Tobias Boes, Doug Anarino, Eryan Ariobowo) if ($this->authtype == 'certificate') { $this->debug('set cURL certificate options'); @@ -411,7 +409,7 @@ function connect($connection_timeout=0,$response_timeout=30){ * @access public */ function send($data, $timeout=0, $response_timeout=30, $cookies=NULL) { - + $this->debug('entered send() with data of length: '.strlen($data)); $this->tryagain = true; @@ -423,18 +421,18 @@ function send($data, $timeout=0, $response_timeout=30, $cookies=NULL) { if (!$this->connect($timeout, $response_timeout)){ return false; } - + // send request if (!$this->sendRequest($data, $cookies)){ return false; } - + // get response $respdata = $this->getResponse(); } else { $this->setError("Too many tries to get an OK response ($this->response_status_line)"); } - } + } $this->debug('end of send()'); return $respdata; } @@ -454,7 +452,7 @@ function send($data, $timeout=0, $response_timeout=30, $cookies=NULL) { function sendHTTPS($data, $timeout=0, $response_timeout=30, $cookies) { return $this->send($data, $timeout, $response_timeout, $cookies); } - + /** * if authenticating, set user credentials here * @@ -476,21 +474,21 @@ function setCredentials($username, $password, $authtype = 'basic', $digestReques } elseif ($authtype == 'digest') { if (isset($digestRequest['nonce'])) { $digestRequest['nc'] = isset($digestRequest['nc']) ? $digestRequest['nc']++ : 1; - + // calculate the Digest hashes (calculate code based on digest implementation found at: http://www.rassoc.com/gregr/weblog/stories/2002/07/09/webServicesSecurityHttpDigestAuthenticationWithoutActiveDirectory.html) - + // A1 = unq(username-value) ":" unq(realm-value) ":" passwd $A1 = $username. ':' . (isset($digestRequest['realm']) ? $digestRequest['realm'] : '') . ':' . $password; - + // H(A1) = MD5(A1) $HA1 = md5($A1); - + // A2 = Method ":" digest-uri-value $A2 = $this->request_method . ':' . $this->digest_uri; - + // H(A2) $HA2 = md5($A2); - + // KD(secret, data) = H(concat(secret, ":", data)) // if qop == auth: // request-digest = <"> < KD ( H(A1), unq(nonce-value) @@ -501,7 +499,7 @@ function setCredentials($username, $password, $authtype = 'basic', $digestReques // ) <"> // if qop is missing, // request-digest = <"> < KD ( H(A1), unq(nonce-value) ":" H(A2) ) > <"> - + $unhashedDigest = ''; $nonce = isset($digestRequest['nonce']) ? $digestRequest['nonce'] : ''; $cnonce = $nonce; @@ -510,10 +508,10 @@ function setCredentials($username, $password, $authtype = 'basic', $digestReques } else { $unhashedDigest = $HA1 . ':' . $nonce . ':' . $HA2; } - + $hashedDigest = md5($unhashedDigest); - - $opaque = ''; + + $opaque = ''; if (isset($digestRequest['opaque'])) { $opaque = ', opaque="' . $digestRequest['opaque'] . '"'; } @@ -532,7 +530,7 @@ function setCredentials($username, $password, $authtype = 'basic', $digestReques $this->authtype = $authtype; $this->digestRequest = $digestRequest; } - + /** * set the soapaction value * @@ -542,7 +540,7 @@ function setCredentials($username, $password, $authtype = 'basic', $digestReques function setSOAPAction($soapaction) { $this->setHeader('SOAPAction', '"' . $soapaction . '"'); } - + /** * use http encoding * @@ -562,7 +560,7 @@ function setEncoding($enc='gzip, deflate') { $this->encoding = $enc; } } - + /** * set proxy info here * @@ -591,7 +589,7 @@ function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = unsetHeader('Proxy-Authorization'); } } - + /** * Test if the given string starts with a header that is to be skipped. @@ -632,7 +630,7 @@ function decodeChunked($buffer, $lb){ // length := 0 $length = 0; $new = ''; - + // read chunk-size, chunk-extension (if any) and CRLF // get the position of the linebreak $chunkend = strpos($buffer, $lb); @@ -647,7 +645,7 @@ function decodeChunked($buffer, $lb){ while ($chunk_size > 0) { $this->debug("chunkstart: $chunkstart chunk_size: $chunk_size"); $chunkend = strpos( $buffer, $lb, $chunkstart + $chunk_size); - + // Just in case we got a broken connection if ($chunkend == FALSE) { $chunk = substr($buffer,$chunkstart); @@ -656,7 +654,7 @@ function decodeChunked($buffer, $lb){ $length += strlen($chunk); break; } - + // read chunk-data and CRLF $chunk = substr($buffer,$chunkstart,$chunkend-$chunkstart); // append chunk-data to entity-body @@ -665,7 +663,7 @@ function decodeChunked($buffer, $lb){ $length += strlen($chunk); // read chunk-size and CRLF $chunkstart = $chunkend + strlen($lb); - + $chunkend = strpos($buffer, $lb, $chunkstart) + strlen($lb); if ($chunkend == FALSE) { break; //Just in case we got a broken connection @@ -676,7 +674,7 @@ function decodeChunked($buffer, $lb){ } return $new; } - + /** * Writes the payload, including HTTP headers, to $this->outgoing_payload. * @@ -721,7 +719,7 @@ function buildPayload($data, $cookie_str = '') { // header/body separator $this->outgoing_payload .= "\r\n"; - + // add data $this->outgoing_payload .= $data; } @@ -793,7 +791,7 @@ function sendRequest($data, $cookies = NULL) { */ function getResponse(){ $this->incoming_payload = ''; - + if ($this->io_method() == 'socket') { // loop until headers have been retrieved $data = ''; @@ -864,7 +862,7 @@ function getResponse(){ $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line; } } - + // loop until msg has been received if (isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked') { $content_length = 2147483647; // ignore any content-length header @@ -930,22 +928,22 @@ function getResponse(){ $this->debug('read body of length ' . strlen($data)); $this->incoming_payload .= $data; $this->debug('received a total of '.strlen($this->incoming_payload).' bytes of data from server'); - + // close filepointer if( - (isset($this->incoming_headers['connection']) && strtolower($this->incoming_headers['connection']) == 'close') || + (isset($this->incoming_headers['connection']) && strtolower($this->incoming_headers['connection']) == 'close') || (! $this->persistentConnection) || feof($this->fp)){ fclose($this->fp); $this->fp = false; $this->debug('closed socket'); } - + // connection was closed unexpectedly if($this->incoming_payload == ''){ $this->setError('no response from server'); return false; } - + // decode transfer-encoding // if(isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked'){ // if(!$data = $this->decodeChunked($data, $lb)){ @@ -956,7 +954,7 @@ function getResponse(){ // set decoded payload // $this->incoming_payload = $header_data.$lb.$lb.$data; // } - + } else if ($this->io_method() == 'curl') { // send and receive $this->debug('send and receive with cURL'); @@ -982,7 +980,7 @@ function getResponse(){ // close curl $this->debug('No cURL error, closing cURL'); curl_close($this->ch); - + // try removing skippable headers $savedata = $data; while ($this->isSkippableCurlHeader($data)) { @@ -1005,7 +1003,7 @@ function getResponse(){ } } } - + // separate content from HTTP headers if ($pos = strpos($data,"\r\n\r\n")) { $lb = "\r\n"; @@ -1065,7 +1063,7 @@ function getResponse(){ $this->debug('Server wants digest authentication'); // remove "Digest " from our elements $digestString = str_replace('Digest ', '', $this->incoming_headers['www-authenticate']); - + // parse elements into array $digestElements = explode(',', $digestString); foreach ($digestElements as $val) { @@ -1084,7 +1082,7 @@ function getResponse(){ $this->setError('HTTP authentication failed'); return false; } - + if ( ($http_status >= 300 && $http_status <= 307) || ($http_status >= 400 && $http_status <= 417) || @@ -1152,13 +1150,13 @@ function getResponse(){ } else { $this->debug('No Content-Encoding header'); } - + if(strlen($data) == 0){ $this->debug('no data after headers!'); $this->setError('no data present after HTTP headers'); return false; } - + return $data; } @@ -1230,7 +1228,7 @@ function parseCookie($cookie_str) { } else { $path = '/'; } - + $cookie_param = ';secure;'; if (strpos($cookie_str, $cookie_param) !== FALSE) { $secure = true; @@ -1249,12 +1247,12 @@ function parseCookie($cookie_str) { 'path' => $path, 'expires' => $expires, 'secure' => $secure - ); + ); return $cookie; } return false; } - + /** * sort out cookies for the current request * @@ -1304,4 +1302,4 @@ function getCookiesForRequest($cookies, $secure=false) { } -?> \ No newline at end of file +?> diff --git a/lib/class.wsdl.php b/lib/class.wsdl.php index 6f124e7..c960e36 100644 --- a/lib/class.wsdl.php +++ b/lib/class.wsdl.php @@ -6,15 +6,15 @@ /** * parses a WSDL file, allows access to it's data, other utility methods. * also builds WSDL structures programmatically. -* +* * @author Dietrich Ayala * @author Scott Nichol * @version $Id: class.wsdl.php,v 1.76 2010/04/26 20:15:08 snichol Exp $ -* @access public +* @access public */ class wsdl extends nusoap_base { // URL or filename of the root of this WSDL - var $wsdl; + var $wsdl; // define internal arrays of bindings, ports, operations, messages, etc. var $schemas = array(); var $currentSchema; @@ -32,9 +32,9 @@ class wsdl extends nusoap_base { var $opData = array(); var $status = ''; var $documentation = false; - var $endpoint = ''; + var $endpoint = ''; // array of wsdl docs to import - var $import = array(); + var $import = array(); // parser vars var $parser; var $position = 0; @@ -57,7 +57,7 @@ class wsdl extends nusoap_base { /** * constructor - * + * * @param string $wsdl WSDL document URL * @param string $proxyhost * @param string $proxyport @@ -67,7 +67,7 @@ class wsdl extends nusoap_base { * @param integer $response_timeout set the response timeout * @param array $curl_options user-specified cURL options * @param boolean $use_curl try to use cURL - * @access public + * @access public */ function __construct($wsdl = '',$proxyhost=false,$proxyport=false,$proxyusername=false,$proxypassword=false,$timeout=0,$response_timeout=30,$curl_options=null,$use_curl=false){ parent::__construct(); @@ -127,7 +127,7 @@ function fetchWSDL($wsdl) { } } } - } + } } } // WSDL imports @@ -153,18 +153,18 @@ function fetchWSDL($wsdl) { } } } - } + } } // add new data to operation data foreach($this->bindings as $binding => $bindingData) { if (isset($bindingData['operations']) && is_array($bindingData['operations'])) { foreach($bindingData['operations'] as $operation => $data) { $this->debug('post-parse data gathering for ' . $operation); - $this->bindings[$binding]['operations'][$operation]['input'] = - isset($this->bindings[$binding]['operations'][$operation]['input']) ? + $this->bindings[$binding]['operations'][$operation]['input'] = + isset($this->bindings[$binding]['operations'][$operation]['input']) ? array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[ $bindingData['portType'] ][$operation]['input']) : $this->portTypes[ $bindingData['portType'] ][$operation]['input']; - $this->bindings[$binding]['operations'][$operation]['output'] = + $this->bindings[$binding]['operations'][$operation]['output'] = isset($this->bindings[$binding]['operations'][$operation]['output']) ? array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[ $bindingData['portType'] ][$operation]['output']) : $this->portTypes[ $bindingData['portType'] ][$operation]['output']; @@ -181,16 +181,16 @@ function fetchWSDL($wsdl) { $this->bindings[$binding]['operations'][$operation]['transport'] = isset($bindingData['transport']) ? $bindingData['transport'] : ''; $this->bindings[$binding]['operations'][$operation]['documentation'] = isset($this->portTypes[ $bindingData['portType'] ][$operation]['documentation']) ? $this->portTypes[ $bindingData['portType'] ][$operation]['documentation'] : ''; $this->bindings[$binding]['operations'][$operation]['endpoint'] = isset($bindingData['endpoint']) ? $bindingData['endpoint'] : ''; - } - } + } + } } } /** * parses the wsdl document - * + * * @param string $wsdl path or URL - * @access private + * @access private */ function parseWSDL($wsdl = '') { $this->debug("parse WSDL at path=$wsdl"); @@ -200,7 +200,7 @@ function parseWSDL($wsdl = '') { $this->setError('no wsdl passed to parseWSDL()!!'); return false; } - + // parse $wsdl for url format $wsdl_props = parse_url($wsdl); @@ -243,24 +243,24 @@ function parseWSDL($wsdl = '') { $wsdl_string = ''; while ($data = fread($fp, 32768)) { $wsdl_string .= $data; - } + } fclose($fp); } else { $errstr = "Bad path to WSDL file $path"; $this->debug($errstr); $this->setError($errstr); return false; - } + } } $this->debug('Parse WSDL'); // end new code added // Create an XML parser. - $this->parser = xml_parser_create(); + $this->parser = xml_parser_create(); // Set the options for parsing the XML data. // xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); - xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); + xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); // Set the object for the parser. - xml_set_object($this->parser, $this); + xml_set_object($this->parser, $this); // Set the element handlers for the parser. xml_set_element_handler($this->parser, 'start_element', 'end_element'); xml_set_character_data_handler($this->parser, 'character_data'); @@ -277,7 +277,7 @@ function parseWSDL($wsdl = '') { $this->debug("XML payload:\n" . $wsdl_string); $this->setError($errstr); return false; - } + } // free the parser xml_parser_free($this->parser); unset($this->parser); @@ -287,15 +287,15 @@ function parseWSDL($wsdl = '') { return false; } return true; - } + } /** * start-element handler - * + * * @param string $parser XML parser object * @param string $name element name * @param string $attrs associative array of attributes - * @access private + * @access private */ function start_element($parser, $name, $attrs) { @@ -314,10 +314,10 @@ function start_element($parser, $name, $attrs) } else { // position in the total number of elements, starting from 0 $pos = $this->position++; - $depth = $this->depth++; + $depth = $this->depth++; // set self as current value for this depth $this->depth_array[$depth] = $pos; - $this->message[$pos] = array('cdata' => ''); + $this->message[$pos] = array('cdata' => ''); // process attributes if (count($attrs) > 0) { // register namespace declarations @@ -327,11 +327,11 @@ function start_element($parser, $name, $attrs) $this->namespaces[$ns_prefix] = $v; } else { $this->namespaces['ns' . (count($this->namespaces) + 1)] = $v; - } + } if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema') { $this->XMLSchemaVersion = $v; $this->namespaces['xsi'] = $v . '-instance'; - } + } } } // expand each attribute prefix to its namespace @@ -339,22 +339,22 @@ function start_element($parser, $name, $attrs) $k = strpos($k, ':') ? $this->expandQname($k) : $k; if ($k != 'location' && $k != 'soapAction' && $k != 'namespace') { $v = strpos($v, ':') ? $this->expandQname($v) : $v; - } + } $eAttrs[$k] = $v; - } + } $attrs = $eAttrs; } else { $attrs = array(); - } + } // get element prefix, namespace and name if (preg_match('/:/', $name)) { // get ns prefix - $prefix = substr($name, 0, strpos($name, ':')); + $prefix = substr($name, 0, strpos($name, ':')); // get ns - $namespace = isset($this->namespaces[$prefix]) ? $this->namespaces[$prefix] : ''; + $namespace = isset($this->namespaces[$prefix]) ? $this->namespaces[$prefix] : ''; // get unqualified name $name = substr(strstr($name, ':'), 1); - } + } // process attributes, expanding any prefixes to namespaces // find status, register data switch ($this->status) { @@ -363,12 +363,12 @@ function start_element($parser, $name, $attrs) if (isset($attrs['type'])) { $this->debug("msg " . $this->currentMessage . ": found part (with type) $attrs[name]: " . implode(',', $attrs)); $this->messages[$this->currentMessage][$attrs['name']] = $attrs['type']; - } + } if (isset($attrs['element'])) { $this->debug("msg " . $this->currentMessage . ": found part (with element) $attrs[name]: " . implode(',', $attrs)); $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'] . '^'; - } - } + } + } break; case 'portType': switch ($name) { @@ -377,25 +377,25 @@ function start_element($parser, $name, $attrs) $this->debug("portType $this->currentPortType operation: $this->currentPortOperation"); if (isset($attrs['parameterOrder'])) { $this->portTypes[$this->currentPortType][$attrs['name']]['parameterOrder'] = $attrs['parameterOrder']; - } + } break; case 'documentation': $this->documentation = true; - break; + break; // merge input/output data default: $m = isset($attrs['message']) ? $this->getLocalPart($attrs['message']) : ''; $this->portTypes[$this->currentPortType][$this->currentPortOperation][$name]['message'] = $m; break; - } + } break; case 'binding': switch ($name) { - case 'binding': + case 'binding': // get ns prefix if (isset($attrs['style'])) { $this->bindings[$this->currentBinding]['prefix'] = $prefix; - } + } $this->bindings[$this->currentBinding] = array_merge($this->bindings[$this->currentBinding], $attrs); break; case 'header': @@ -404,17 +404,17 @@ function start_element($parser, $name, $attrs) case 'operation': if (isset($attrs['soapAction'])) { $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['soapAction'] = $attrs['soapAction']; - } + } if (isset($attrs['style'])) { $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['style'] = $attrs['style']; - } + } if (isset($attrs['name'])) { $this->currentOperation = $attrs['name']; $this->debug("current binding operation: $this->currentOperation"); $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['name'] = $attrs['name']; $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['binding'] = $this->currentBinding; $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['endpoint'] = isset($this->bindings[$this->currentBinding]['endpoint']) ? $this->bindings[$this->currentBinding]['endpoint'] : ''; - } + } break; case 'input': $this->opStatus = 'input'; @@ -427,9 +427,9 @@ function start_element($parser, $name, $attrs) $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = array_merge($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus], $attrs); } else { $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = $attrs; - } + } break; - } + } break; case 'service': switch ($name) { @@ -437,7 +437,7 @@ function start_element($parser, $name, $attrs) $this->currentPort = $attrs['name']; $this->debug('current port: ' . $this->currentPort); $this->ports[$this->currentPort]['binding'] = $this->getLocalPart($attrs['binding']); - + break; case 'address': $this->ports[$this->currentPort]['location'] = $attrs['location']; @@ -445,9 +445,9 @@ function start_element($parser, $name, $attrs) $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['bindingType'] = $namespace; $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['endpoint'] = $attrs['location']; break; - } + } break; - } + } // set status switch ($name) { case 'import': @@ -483,11 +483,11 @@ function start_element($parser, $name, $attrs) $this->currentBinding = $this->getLocalPart($attrs['name']); } else { $this->currentBinding = $attrs['name']; - } + } $this->status = 'binding'; $this->bindings[$this->currentBinding]['portType'] = $this->getLocalPart($attrs['type']); $this->debug("current binding: $this->currentBinding of portType: " . $attrs['type']); - } + } break; case 'service': $this->serviceName = $attrs['name']; @@ -497,20 +497,20 @@ function start_element($parser, $name, $attrs) case 'definitions': foreach ($attrs as $name => $value) { $this->wsdl_info[$name] = $value; - } + } break; - } - } - } + } + } + } /** * end-element handler - * + * * @param string $parser XML parser object * @param string $name element name - * @access private + * @access private */ - function end_element($parser, $name){ + function end_element($parser, $name){ // unset schema status if (/*preg_match('/types$/', $name) ||*/ preg_match('/schema$/', $name)) { $this->status = ""; @@ -518,38 +518,38 @@ function end_element($parser, $name){ $this->currentSchema->clearDebug(); $this->schemas[$this->currentSchema->schemaTargetNamespace][] = $this->currentSchema; $this->debug('Parsing WSDL schema done'); - } + } if ($this->status == 'schema') { $this->currentSchema->schemaEndElement($parser, $name); } else { // bring depth down a notch $this->depth--; - } + } // end documentation if ($this->documentation) { //TODO: track the node to which documentation should be assigned; it can be a part, message, etc. //$this->portTypes[$this->currentPortType][$this->currentPortOperation]['documentation'] = $this->documentation; $this->documentation = false; - } - } + } + } /** * element content handler - * + * * @param string $parser XML parser object * @param string $data element content - * @access private + * @access private */ function character_data($parser, $data) { $pos = isset($this->depth_array[$this->depth]) ? $this->depth_array[$this->depth] : 0; if (isset($this->message[$pos]['cdata'])) { $this->message[$pos]['cdata'] .= $data; - } + } if ($this->documentation) { $this->documentation .= $data; - } - } + } + } /** * if authenticating, set user credentials here @@ -568,21 +568,21 @@ function setCredentials($username, $password, $authtype = 'basic', $certRequest $this->authtype = $authtype; $this->certRequest = $certRequest; } - + function getBindingData($binding) { if (is_array($this->bindings[$binding])) { return $this->bindings[$binding]; - } + } } - + /** * returns an assoc array of operation names => operation data - * + * * @param string $portName WSDL port name * @param string $bindingType eg: soap, smtp, dime (only soap and soap12 are currently supported) - * @return array - * @access public + * @return array + * @access public */ function getOperations($portName = '', $bindingType = 'soap') { $ops = array(); @@ -614,15 +614,15 @@ function getOperations($portName = '', $bindingType = 'soap') { $this->debug("getOperations found no operations for port '$portName' bindingType $bindingType"); } return $ops; - } - + } + /** * returns an associative array of data necessary for calling an operation - * + * * @param string $operation name of operation * @param string $bindingType type of binding eg: soap, soap12 - * @return array - * @access public + * @return array + * @access public */ function getOperationData($operation, $bindingType = 'soap') { @@ -642,19 +642,19 @@ function getOperationData($operation, $bindingType = 'soap') if ($operation == $bOperation) { $opData = $this->bindings[ $portData['binding'] ]['operations'][$operation]; return $opData; - } - } + } + } } - } + } } - + /** * returns an associative array of data necessary for calling an operation - * + * * @param string $soapAction soapAction for operation * @param string $bindingType type of binding eg: soap, soap12 - * @return array - * @access public + * @return array + * @access public */ function getOperationDataForSoapAction($soapAction, $bindingType = 'soap') { if ($bindingType == 'soap') { @@ -670,12 +670,12 @@ function getOperationDataForSoapAction($soapAction, $bindingType = 'soap') { foreach ($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) { if ($opData['soapAction'] == $soapAction) { return $opData; - } - } + } + } } - } + } } - + /** * returns an array of information about a given type * returns false if no type exists by the given name @@ -755,16 +755,14 @@ function getTypeDef($type, $ns) { * @access private */ function webDescription(){ - global $HTTP_SERVER_VARS; - if (isset($_SERVER)) { - $PHP_SELF = $_SERVER['PHP_SELF']; - } elseif (isset($HTTP_SERVER_VARS)) { - $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF']; + $this->debug("_SERVER is defined:"); + $this->appendDebug($this->varDump($_SERVER)); } else { - $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available"); + $this->debug("_SERVER is not defined."); } + $b = ' NuSOAP: '.$this->serviceName.'