ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
nusoap_parser Class Reference

nusoap_parser class parses SOAP XML messages into native PHP values More...

+ Inheritance diagram for nusoap_parser:
+ Collaboration diagram for nusoap_parser:

Public Member Functions

 __construct ($xml, $encoding='UTF-8', $method='', $decode_utf8=true)
 constructor that actually does the parsing More...
 
 start_element ($parser, $name, $attrs)
 start-element handler More...
 
 end_element ($parser, $name)
 end-element handler More...
 
 character_data ($parser, $data)
 element content handler More...
 
 get_response ()
 get the parsed message (SOAP Body) More...
 
 get_soapbody ()
 get the parsed SOAP Body (NULL if there was none) More...
 
 get_soapheader ()
 get the parsed SOAP Header (NULL if there was none) More...
 
 getHeaders ()
 get the unparsed SOAP Header More...
 
 decodeSimple ($value, $type, $typens)
 decodes simple types into PHP variables More...
 
 buildVal ($pos)
 builds response structures for compound values (arrays/structs) and scalars More...
 
- Public Member Functions inherited from nusoap_base
 debug ($string)
 adds debug data to the class level debug string More...
 
 expandEntities ($val)
 expands entities, e.g. More...
 
 getError ()
 returns error string if present More...
 
 setError ($str)
 sets error string More...
 
 isArraySimpleOrStruct ($val)
 detect if array is a simple array or a struct (associative array) More...
 
 serialize_val ($val, $name=false, $type=false, $name_ns=false, $type_ns=false, $attributes=false, $use='encoded')
 
 serializeEnvelope ($body, $headers=false, $namespaces=array(), $style='rpc', $use='encoded')
 serialize message More...
 
 formatDump ($str)
 
 contractQname ($qname)
 contracts a qualified name More...
 
 expandQname ($qname)
 expands a qualified name More...
 
 getLocalPart ($str)
 returns the local part of a prefixed string returns the original string, if not prefixed More...
 
 getPrefix ($str)
 returns the prefix part of a prefixed string returns false, if not prefixed More...
 
 getNamespaceFromPrefix ($prefix)
 pass it a prefix, it returns a namespace returns false if no namespace registered with the given prefix More...
 
 getPrefixFromNamespace ($ns)
 returns the prefix for a given namespace (or prefix) or false if no prefixes registered for the given namespace More...
 
 varDump ($data)
 
 __construct ()
 constructor More...
 
 getGlobalDebugLevel ()
 gets the global debug level, which applies to future instances More...
 
 setGlobalDebugLevel ($level)
 sets the global debug level, which applies to future instances More...
 
 getDebugLevel ()
 gets the debug level for this instance More...
 
 setDebugLevel ($level)
 sets the debug level for this instance More...
 
 debug ($string)
 adds debug data to the instance debug string with formatting More...
 
 appendDebug ($string)
 adds debug data to the instance debug string without formatting More...
 
 clearDebug ()
 clears the current debug data for this instance More...
 
getDebug ()
 gets the current debug data for this instance More...
 
getDebugAsXMLComment ()
 gets the current debug data for this instance as an XML comment this may change the contents of the debug data More...
 
 expandEntities ($val)
 expands entities, e.g. More...
 
 getError ()
 returns error string if present More...
 
 setError ($str)
 sets error string More...
 
 isArraySimpleOrStruct ($val)
 detect if array is a simple array or a struct (associative array) More...
 
 serialize_val ($val, $name=false, $type=false, $name_ns=false, $type_ns=false, $attributes=false, $use='encoded', $soapval=false)
 
 serializeEnvelope ($body, $headers=false, $namespaces=array(), $style='rpc', $use='encoded', $encodingStyle='http://schemas.xmlsoap.org/soap/encoding/')
 serializes a message More...
 
 formatDump ($str)
 formats a string to be inserted into an HTML stream More...
 
 contractQname ($qname)
 contracts (changes namespace to prefix) a qualified name More...
 
 expandQname ($qname)
 expands (changes prefix to namespace) a qualified name More...
 
 getLocalPart ($str)
 returns the local part of a prefixed string returns the original string, if not prefixed More...
 
 getPrefix ($str)
 returns the prefix part of a prefixed string returns false, if not prefixed More...
 
 getNamespaceFromPrefix ($prefix)
 pass it a prefix, it returns a namespace More...
 
 getPrefixFromNamespace ($ns)
 returns the prefix for a given namespace (or prefix) or false if no prefixes registered for the given namespace More...
 
 getmicrotime ()
 returns the time in ODBC canonical form with microseconds More...
 
 varDump ($data)
 Returns a string with the output of var_dump. More...
 
 __toString ()
 represents the object as a string More...
 

Data Fields

 $xml = ''
 
 $xml_encoding = ''
 
 $method = ''
 
 $root_struct = ''
 
 $root_struct_name = ''
 
 $root_struct_namespace = ''
 
 $root_header = ''
 
 $document = ''
 
 $status = ''
 
 $position = 0
 
 $depth = 0
 
 $default_namespace = ''
 
 $namespaces = array()
 
 $message = array()
 
 $parent = ''
 
 $fault = false
 
 $fault_code = ''
 
 $fault_str = ''
 
 $fault_detail = ''
 
 $depth_array = array()
 
 $debug_flag = true
 
 $soapresponse = NULL
 
 $soapheader = NULL
 
 $responseHeaders = ''
 
 $body_position = 0
 
 $ids = array()
 
 $multirefs = array()
 
 $decode_utf8 = true
 
- Data Fields inherited from nusoap_base
 $title = 'NuSOAP'
 
 $version = '0.6.7'
 
 $revision = '$Revision$'
 
 $error_str = false
 Current error string (manipulated by getError/setError) More...
 
 $debug_str = ''
 Current debug string (manipulated by debug/appendDebug/clearDebug/getDebug/getDebugAsXMLComment) More...
 
 $charencoding = true
 
 $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema'
 
 $soap_defencoding = 'UTF-8'
 
 $namespaces
 
 $usedNamespaces = array()
 
 $typemap
 
 $xmlEntities
 
 $debugLevel
 

Detailed Description

nusoap_parser class parses SOAP XML messages into native PHP values

Author
Dietrich Ayala dietr.nosp@m.ich@.nosp@m.ganx4.nosp@m..com
Scott Nichol snich.nosp@m.ol@u.nosp@m.sers..nosp@m.sour.nosp@m.cefor.nosp@m.ge.n.nosp@m.et
Version
$Id$ @access public

Definition at line 6417 of file nusoap.php.

Constructor & Destructor Documentation

◆ __construct()

nusoap_parser::__construct (   $xml,
  $encoding = 'UTF-8',
  $method = '',
  $decode_utf8 = true 
)

constructor that actually does the parsing

Parameters
string$xmlSOAP message
string$encodingcharacter encoding scheme of message
string$methodmethod for which XML is parsed (unused?)
string$decode_utf8whether to decode UTF-8 to ISO-8859-1 @access public

Definition at line 6462 of file nusoap.php.

6462 {
6463 parent::__construct();
6464 $this->xml = $xml;
6465 $this->xml_encoding = $encoding;
6466 $this->method = $method;
6467 $this->decode_utf8 = $decode_utf8;
6468
6469 // Check whether content has been read.
6470 if(!empty($xml)){
6471 // Check XML encoding
6472 $pos_xml = strpos($xml, '<?xml');
6473 if ($pos_xml !== FALSE) {
6474 $xml_decl = substr($xml, $pos_xml, strpos($xml, '?>', $pos_xml + 2) - $pos_xml + 1);
6475 if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) {
6476 $xml_encoding = $res[1];
6477 if (strtoupper($xml_encoding) != $encoding) {
6478 $err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'";
6479 $this->debug($err);
6480 if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') {
6481 $this->setError($err);
6482 return;
6483 }
6484 // when HTTP says ISO-8859-1 (the default) and XML says UTF-8 (the typical), assume the other endpoint is just sloppy and proceed
6485 } else {
6486 $this->debug('Charset from HTTP Content-Type matches encoding from XML declaration');
6487 }
6488 } else {
6489 $this->debug('No encoding specified in XML declaration');
6490 }
6491 } else {
6492 $this->debug('No XML declaration');
6493 }
6494 $this->debug('Entering nusoap_parser(), length='.strlen($xml).', encoding='.$encoding);
6495 // Create an XML parser - why not xml_parser_create_ns?
6496 $this->parser = xml_parser_create($this->xml_encoding);
6497 // Set the options for parsing the XML data.
6498 //xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
6499 xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
6500 xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding);
6501 // Set the object for the parser.
6502 xml_set_object($this->parser, $this);
6503 // Set the element handlers for the parser.
6504 xml_set_element_handler($this->parser, 'start_element','end_element');
6505 xml_set_character_data_handler($this->parser,'character_data');
6506
6507 // Parse the XML file.
6508 if(!xml_parse($this->parser,$xml,true)){
6509 // Display an error message.
6510 $err = sprintf('XML error parsing SOAP payload on line %d: %s',
6511 xml_get_current_line_number($this->parser),
6512 xml_error_string(xml_get_error_code($this->parser)));
6513 $this->debug($err);
6514 $this->debug("XML payload:\n" . $xml);
6515 $this->setError($err);
6516 } else {
6517 $this->debug('parsed successfully, found root struct: '.$this->root_struct.' of name '.$this->root_struct_name);
6518 // get final value
6519 $this->soapresponse = $this->message[$this->root_struct]['result'];
6520 // get header value
6521 if($this->root_header != '' && isset($this->message[$this->root_header]['result'])){
6522 $this->soapheader = $this->message[$this->root_header]['result'];
6523 }
6524 // resolve hrefs/ids
6525 if(sizeof($this->multirefs) > 0){
6526 foreach($this->multirefs as $id => $hrefs){
6527 $this->debug('resolving multirefs for id: '.$id);
6528 $idVal = $this->buildVal($this->ids[$id]);
6529 if (is_array($idVal) && isset($idVal['!id'])) {
6530 unset($idVal['!id']);
6531 }
6532 foreach($hrefs as $refPos => $ref){
6533 $this->debug('resolving href at pos '.$refPos);
6534 $this->multirefs[$id][$refPos] = $idVal;
6535 }
6536 }
6537 }
6538 }
6539 xml_parser_free($this->parser);
6540 } else {
6541 $this->debug('xml was empty, didn\'t parse!');
6542 $this->setError('xml was empty, didn\'t parse!');
6543 }
6544 }
sprintf('%.4f', $callTime)
setError($str)
sets error string
Definition: nusoap.php:184
debug($string)
adds debug data to the class level debug string
Definition: nusoap.php:144
buildVal($pos)
builds response structures for compound values (arrays/structs) and scalars
Definition: nusoap.php:6926
if(!array_key_exists('StateId', $_REQUEST)) $id
foreach($_POST as $key=> $value) $res

References $decode_utf8, $id, $method, $res, $root_header, $root_struct, $xml, $xml_encoding, buildVal(), nusoap_base\debug(), nusoap_base\setError(), and sprintf.

+ Here is the call graph for this function:

Member Function Documentation

◆ buildVal()

nusoap_parser::buildVal (   $pos)

builds response structures for compound values (arrays/structs) and scalars

Parameters
integer$posposition in node tree
Returns
mixed PHP value @access private

Reimplemented in soap_parser.

Definition at line 6926 of file nusoap.php.

