nusoap.php.bak
来自「php源码 php源码参考」· BAK 代码 · 共 2,142 行 · 第 1/5 页
BAK
2,142 行
// finalize complex type if($contentStr != ''){ $contentStr = "<$schemaPrefix:complexType name=\"$typeName\">".$contentStr."</$schemaPrefix:complexType>"; } else { $contentStr = "<$schemaPrefix:complexType name=\"$typeName\"/>"; } $xml .= $contentStr; } // elements if(isset($this->elements) && count($this->elements) > 0){ foreach($this->elements as $element => $eParts){ $xml .= "<$schemaPrefix:element name=\"$element\" type=\"".$eParts['type']."\"/>"; } } // attributes if(isset($this->attributes) && count($this->attributes) > 0){ foreach($this->attributes as $attr => $aParts){ $xml .= "<$schemaPrefix:attribute name=\"$attr\" type=\"".$aParts['type']."\"/>"; } } // finish 'er up $xml = "<$schemaPrefix:schema xmlns=\"$this->XMLSchemaVersion\" targetNamespace=\"$this->schemaTargetNamespace\">".$xml."</$schemaPrefix:schema>"; return $xml; } /** * expands a qualified name * * @param string $string qname * @return string expanded qname * @access private */ function expandQname($qname){ // get element prefix if(strpos($qname,':') && !ereg('^http://',$qname)){ // get unqualified name $name = substr(strstr($qname,':'),1); // get ns prefix $prefix = substr($qname,0,strpos($qname,':')); if(isset($this->namespaces[$prefix])){ return $this->namespaces[$prefix].':'.$name; } else { return $qname; } } else { return $qname; } } /** * adds debug data to the clas level debug string * * @param string $string debug data * @access private */ function xdebug($string){ $this->debug(' xmlschema: '.$string); } /** * get the PHP type of a user defined type in the schema * PHP type is kind of a misnomer since it actually returns 'struct' for assoc. arrays * returns false if no type exists, or not w/ the given namespace * else returns a string that is either a native php type, or 'struct' * * @param string $type, name of defined type * @param string $ns, namespace of type * @return mixed * @access public */ function getPHPType($type,$ns){ global $typemap; if(isset($typemap[$ns][$type])){ //print "found type '$type' and ns $ns in typemap<br>"; return $typemap[$ns][$type]; } elseif(isset($this->complexTypes[$type])){ //print "getting type '$type' and ns $ns from complexTypes array<br>"; return $this->complexTypes[$type]['phpType']; } return false; } /** * returns the local part of a prefixed string * returns the original string, if not prefixed * * @param string * @return string * @access public */ function getLocalPart($str){ if($sstr = strrchr($str,':')){ // get unqualified name return substr( $sstr, 1 ); } else { return $str; } } /** * returns the prefix part of a prefixed string * returns false, if not prefixed * * @param string * @return mixed * @access public */ function getPrefix($str){ if($pos = strrpos($str,':')){ // get prefix return substr($str,0,$pos); } return false; } /** * pass it a prefix, it returns a namespace * returns false if no namespace registered with the given prefix * * @param string * @return mixed * @access public */ function getNamespaceFromPrefix($prefix){ if(isset($this->namespaces[$prefix])){ return $this->namespaces[$prefix]; } //$this->setError("No namespace registered for prefix '$prefix'"); return false; } /** * returns the prefix for a given namespace (or prefix) * or false if no prefixes registered for the given namespace * * @param string * @return mixed * @access public */ function getPrefixFromNamespace($ns){ foreach($this->namespaces as $p => $n){ if($ns == $n || $ns == $p){ $this->usedNamespaces[$p] = $ns; return $p; } } return false; } /** * returns an array of information about a given type * returns false if no type exists by the given name * * typeDef = array( * 'elements' => array(), // refs to elements array * 'restrictionBase' => '', * 'phpType' => '', * 'order' => '(sequence|all)', * 'attrs' => array() // refs to attributes array * ) * * @param string * @return mixed * @access public */ function getTypeDef($type){ if(isset($this->complexTypes[$type])){ return $this->complexTypes[$type]; } elseif(isset($this->elements[$type])){ return $this->elements[$type]; } elseif(isset($this->attributes[$type])){ return $this->attributes[$type]; } return false; } /** * returns a sample serialization of a given type, or false if no type by the given name * * @param string $type, name of type * @return mixed * @access public */ function serializeTypeDef($type){ //print "in sTD() for type $type<br>"; if($typeDef = $this->getTypeDef($type)){ $str .= '<'.$type; if(is_array($typeDef['attrs'])){ foreach($attrs as $attName => $data){ $str .= " $attName=\"{type = ".$data['type']."}\""; } } $str .= " xmlns=\"".$this->schema['targetNamespace']."\""; if(count($typeDef['elements']) > 0){ $str .= ">"; foreach($typeDef['elements'] as $element => $eData){ $str .= $this->serializeTypeDef($element); } $str .= "</$type>"; } elseif($typeDef['typeClass'] == 'element') { $str .= "></$type>"; } else { $str .= "/>"; } return $str; } return false; } /** * returns HTML form elements that allow a user * to enter values for creating an instance of the given type. * * @param string $name, name for type instance * @param string $type, name of type * @return string * @access public */ function typeToForm($name,$type){ // get typedef if($typeDef = $this->getTypeDef($type)){ // if struct if($typeDef['phpType'] == 'struct'){ $buffer .= '<table>'; foreach($typeDef['elements'] as $child => $childDef){ $buffer .= " <tr><td align='right'>$childDef[name] (type: ".$this->getLocalPart($childDef['type'])."):</td> <td><input type='text' name='parameters[".$name."][$childDef[name]]'></td></tr>"; } $buffer .= '</table>'; // if array } elseif($typeDef['phpType'] == 'array'){ $buffer .= '<table>'; for($i=0;$i < 3; $i++){ $buffer .= " <tr><td align='right'>array item (type: $typeDef[arrayType]):</td> <td><input type='text' name='parameters[".$name."][]'></td></tr>"; } $buffer .= '</table>'; // if scalar } else { $buffer .= "<input type='text' name='parameters[$name]'>"; } } else { $buffer .= "<input type='text' name='parameters[$name]'>"; } return $buffer; } /** * adds an XML Schema complex type to the WSDL types * * example: array * * addType( * 'ArrayOfstring', * 'complexType', * 'array', * '', * 'SOAP-ENC:Array', * array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'string[]'), * 'xsd:string' * ); * * example: PHP associative array ( SOAP Struct ) * * addType( * 'SOAPStruct', * 'complexType', * 'struct', * 'all', * array('myVar'=> array('name'=>'myVar','type'=>'string') * ); * * @param name * @param typeClass (complexType|simpleType|attribute) * @param phpType: currently supported are array and struct (php assoc array) * @param compositor (all|sequence|choice) * @param restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) * @param elements = array ( name = array(name=>'',type=>'') ) * @param attrs = array( * array( * 'ref' => "http://schemas.xmlsoap.org/soap/encoding/:arrayType", * "http://schemas.xmlsoap.org/wsdl/:arrayType" => "string[]" * ) * ) * @param arrayType: namespace:name (http://www.w3.org/2001/XMLSchema:string) * */ function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType=''){ $this->complexTypes[$name] = array( 'name' => $name, 'typeClass' => $typeClass, 'phpType' => $phpType, 'compositor'=> $compositor, 'restrictionBase' => $restrictionBase, 'elements' => $elements, 'attrs' => $attrs, 'arrayType' => $arrayType ); }}?><?php/*** for creating serializable abstractions of native PHP types* NOTE: this is only really used when WSDL is not available.** @author Dietrich Ayala <dietrich@ganx4.com>* @version v 0.6.3* @access public*/class soapval extends nusoap_base { /** * constructor * * @param string $name optional name * @param string $type optional type name * @param mixed $value optional value * @param string $namespace optional namespace of value * @param string $type_namespace optional namespace of type * @param array $attributes associative array of attributes to add to element serialization * @access public */ function soapval($name='soapval',$type=false,$value=-1,$element_ns=false,$type_ns=false,$attributes=false) { $this->name = $name; $this->value = $value; $this->type = $type; $this->element_ns = $element_ns; $this->type_ns = $type_ns; $this->attributes = $attributes; } /** * return serialized value * * @return string XML data * @access private */ function serialize() { return $this->serialize_val($this->value,$this->name,$this->type,$this->element_ns,$this->type_ns,$this->attributes); } /** * decodes a soapval object into a PHP native type * * @param object $soapval optional SOAPx4 soapval object, else uses self * @return mixed * @access public */ function decode(){ return $this->value; }}?><?php/*** 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 <dietrich@ganx4.com>* @version v 0.6.3* @access public*/class soap_transport_http extends nusoap_base { var $username = ''; var $password = ''; var $url = ''; var $proxyhost = ''; var $proxyport = ''; var $scheme = ''; var $protocol_version = '1.0'; var $encoding = ''; var $outgoing_payload = ''; var $incoming_payload = ''; /** * constructor */ function soap_transport_http($url){ $this->url = $url; $u = parse_url($url); foreach($u as $k => $v){ $this->debug("$k = $v"); $this->$k = $v; } if(isset($u['query']) && $u['query'] != ''){ $this->path .= '?' . $u['query']; } if(!isset($u['port']) && $u['scheme'] == 'http'){ $this->port = 80; } } /** * if authenticating, set user credentials here * * @param string $user * @param string $pass * @access public */ function setCredentials($username, $password) { $this->username = $username; $this->password = $password; } /** * set the soapaction value * * @param string $soapaction * @access public */ function setSOAPAction($soapaction) { $this->soapaction = $soapaction; } /** * set proxy info here * * @param string $proxyhost * @param string $proxyport * @access public */ function setProxy($proxyhost, $proxyport) { $this->proxyhost = $proxyhost; $this->proxyport = $proxyport;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?