ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 6429 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 6474 of file nusoap.php.

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

References $decode_utf8, $method, $res, $root_header, $root_struct, $xml, $xml_encoding, ILIAS\GlobalScreen\Provider\__construct(), buildVal(), nusoap_base\debug(), and nusoap_base\setError().

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

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

References Vendor\Package\$c, $n, $parent, $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 6825 of file nusoap.php.

6825 {
6826 $pos = $this->depth_array[$this->depth];
6827 if ($this->xml_encoding=='UTF-8'){
6828 // TODO: add an option to disable this for folks who want
6829 // raw UTF-8 that, e.g., might not map to iso-8859-1
6830 // TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1");
6831 if($this->decode_utf8){
6832 $data = utf8_decode($data);
6833 }
6834 }
6835 $this->message[$pos]['cdata'] .= $data;
6836 // for doclit
6837 if($this->status == 'header'){
6838 $this->responseHeaders .= $data;
6839 } else {
6840 $this->document .= $data;
6841 }
6842 }
$data
Definition: storeScorm.php:23

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

6894 {
6895 // TODO: use the namespace!
6896 if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') {
6897 return (string) $value;
6898 }
6899 if ($type == 'int' || $type == 'integer' || $type == 'short' || $type == 'byte') {
6900 return (int) $value;
6901 }
6902 if ($type == 'float' || $type == 'double' || $type == 'decimal') {
6903 return (double) $value;
6904 }
6905 if ($type == 'boolean') {
6906 if (strtolower($value) == 'false' || strtolower($value) == 'f') {
6907 return false;
6908 }
6909 return (boolean) $value;
6910 }
6911 if ($type == 'base64' || $type == 'base64Binary') {
6912 $this->debug('Decode base64 value');
6913 return base64_decode($value);
6914 }
6915 // obscure numeric types
6916 if ($type == 'nonPositiveInteger' || $type == 'negativeInteger'
6917 || $type == 'nonNegativeInteger' || $type == 'positiveInteger'
6918 || $type == 'unsignedInt'
6919 || $type == 'unsignedShort' || $type == 'unsignedByte') {
6920 return (int) $value;
6921 }
6922 // bogus: parser treats array with no elements as a simple type
6923 if ($type == 'array') {
6924 return array();
6925 }
6926 // everything else
6927 return (string) $value;
6928 }
$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 6721 of file nusoap.php.

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

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

6851 {
6852 return $this->soapresponse;
6853 }

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

6861 {
6862 return $this->soapresponse;
6863 }

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

6871 {
6872 return $this->soapheader;
6873 }

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

6881 {
6883 }

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

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

◆ $debug_flag

nusoap_parser::$debug_flag = true

Definition at line 6452 of file nusoap.php.

◆ $decode_utf8

nusoap_parser::$decode_utf8 = true

Definition at line 6463 of file nusoap.php.

Referenced by __construct().

◆ $default_namespace

nusoap_parser::$default_namespace = ''

Definition at line 6443 of file nusoap.php.

Referenced by start_element().

◆ $depth

nusoap_parser::$depth = 0

Definition at line 6442 of file nusoap.php.

Referenced by character_data(), and start_element().

◆ $depth_array

nusoap_parser::$depth_array = array()

Definition at line 6451 of file nusoap.php.

◆ $document

nusoap_parser::$document = ''

Definition at line 6438 of file nusoap.php.

◆ $fault

nusoap_parser::$fault = false

Definition at line 6447 of file nusoap.php.

◆ $fault_code

nusoap_parser::$fault_code = ''

Definition at line 6448 of file nusoap.php.

◆ $fault_detail

nusoap_parser::$fault_detail = ''

Definition at line 6450 of file nusoap.php.

◆ $fault_str

nusoap_parser::$fault_str = ''

Definition at line 6449 of file nusoap.php.

◆ $ids

nusoap_parser::$ids = array()

Definition at line 6459 of file nusoap.php.

◆ $message

nusoap_parser::$message = array()

Definition at line 6445 of file nusoap.php.

◆ $method

nusoap_parser::$method = ''

Definition at line 6433 of file nusoap.php.

Referenced by __construct().

◆ $multirefs

nusoap_parser::$multirefs = array()

Definition at line 6461 of file nusoap.php.

◆ $namespaces

nusoap_parser::$namespaces = array()

Definition at line 6444 of file nusoap.php.

◆ $parent

nusoap_parser::$parent = ''

Definition at line 6446 of file nusoap.php.

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

◆ $position

nusoap_parser::$position = 0

Definition at line 6441 of file nusoap.php.

◆ $responseHeaders

nusoap_parser::$responseHeaders = ''

Definition at line 6455 of file nusoap.php.

Referenced by getHeaders().

◆ $root_header

nusoap_parser::$root_header = ''

Definition at line 6437 of file nusoap.php.

Referenced by __construct().

◆ $root_struct

nusoap_parser::$root_struct = ''

Definition at line 6434 of file nusoap.php.

Referenced by __construct().

◆ $root_struct_name

nusoap_parser::$root_struct_name = ''

Definition at line 6435 of file nusoap.php.

◆ $root_struct_namespace

nusoap_parser::$root_struct_namespace = ''

Definition at line 6436 of file nusoap.php.

◆ $soapheader

nusoap_parser::$soapheader = NULL

Definition at line 6454 of file nusoap.php.

Referenced by get_soapheader().

◆ $soapresponse

nusoap_parser::$soapresponse = NULL

Definition at line 6453 of file nusoap.php.

Referenced by get_response(), and get_soapbody().

◆ $status

nusoap_parser::$status = ''

Definition at line 6440 of file nusoap.php.

Referenced by start_element().

◆ $xml

nusoap_parser::$xml = ''

Definition at line 6431 of file nusoap.php.

Referenced by __construct().

◆ $xml_encoding

nusoap_parser::$xml_encoding = ''

Definition at line 6432 of file nusoap.php.

Referenced by __construct().


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