6926 {
6927 if(!isset($this->message[$pos]['type'])){
6928 $this->message[$pos]['type'] = '';
6929 }
6930 $this->debug('in buildVal() for '.$this->message[$pos]['name']."(pos $pos) of type ".$this->message[$pos]['type']);
6931 // if there are children...
6932 if($this->message[$pos]['children'] != ''){
6933 $this->debug('in buildVal, there are children');
6934 $children = explode('|',$this->message[$pos]['children']);
6935 array_shift($children); // knock off empty
6936 // md array
6937 if(isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != ''){
6938 $r=0; // rowcount
6939 $c=0; // colcount
6940 foreach($children as $child_pos){
6941 $this->debug("in buildVal, got an MD array element: $r, $c");
6942 $params[$r][] = $this->message[$child_pos]['result'];
6943 $c++;
6944 if($c == $this->message[$pos]['arrayCols']){
6945 $c = 0;
6946 $r++;
6947 }
6948 }
6949 // array
6950 } elseif($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array'){
6951 $this->debug('in buildVal, adding array '.$this->message[$pos]['name']);
6952 foreach($children as $child_pos){
6953 $params[] = &$this->message[$child_pos]['result'];
6954 }
6955 // apache Map type: java hashtable
6956 } elseif($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap'){
6957 $this->debug('in buildVal, Java Map '.$this->message[$pos]['name']);
6958 foreach($children as $child_pos){
6959 $kv = explode("|",$this->message[$child_pos]['children']);
6960 $params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result'];
6961 }
6962 // generic compound type
6963 //} elseif($this->message[$pos]['type'] == 'SOAPStruct' || $this->message[$pos]['type'] == 'struct') {
6964 } else {
6965 // Apache Vector type: treat as an array
6966 $this->debug('in buildVal, adding Java Vector or generic compound type '.$this->message[$pos]['name']);
6967 if ($this->message[$pos]['type'] == 'Vector' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') {
6968 $notstruct = 1;
6969 } else {
6970 $notstruct = 0;
6971 }
6972 //
6973 foreach($children as $child_pos){
6974 if($notstruct){
6975 $params[] = &$this->message[$child_pos]['result'];
6976 } else {
6977 if (isset($params[$this->message[$child_pos]['name']])) {
6978 // de-serialize repeated element name into an array
6979 if ((!is_array($params[$this->message[$child_pos]['name']])) || (!isset($params[$this->message[$child_pos]['name']][0]))) {
6980 $params[$this->message[$child_pos]['name']] = array($params[$this->message[$child_pos]['name']]);
6981 }
6982 $params[$this->message[$child_pos]['name']][] = &$this->message[$child_pos]['result'];
6983 } else {
6984 $params[$this->message[$child_pos]['name']] = &$this->message[$child_pos]['result'];
6985 }
6986 }
6987 }
6988 }
6989 if (isset($this->message[$pos]['xattrs'])) {
6990 $this->debug('in buildVal, handling attributes');
6991 foreach ($this->message[$pos]['xattrs'] as $n => $v) {
6992 $params[$n] = $v;
6993 }
6994 }
6995 // handle simpleContent
6996 if (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
6997 $this->debug('in buildVal, handling simpleContent');
6998 if (isset($this->message[$pos]['type'])) {
6999 $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
7000 } else {
7001 $parent = $this->message[$pos]['parent'];
7002 if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
7003 $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
7004 } else {
7005 $params['!'] = $this->message[$pos]['cdata'];
7006 }
7007 }
7008 }
7009 $ret = is_array($params) ? $params : array();
7010 $this->debug('in buildVal, return:');
7011 $this->appendDebug($this->varDump($ret));
7012 return $ret;
7013 } else {
7014 $this->debug('in buildVal, no children, building scalar');
7015 $cdata = isset($this->message[$pos]['cdata']) ? $this->message[$pos]['cdata'] : '';
7016 if (isset($this->message[$pos]['type'])) {
7017 $ret = $this->decodeSimple($cdata, $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
7018 $this->debug("in buildVal, return: $ret");
7019 return $ret;
7020 }
7021 $parent = $this->message[$pos]['parent'];
7022 if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
7023 $ret = $this->decodeSimple($cdata, $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
7024 $this->debug("in buildVal, return: $ret");
7025 return $ret;
7026 }
7027 $ret = $this->message[$pos]['cdata'];
7028 $this->debug("in buildVal, return: $ret");
7029 return $ret;
7030 }
7031 }
$n
Definition: RandomTest.php:85
varDump($data)
Definition: nusoap.php:567
appendDebug($string)
adds debug data to the instance debug string without formatting
Definition: nusoap.php:294
decodeSimple($value, $type, $typens)
decodes simple types into PHP variables
Definition: nusoap.php:6882
$r
Definition: example_031.php:79
$ret
Definition: parser.php:6
$params
Definition: disable.php:11

References $n, $params, $parent, $r, $ret, nusoap_base\appendDebug(), nusoap_base\debug(), decodeSimple(), and nusoap_base\varDump().

Referenced by __construct(), and end_element().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ character_data()

nusoap_parser::character_data (   $parser,
  $data 
)

element content handler

Parameters
resource$parserXML parser object
string$dataelement content @access private

Reimplemented in soap_parser.

Definition at line 6813 of file nusoap.php.

6813 {
6814 $pos = $this->depth_array[$this->depth];
6815 if ($this->xml_encoding=='UTF-8'){
6816 // TODO: add an option to disable this for folks who want
6817 // raw UTF-8 that, e.g., might not map to iso-8859-1
6818 // TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1");
6819 if($this->decode_utf8){
6820 $data = utf8_decode($data);
6821 }
6822 }
6823 $this->message[$pos]['cdata'] .= $data;
6824 // for doclit
6825 if($this->status == 'header'){
6826 $this->responseHeaders .= $data;
6827 } else {
6828 $this->document .= $data;
6829 }
6830 }

References $data, and $depth.

◆ decodeSimple()

nusoap_parser::decodeSimple (   $value,
  $type,
  $typens 
)

