📄 copy of base.php
字号:
<?php/** * This file loads all required libraries, defines constants used across the * SOAP package, and defines the base classes that most other classes of this * package extend. * * PHP versions 4 and 5 * * LICENSE: This source file is subject to version 2.02 of the PHP license, * that is bundled with this package in the file LICENSE, and is available at * through the world-wide-web at http://www.php.net/license/2_02.txt. If you * did not receive a copy of the PHP license and are unable to obtain it * through the world-wide-web, please send a note to license@php.net so we can * mail you a copy immediately. * * @category Web Services * @package SOAP * @author Dietrich Ayala <dietrich@ganx4.com> Original Author * @author Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more * @author Chuck Hagenbuch <chuck@horde.org> Maintenance * @author Jan Schneider <jan@horde.org> Maintenance * @copyright 2003-2005 The PHP Group * @license http://www.php.net/license/2_02.txt PHP License 2.02 * @link http://pear.php.net/package/SOAP *//** * SOAP_OBJECT_STRUCT makes PEAR::SOAP use objects for SOAP structures rather * than arrays. This has been done to provide a closer match to php-soap. If * the old behaviour is needed, set to false. The old behaviour is * deprecated. * * @global bool $GLOBALS['SOAP_OBJECT_STRUCT'] */$GLOBALS['SOAP_OBJECT_STRUCT'] = true;/** * SOAP_RAW_CONVERT makes PEAR::SOAP attempt to determine what SOAP type a PHP * string COULD be. This may result in slightly better interoperability when * you are not using WSDL, and are being lazy and not using SOAP_Value to * define types for your values. * * @global bool $GLOBALS['SOAP_RAW_CONVERT'] */$GLOBALS['SOAP_RAW_CONVERT'] = false;require_once 'PEAR.php';require_once 'SOAP/Type/dateTime.php';require_once 'SOAP/Type/hexBinary.php';// optional features$GLOBALS['SOAP_options'] = array();@include_once 'Mail/mimePart.php';@include_once 'Mail/mimeDecode.php';if (class_exists('Mail_mimePart')) { $GLOBALS['SOAP_options']['Mime'] = 1; define('MAIL_MIMEPART_CRLF', "\r\n");}@include_once 'Net/DIME.php';if (class_exists('Net_DIME_Message')) { $GLOBALS['SOAP_options']['DIME'] = 1;}/** * Enable debugging information? * * @global bool $GLOBALS['SOAP_DEBUG'] * @name $SOAP_DEBUG */$GLOBALS['SOAP_DEBUG'] = false;if (!function_exists('version_compare') || version_compare(phpversion(), '4.1', '<')) { die("requires PHP 4.1 or higher\n");}if (version_compare(phpversion(), '4.1', '>=') && version_compare(phpversion(), '4.2', '<')) { define('FLOAT', 'double');} else { define('FLOAT', 'float');}if (!defined('INF')) { define('INF', 1.8e307);}if (!defined('NAN')) { define('NAN', 0.0);}define('SOAP_LIBRARY_VERSION', '0.8.0RC4');define('SOAP_LIBRARY_NAME', 'PEAR-SOAP 0.8.0RC4-devel');// Set schema version.define('SOAP_XML_SCHEMA_VERSION', 'http://www.w3.org/2001/XMLSchema');define('SOAP_XML_SCHEMA_INSTANCE', 'http://www.w3.org/2001/XMLSchema-instance');define('SOAP_XML_SCHEMA_1999', 'http://www.w3.org/1999/XMLSchema');define('SOAP_SCHEMA', 'http://schemas.xmlsoap.org/wsdl/soap/');define('SOAP_SCHEMA_ENCODING', 'http://schemas.xmlsoap.org/soap/encoding/');define('SOAP_ENVELOP', 'http://schemas.xmlsoap.org/soap/envelope/');define('SCHEMA_DISCO', 'http://schemas.xmlsoap.org/disco/');define('SCHEMA_DISCO_SCL', 'http://schemas.xmlsoap.org/disco/scl/');define('SCHEMA_SOAP', 'http://schemas.xmlsoap.org/wsdl/soap/');define('SCHEMA_SOAP_HTTP', 'http://schemas.xmlsoap.org/soap/http');define('SCHEMA_WSDL_HTTP', 'http://schemas.xmlsoap.org/wsdl/http/');define('SCHEMA_MIME', 'http://schemas.xmlsoap.org/wsdl/mime/');define('SCHEMA_WSDL', 'http://schemas.xmlsoap.org/wsdl/');define('SCHEMA_DIME', 'http://schemas.xmlsoap.org/ws/2002/04/dime/wsdl/');define('SCHEMA_CONTENT', 'http://schemas.xmlsoap.org/ws/2002/04/content-type/');define('SCHEMA_REF', 'http://schemas.xmlsoap.org/ws/2002/04/reference/');define('SOAP_DEFAULT_ENCODING', 'UTF-8');class SOAP_Base_Object extends PEAR{ /** * Store debugging information in $_debug_data? * * @see $debug_data, SOAP_Base * @var boolean $_debug_flag */ var $_debug_flag = false; /** * String containing debugging information if $_debug_flag is true. * * @access public * @see $debug_flag, SOAP_Base * @var string $_debug_data */ var $_debug_data = ''; /** * Supported encodings, limited by XML extension. * * @var array $_encodings */ var $_encodings = array('ISO-8859-1', 'US-ASCII', 'UTF-8'); /** * Fault code. * * @var string $_myfaultcode */ var $_myfaultcode = ''; /** * Recent PEAR_Error object. * * @var PEAR_Error $fault */ var $fault = null; /** * Constructor. * * @see $debug_data, _debug() * * @param string $faultcode Error code. */ function SOAP_Base_Object($faultcode = 'Client') { $this->_myfaultcode = $faultcode; $this->_debug_flag = $GLOBALS['SOAP_DEBUG']; parent::PEAR('SOAP_Fault'); } /** * Raises a SOAP error. * * Please refer to the SOAP definition for an impression of what a certain * parameter stands for. * * Use $debug_flag to store errors to the member variable $debug_data * * @see $debug_flag, $debug_data, SOAP_Fault * * @param string|object $str Error message or object. * @param string $detail Detailed error message. * @param string $actorURI * @param mixed $code * @param mixed $mode * @param mixed $options * @param boolean $skipmsg */ function &_raiseSoapFault($str, $detail = '', $actorURI = '', $code = null, $mode = null, $options = null, $skipmsg = false) { // Pass through previous faults. $is_instance = isset($this); if (is_object($str)) { $fault =& $str; } else { if (!$code) { $code = $is_instance ? $this->_myfaultcode : 'Client'; } $fault =& new SOAP_Fault($str, $code, $actorURI, $detail, $mode, $options); } if ($is_instance) { $this->fault =& $fault; } return $fault; } function __isfault() { return $this->fault != null; } function &__getfault() { return $this->fault; } /** * Adds a string to the debug data. * * @param string $string Debugging message. */ function _debug($string) { if ($this->_debug_flag) { $this->_debug_data .= get_class($this) . ': ' . str_replace('>', ">\r\n", $string) . "\n"; } }}/** * Common base class of all SOAP classes. * * @access public * @package SOAP * @author Shane Caraveo <shane@php.net> Conversion to PEAR and updates */class SOAP_Base extends SOAP_Base_Object{ var $_XMLSchema = array('http://www.w3.org/2001/XMLSchema', 'http://www.w3.org/1999/XMLSchema'); var $_XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema'; // load types into typemap array var $_typemap = array( 'http://www.w3.org/2001/XMLSchema' => array( 'string' => 'string', 'boolean' => 'boolean', 'float' => FLOAT, 'double' => FLOAT, 'decimal' => FLOAT, 'duration' => 'integer', 'dateTime' => 'string', 'time' => 'string', 'date' => 'string', 'gYearMonth' => 'integer', 'gYear' => 'integer', 'gMonthDay' => 'integer', 'gDay' => 'integer', 'gMonth' => 'integer', 'hexBinary' => 'string', 'base64Binary' => 'string', // derived datatypes 'normalizedString' => 'string', 'token' => 'string', 'language' => 'string', 'NMTOKEN' => 'string', 'NMTOKENS' => 'string', 'Name' => 'string', 'NCName' => 'string', 'ID' => 'string', 'IDREF' => 'string', 'IDREFS' => 'string', 'ENTITY' => 'string', 'ENTITIES' => 'string', 'integer' => 'integer', 'nonPositiveInteger' => 'integer', 'negativeInteger' => 'integer', 'long' => 'integer', 'int' => 'integer', 'short' => 'integer', 'byte' => 'string', 'nonNegativeInteger' => 'integer', 'unsignedLong' => 'integer', 'unsignedInt' => 'integer', 'unsignedShort' => 'integer', 'unsignedByte' => 'integer', 'positiveInteger' => 'integer', 'anyType' => 'string', 'anyURI' => 'string', 'QName' => 'string' ), 'http://www.w3.org/1999/XMLSchema' => array( 'i4' => 'integer', 'int' => 'integer', 'boolean' => 'boolean', 'string' => 'string', 'double' => FLOAT, 'float' => FLOAT, 'dateTime' => 'string', 'timeInstant' => 'string', 'base64Binary' => 'string', 'base64' => 'string', 'ur-type' => 'string' ), 'http://schemas.xmlsoap.org/soap/encoding/' => array( 'base64' => 'string', 'array' => 'array', 'Array' => 'array', 'Struct' => 'array') ); /** * Default class name to use for decoded response objects. * * @var string $_defaultObjectClassname */ var $_defaultObjectClassname = 'stdClass'; // Load namespace URIs into an array of URI => prefix. var $_namespaces; var $_namespace; var $_xmlEntities = array('&' => '&', '<' => '<', '>' => '>', "'" => ''', '"' => '"'); var $_doconversion = false; var $__attachments = array(); var $_wsdl = null; /** * True if we use section 5 encoding, or false if this is literal. * * @var boolean $_section5 */ var $_section5 = true; // Handle type to class mapping. var $_auto_translation = false; var $_type_translation = array(); /** * Constructor. * * @see $debug_data, _debug() * * @param string $faultcode Error code. */ function SOAP_Base($faultcode = 'Client') { parent::SOAP_Base_Object($faultcode); $this->_resetNamespaces(); } function _resetNamespaces() { $this->_namespaces = array( 'http://schemas.xmlsoap.org/soap/envelope/' => 'SOAP-ENV', 'http://www.w3.org/2001/XMLSchema' => 'xsd', 'http://www.w3.org/2001/XMLSchema-instance' => 'xsi', 'http://schemas.xmlsoap.org/soap/encoding/' => 'SOAP-ENC'); } /** * Sets the schema version used in the SOAP message. * * @access private * @see $_XMLSchema * * @param string $schemaVersion The schema version. */ function _setSchemaVersion($schemaVersion) { if (!in_array($schemaVersion, $this->_XMLSchema)) { return $this->_raiseSoapFault("unsuported XMLSchema $schemaVersion"); } $this->_XMLSchemaVersion = $schemaVersion; $tmpNS = array_flip($this->_namespaces); $tmpNS['xsd'] = $this->_XMLSchemaVersion; $tmpNS['xsi'] = $this->_XMLSchemaVersion . '-instance'; $this->_namespaces = array_flip($tmpNS); } function _getNamespacePrefix($ns) { if ($this->_namespace && $ns == $this->_namespace) { return ''; } if (isset($this->_namespaces[$ns])) { return $this->_namespaces[$ns]; } $prefix = 'ns' . count($this->_namespaces); $this->_namespaces[$ns] = $prefix; return $prefix; } function _getNamespaceForPrefix($prefix)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -