ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 6412 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 6457 of file nusoap.php.

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

References $decode_utf8, $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 6921 of file nusoap.php.

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

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 6808 of file nusoap.php.

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

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 6877 of file nusoap.php.

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

References 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 6704 of file nusoap.php.

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

References $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 6834 of file nusoap.php.

6834 {
6835 return $this->soapresponse;
6836 }

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 6844 of file nusoap.php.

6844 {
6845 return $this->soapresponse;
6846 }

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 6854 of file nusoap.php.

6854 {
6855 return $this->soapheader;
6856 }

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 6864 of file nusoap.php.

6864 {
6866 }

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 6549 of file nusoap.php.

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

References $default_namespace, $depth, $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 6439 of file nusoap.php.

◆ $debug_flag

nusoap_parser::$debug_flag = true

Definition at line 6435 of file nusoap.php.

◆ $decode_utf8

nusoap_parser::$decode_utf8 = true

Definition at line 6446 of file nusoap.php.

Referenced by __construct().

◆ $default_namespace

nusoap_parser::$default_namespace = ''

Definition at line 6426 of file nusoap.php.

Referenced by start_element().

◆ $depth

nusoap_parser::$depth = 0

Definition at line 6425 of file nusoap.php.

Referenced by character_data(), and start_element().

◆ $depth_array

nusoap_parser::$depth_array = array()

Definition at line 6434 of file nusoap.php.

◆ $document

nusoap_parser::$document = ''

Definition at line 6421 of file nusoap.php.

◆ $fault

nusoap_parser::$fault = false

Definition at line 6430 of file nusoap.php.

◆ $fault_code

nusoap_parser::$fault_code = ''

Definition at line 6431 of file nusoap.php.

◆ $fault_detail

nusoap_parser::$fault_detail = ''

Definition at line 6433 of file nusoap.php.

◆ $fault_str

nusoap_parser::$fault_str = ''

Definition at line 6432 of file nusoap.php.

◆ $ids

nusoap_parser::$ids = array()

Definition at line 6442 of file nusoap.php.

◆ $message

nusoap_parser::$message = array()

Definition at line 6428 of file nusoap.php.

◆ $method

nusoap_parser::$method = ''

Definition at line 6416 of file nusoap.php.

Referenced by __construct().

◆ $multirefs

nusoap_parser::$multirefs = array()

Definition at line 6444 of file nusoap.php.

◆ $namespaces

nusoap_parser::$namespaces = array()

Definition at line 6427 of file nusoap.php.

◆ $parent

nusoap_parser::$parent = ''

Definition at line 6429 of file nusoap.php.

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

◆ $position

nusoap_parser::$position = 0

Definition at line 6424 of file nusoap.php.

◆ $responseHeaders

nusoap_parser::$responseHeaders = ''

Definition at line 6438 of file nusoap.php.

Referenced by getHeaders().

◆ $root_header

nusoap_parser::$root_header = ''

Definition at line 6420 of file nusoap.php.

Referenced by __construct().

◆ $root_struct

nusoap_parser::$root_struct = ''

Definition at line 6417 of file nusoap.php.

Referenced by __construct().

◆ $root_struct_name

nusoap_parser::$root_struct_name = ''

Definition at line 6418 of file nusoap.php.

◆ $root_struct_namespace

nusoap_parser::$root_struct_namespace = ''

Definition at line 6419 of file nusoap.php.

◆ $soapheader

nusoap_parser::$soapheader = NULL

Definition at line 6437 of file nusoap.php.

Referenced by get_soapheader().

◆ $soapresponse

nusoap_parser::$soapresponse = NULL

Definition at line 6436 of file nusoap.php.

Referenced by get_response(), and get_soapbody().

◆ $status

nusoap_parser::$status = ''

Definition at line 6423 of file nusoap.php.

Referenced by start_element().

◆ $xml

nusoap_parser::$xml = ''

Definition at line 6414 of file nusoap.php.

Referenced by __construct().

◆ $xml_encoding

nusoap_parser::$xml_encoding = ''

Definition at line 6415 of file nusoap.php.

Referenced by __construct().


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