decodes simple types into PHP variables

Parameters
string$valuevalue to decode
string$typeXML type to decode
string$typensXML type namespace to decode
Returns
mixed PHP value @access private

Reimplemented in soap_parser.

Definition at line 6882 of file nusoap.php.

6882 {
6883 // TODO: use the namespace!
6884 if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') {
6885 return (string) $value;
6886 }
6887 if ($type == 'int' || $type == 'integer' || $type == 'short' || $type == 'byte') {
6888 return (int) $value;
6889 }
6890 if ($type == 'float' || $type == 'double' || $type == 'decimal') {
6891 return (double) $value;
6892 }
6893 if ($type == 'boolean') {
6894 if (strtolower($value) == 'false' || strtolower($value) == 'f') {
6895 return false;
6896 }
6897 return (boolean) $value;
6898 }
6899 if ($type == 'base64' || $type == 'base64Binary') {
6900 $this->debug('Decode base64 value');
6901 return base64_decode($value);
6902 }
6903 // obscure numeric types
6904 if ($type == 'nonPositiveInteger' || $type == 'negativeInteger'
6905 || $type == 'nonNegativeInteger' || $type == 'positiveInteger'
6906 || $type == 'unsignedInt'
6907 || $type == 'unsignedShort' || $type == 'unsignedByte') {
6908 return (int) $value;
6909 }
6910 // bogus: parser treats array with no elements as a simple type
6911 if ($type == 'array') {
6912 return array();
6913 }
6914 // everything else
6915 return (string) $value;
6916 }
$type

References $type, and nusoap_base\debug().

Referenced by buildVal(), and end_element().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ end_element()

nusoap_parser::end_element (   $parser,
  $name 
)

end-element handler

Parameters
resource$parserXML parser object
string$nameelement name @access private

Reimplemented in soap_parser.

Definition at line 6709 of file nusoap.php.

6709 {
6710 // position of current element is equal to the last value left in depth_array for my depth
6711 $pos = $this->depth_array[$this->depth--];
6712
6713 // get element prefix
6714 if(strpos($name,':')){
6715 // get ns prefix
6716 $prefix = substr($name,0,strpos($name,':'));
6717 // get unqualified name
6718 $name = substr(strstr($name,':'),1);
6719 }
6720
6721 // build to native type
6722 if(isset($this->body_position) && $pos > $this->body_position){
6723 // deal w/ multirefs
6724 if(isset($this->message[$pos]['attrs']['href'])){
6725 // get id
6726 $id = substr($this->message[$pos]['attrs']['href'],1);
6727 // add placeholder to href array
6728 $this->multirefs[$id][$pos] = 'placeholder';
6729 // add set a reference to it as the result value
6730 $this->message[$pos]['result'] =& $this->multirefs[$id][$pos];
6731 // build complexType values
6732 } elseif($this->message[$pos]['children'] != ''){
6733 // if result has already been generated (struct/array)
6734 if(!isset($this->message[$pos]['result'])){
6735 $this->message[$pos]['result'] = $this->buildVal($pos);
6736 }
6737 // build complexType values of attributes and possibly simpleContent
6738 } elseif (isset($this->message[$pos]['xattrs'])) {
6739 if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
6740 $this->message[$pos]['xattrs']['!'] = null;
6741 } elseif (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
6742 if (isset($this->message[$pos]['type'])) {
6743 $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
6744 } else {
6745 $parent = $this->message[$pos]['parent'];
6746 if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
6747 $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
6748 } else {
6749 $this->message[$pos]['xattrs']['!'] = $this->message[$pos]['cdata'];
6750 }
6751 }
6752 }
6753 $this->message[$pos]['result'] = $this->message[$pos]['xattrs'];
6754 // set value of simpleType (or nil complexType)
6755 } else {
6756 //$this->debug('adding data for scalar value '.$this->message[$pos]['name'].' of value '.$this->message[$pos]['cdata']);
6757 if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
6758 $this->message[$pos]['xattrs']['!'] = null;
6759 } elseif (isset($this->message[$pos]['type'])) {
6760 $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
6761 } else {
6762 $parent = $this->message[$pos]['parent'];
6763 if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
6764 $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
6765 } else {
6766 $this->message[$pos]['result'] = $this->message[$pos]['cdata'];
6767 }
6768 }
6769
6770 /* add value to parent's result, if parent is struct/array
6771 $parent = $this->message[$pos]['parent'];
6772 if($this->message[$parent]['type'] != 'map'){
6773 if(strtolower($this->message[$parent]['type']) == 'array'){
6774 $this->message[$parent]['result'][] = $this->message[$pos]['result'];
6775 } else {
6776 $this->message[$parent]['result'][$this->message[$pos]['name']] = $this->message[$pos]['result'];
6777 }
6778 }
6779 */
6780 }
6781 }
6782
6783 // for doclit
6784 if($this->status == 'header'){
6785 if ($this->root_header != $pos) {
6786 $this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
6787 }
6788 } elseif($pos >= $this->root_struct){
6789 $this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
6790 }
6791 // switch status
6792 if($pos == $this->root_struct){
6793 $this->status = 'body';
6794 $this->root_struct_namespace = $this->message[$pos]['namespace'];
6795 } elseif($name == 'Body'){
6796 $this->status = 'envelope';
6797 } elseif($name == 'Header'){
6798 $this->status = 'envelope';
6799 } elseif($name == 'Envelope'){
6800 //
6801 }
6802 // set parent back to my parent
6803 $this->parent = $this->message[$pos]['parent'];
6804 }
if($format !==null) $name
Definition: metadata.php:146

References $id, $name, $parent, buildVal(), and decodeSimple().

+ Here is the call graph for this function:

◆ get_response()

nusoap_parser::get_response ( )

get the parsed message (SOAP Body)

Returns
mixed @access public
Deprecated:
use get_soapbody instead

Reimplemented in soap_parser.

Definition at line 6839 of file nusoap.php.

6839 {
6840 return $this->soapresponse;
6841 }

References $soapresponse.

◆ get_soapbody()

nusoap_parser::get_soapbody ( )

get the parsed SOAP Body (NULL if there was none)

Returns
mixed @access public

Definition at line 6849 of file nusoap.php.

6849 {
6850 return $this->soapresponse;
6851 }

References $soapresponse.

◆ get_soapheader()

nusoap_parser::get_soapheader ( )

get the parsed SOAP Header (NULL if there was none)

Returns
mixed @access public

Definition at line 6859 of file nusoap.php.

6859 {
6860 return $this->soapheader;
6861 }

References $soapheader.

◆ getHeaders()

nusoap_parser::getHeaders ( )

get the unparsed SOAP Header

Returns
string XML or empty if no Header @access public

Reimplemented in soap_parser.

Definition at line 6869 of file nusoap.php.

6869 {
6871 }

References $responseHeaders.

◆ start_element()

nusoap_parser::start_element (   $parser,
  $name,
  $attrs 
)

start-element handler

Parameters
resource$parserXML parser object
string$nameelement name
array$attrsassociative array of attributes @access private

Reimplemented in soap_parser.

Definition at line 6554 of file nusoap.php.

6554 {
6555 // position in a total number of elements, starting from 0
6556 // update class level pos
6557 $pos = $this->position++;
6558 // and set mine
6559 $this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>'');
6560 // depth = how many levels removed from root?
6561 // set mine as current global depth and increment global depth value
6562 $this->message[$pos]['depth'] = $this->depth++;
6563
6564 // else add self as child to whoever the current parent is
6565 if($pos != 0){
6566 $this->message[$this->parent]['children'] .= '|'.$pos;
6567 }
6568 // set my parent
6569 $this->message[$pos]['parent'] = $this->parent;
6570 // set self as current parent
6571 $this->parent = $pos;
6572 // set self as current value for this depth
6573 $this->depth_array[$this->depth] = $pos;
6574 // get element prefix
6575 if(strpos($name,':')){
6576 // get ns prefix
6577 $prefix = substr($name,0,strpos($name,':'));
6578 // get unqualified name
6579 $name = substr(strstr($name,':'),1);
6580 }
6581 // set status
6582 if($name == 'Envelope'){
6583 $this->status = 'envelope';
6584 } elseif($name == 'Header' && $this->status = 'envelope'){
6585 $this->root_header = $pos;
6586 $this->status = 'header';
6587 } elseif($name == 'Body' && $this->status = 'envelope'){
6588 $this->status = 'body';
6589 $this->body_position = $pos;
6590 // set method
6591 } elseif($this->status == 'body' && $pos == ($this->body_position+1)){
6592 $this->status = 'method';
6593 $this->root_struct_name = $name;
6594 $this->root_struct = $pos;
6595 $this->message[$pos]['type'] = 'struct';
6596 $this->debug("found root struct $this->root_struct_name, pos $this->root_struct");
6597 }
6598 // set my status
6599 $this->message[$pos]['status'] = $this->status;
6600 // set name
6601 $this->message[$pos]['name'] = htmlspecialchars($name);
6602 // set attrs
6603 $this->message[$pos]['attrs'] = $attrs;
6604
6605 // loop through atts, logging ns and type declarations
6606 $attstr = '';
6607 foreach($attrs as $key => $value){
6608 $key_prefix = $this->getPrefix($key);
6609 $key_localpart = $this->getLocalPart($key);
6610 // if ns declarations, add to class level array of valid namespaces
6611 if($key_prefix == 'xmlns'){
6612 if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){
6613 $this->XMLSchemaVersion = $value;
6614 $this->namespaces['xsd'] = $this->XMLSchemaVersion;
6615 $this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance';
6616 }
6617 $this->namespaces[$key_localpart] = $value;
6618 // set method namespace
6619 if($name == $this->root_struct_name){
6620 $this->methodNamespace = $value;
6621 }
6622 // if it's a type declaration, set type
6623 } elseif($key_localpart == 'type'){
6624 if (isset($this->message[$pos]['type']) && $this->message[$pos]['type'] == 'array') {
6625 // do nothing: already processed arrayType
6626 } else {
6627 $value_prefix = $this->getPrefix($value);
6628 $value_localpart = $this->getLocalPart($value);
6629 $this->message[$pos]['type'] = $value_localpart;
6630 $this->message[$pos]['typePrefix'] = $value_prefix;
6631 if(isset($this->namespaces[$value_prefix])){
6632 $this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix];
6633 } else if(isset($attrs['xmlns:'.$value_prefix])) {
6634 $this->message[$pos]['type_namespace'] = $attrs['xmlns:'.$value_prefix];
6635 }
6636 // should do something here with the namespace of specified type?
6637 }
6638 } elseif($key_localpart == 'arrayType'){
6639 $this->message[$pos]['type'] = 'array';
6640 /* do arrayType ereg here
6641 [1] arrayTypeValue ::= atype asize
6642 [2] atype ::= QName rank*
6643 [3] rank ::= '[' (',')* ']'
6644 [4] asize ::= '[' length~ ']'
6645 [5] length ::= nextDimension* Digit+
6646 [6] nextDimension ::= Digit+ ','
6647 */
6648 $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/';
6649 if(preg_match($expr,$value,$regs)){
6650 $this->message[$pos]['typePrefix'] = $regs[1];
6651 $this->message[$pos]['arrayTypePrefix'] = $regs[1];
6652 if (isset($this->namespaces[$regs[1]])) {
6653 $this->message[$pos]['arrayTypeNamespace'] = $this->namespaces[$regs[1]];
6654 } else if (isset($attrs['xmlns:'.$regs[1]])) {
6655 $this->message[$pos]['arrayTypeNamespace'] = $attrs['xmlns:'.$regs[1]];
6656 }
6657 $this->message[$pos]['arrayType'] = $regs[2];
6658 $this->message[$pos]['arraySize'] = $regs[3];
6659 $this->message[$pos]['arrayCols'] = $regs[4];
6660 }
6661 // specifies nil value (or not)
6662 } elseif ($key_localpart == 'nil'){
6663 $this->message[$pos]['nil'] = ($value == 'true' || $value == '1');
6664 // some other attribute
6665 } elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') {
6666 $this->message[$pos]['xattrs']['!' . $key] = $value;
6667 }
6668
6669 if ($key == 'xmlns') {
6670 $this->default_namespace = $value;
6671 }
6672 // log id
6673 if($key == 'id'){
6674 $this->ids[$value] = $pos;
6675 }
6676 // root
6677 if($key_localpart == 'root' && $value == 1){
6678 $this->status = 'method';
6679 $this->root_struct_name = $name;
6680 $this->root_struct = $pos;
6681 $this->debug("found root struct $this->root_struct_name, pos $pos");
6682 }
6683 // for doclit
6684 $attstr .= " $key=\"$value\"";
6685 }
6686 // get namespace - must be done after namespace atts are processed
6687 if(isset($prefix)){
6688 $this->message[$pos]['namespace'] = $this->namespaces[$prefix];
6689 $this->default_namespace = $this->namespaces[$prefix];
6690 } else {
6691 $this->message[$pos]['namespace'] = $this->default_namespace;
6692 }
6693 if($this->status == 'header'){
6694 if ($this->root_header != $pos) {
6695 $this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
6696 }
6697 } elseif($this->root_struct_name != ''){
6698 $this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
6699 }
6700 }
getPrefix($str)
returns the prefix part of a prefixed string returns false, if not prefixed
Definition: nusoap.php:525
$XMLSchemaVersion
Definition: nusoap.php:78
getLocalPart($str)
returns the local part of a prefixed string returns the original string, if not prefixed
Definition: nusoap.php:508
$key
Definition: croninfo.php:18

References $default_namespace, $depth, $key, $name, $parent, $status, nusoap_base\$XMLSchemaVersion, nusoap_base\debug(), nusoap_base\getLocalPart(), and nusoap_base\getPrefix().

+ Here is the call graph for this function:

Field Documentation

◆ $body_position

nusoap_parser::$body_position = 0

Definition at line 6444 of file nusoap.php.

◆ $debug_flag

nusoap_parser::$debug_flag = true

Definition at line 6440 of file nusoap.php.

◆ $decode_utf8

nusoap_parser::$decode_utf8 = true

Definition at line 6451 of file nusoap.php.

Referenced by __construct().

◆ $default_namespace

nusoap_parser::$default_namespace = ''

Definition at line 6431 of file nusoap.php.

Referenced by start_element().

◆ $depth

nusoap_parser::$depth = 0

Definition at line 6430 of file nusoap.php.

Referenced by character_data(), and start_element().

◆ $depth_array

nusoap_parser::$depth_array = array()

Definition at line 6439 of file nusoap.php.

◆ $document

nusoap_parser::$document = ''

Definition at line 6426 of file nusoap.php.

◆ $fault

nusoap_parser::$fault = false

Definition at line 6435 of file nusoap.php.

◆ $fault_code

nusoap_parser::$fault_code = ''

Definition at line 6436 of file nusoap.php.

◆ $fault_detail

nusoap_parser::$fault_detail = ''

Definition at line 6438 of file nusoap.php.

◆ $fault_str

nusoap_parser::$fault_str = ''

Definition at line 6437 of file nusoap.php.

◆ $ids

nusoap_parser::$ids = array()

Definition at line 6447 of file nusoap.php.

◆ $message

nusoap_parser::$message = array()

Definition at line 6433 of file nusoap.php.

◆ $method

nusoap_parser::$method = ''

Definition at line 6421 of file nusoap.php.

Referenced by __construct().

◆ $multirefs

nusoap_parser::$multirefs = array()

Definition at line 6449 of file nusoap.php.

◆ $namespaces

nusoap_parser::$namespaces = array()

Definition at line 6432 of file nusoap.php.

◆ $parent

nusoap_parser::$parent = ''

Definition at line 6434 of file nusoap.php.

Referenced by buildVal(), end_element(), and start_element().

◆ $position

nusoap_parser::$position = 0

Definition at line 6429 of file nusoap.php.

◆ $responseHeaders

nusoap_parser::$responseHeaders = ''

Definition at line 6443 of file nusoap.php.

Referenced by getHeaders().

◆ $root_header

nusoap_parser::$root_header = ''

Definition at line 6425 of file nusoap.php.

Referenced by __construct().

◆ $root_struct

nusoap_parser::$root_struct = ''

Definition at line 6422 of file nusoap.php.

Referenced by __construct().

◆ $root_struct_name

nusoap_parser::$root_struct_name = ''

Definition at line 6423 of file nusoap.php.

◆ $root_struct_namespace

nusoap_parser::$root_struct_namespace = ''

Definition at line 6424 of file nusoap.php.

◆ $soapheader

nusoap_parser::$soapheader = NULL

Definition at line 6442 of file nusoap.php.

Referenced by get_soapheader().

◆ $soapresponse

nusoap_parser::$soapresponse = NULL

Definition at line 6441 of file nusoap.php.

Referenced by get_response(), and get_soapbody().

◆ $status

nusoap_parser::$status = ''

Definition at line 6428 of file nusoap.php.

Referenced by start_element().

◆ $xml

nusoap_parser::$xml = ''

Definition at line 6419 of file nusoap.php.

Referenced by __construct().

◆ $xml_encoding

nusoap_parser::$xml_encoding = ''

Definition at line 6420 of file nusoap.php.

Referenced by __construct().


The documentation for this class was generated from the following file: