ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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
 __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)
 serializes PHP values in accordance w/ section 5. More...
 
 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

 $methodNamespace
 
 $parser
 
 $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.7.3'
 
 $revision = '$Revision$'
 
 $error_str = ''
 
 $debug_str = ''
 
 $charencoding = true
 
 $debugLevel
 
 $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema'
 
 $soap_defencoding = 'UTF-8'
 
 $namespaces
 
 $usedNamespaces = array()
 
 $typemap
 
 $xmlEntities
 

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

6565 {
6567 $this->xml = $xml;
6568 $this->xml_encoding = $encoding;
6569 $this->method = $method;
6570 $this->decode_utf8 = $decode_utf8;
6571
6572 // Check whether content has been read.
6573 if (!empty($xml)) {
6574 // Check XML encoding
6575 $pos_xml = strpos($xml, '<?xml');
6576 if ($pos_xml !== false) {
6577 $xml_decl = substr($xml, $pos_xml, strpos($xml, '?>', $pos_xml + 2) - $pos_xml + 1);
6578 if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) {
6579 $xml_encoding = $res[1];
6580 if (strtoupper($xml_encoding) != $encoding) {
6581 $err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'";
6582 $this->debug($err);
6583 if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') {
6584 $this->setError($err);
6585 return;
6586 }
6587 // when HTTP says ISO-8859-1 (the default) and XML says UTF-8 (the typical), assume the other endpoint is just sloppy and proceed
6588 } else {
6589 $this->debug('Charset from HTTP Content-Type matches encoding from XML declaration');
6590 }
6591 } else {
6592 $this->debug('No encoding specified in XML declaration');
6593 }
6594 } else {
6595 $this->debug('No XML declaration');
6596 }
6597 $this->debug('Entering nusoap_parser(), length=' . strlen($xml) . ', encoding=' . $encoding);
6598 // Create an XML parser - why not xml_parser_create_ns?
6599 $this->parser = xml_parser_create($this->xml_encoding);
6600 // Set the options for parsing the XML data.
6601 //xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
6602 xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
6603 xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding);
6604 // Set the object for the parser.
6605 // Set the element handlers for the parser.
6606 xml_set_element_handler($this->parser, $this->start_element(...), $this->end_element(...));
6607 xml_set_character_data_handler($this->parser, $this->character_data(...));
6608
6609 // Parse the XML file.
6610 if (!xml_parse($this->parser, $xml, true)) {
6611 // Display an error message.
6612 $err = sprintf(
6613 'XML error parsing SOAP payload on line %d: %s',
6614 xml_get_current_line_number($this->parser),
6615 xml_error_string(xml_get_error_code($this->parser))
6616 );
6617 $this->debug($err);
6618 $this->debug("XML payload:\n" . $xml);
6619 $this->setError($err);
6620 } else {
6621 $this->debug('parsed successfully, found root struct: ' . $this->root_struct . ' of name ' . $this->root_struct_name);
6622 // get final value
6623 $this->soapresponse = $this->message[$this->root_struct]['result'];
6624 // get header value
6625 if ($this->root_header != '' && isset($this->message[$this->root_header]['result'])) {
6626 $this->soapheader = $this->message[$this->root_header]['result'];
6627 }
6628 // resolve hrefs/ids
6629 if (sizeof($this->multirefs) > 0) {
6630 foreach ($this->multirefs as $id => $hrefs) {
6631 $this->debug('resolving multirefs for id: ' . $id);
6632 $idVal = $this->buildVal($this->ids[$id]);
6633 if (is_array($idVal) && isset($idVal['!id'])) {
6634 unset($idVal['!id']);
6635 }
6636 foreach ($hrefs as $refPos => $ref) {
6637 $this->debug('resolving href at pos ' . $refPos);
6638 $this->multirefs[$id][$refPos] = $idVal;
6639 }
6640 }
6641 }
6642 }
6643 xml_parser_free($this->parser);
6644 } else {
6645 $this->debug('xml was empty, didn\'t parse!');
6646 $this->setError('xml was empty, didn\'t parse!');
6647 }
6648 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
setError($str)
sets error string
Definition: nusoap.php:353
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:250
character_data($parser, $data)
element content handler
Definition: nusoap.php:6919
end_element($parser, $name)
end-element handler
Definition: nusoap.php:6814
start_element($parser, $name, $attrs)
start-element handler
Definition: nusoap.php:6658
buildVal($pos)
builds response structures for compound values (arrays/structs) and scalars
Definition: nusoap.php:7038
$res
Definition: ltiservices.php:69
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

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

+ 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

Definition at line 7038 of file nusoap.php.

7039 {
7040 if (!isset($this->message[$pos]['type'])) {
7041 $this->message[$pos]['type'] = '';
7042 }
7043 $this->debug('in buildVal() for ' . $this->message[$pos]['name'] . "(pos $pos) of type " . $this->message[$pos]['type']);
7044 // if there are children...
7045 if ($this->message[$pos]['children'] != '') {
7046 $this->debug('in buildVal, there are children');
7047 $children = explode('|', $this->message[$pos]['children']);
7048 array_shift($children); // knock off empty
7049 // md array
7050 if (isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != '') {
7051 $r = 0; // rowcount
7052 $c = 0; // colcount
7053 foreach ($children as $child_pos) {
7054 $this->debug("in buildVal, got an MD array element: $r, $c");
7055 $params[$r][] = $this->message[$child_pos]['result'];
7056 $c++;
7057 if ($c == $this->message[$pos]['arrayCols']) {
7058 $c = 0;
7059 $r++;
7060 }
7061 }
7062 // array
7063 } elseif ($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array') {
7064 $this->debug('in buildVal, adding array ' . $this->message[$pos]['name']);
7065 foreach ($children as $child_pos) {
7066 $params[] = &$this->message[$child_pos]['result'];
7067 }
7068 // apache Map type: java hashtable
7069 } elseif ($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') {
7070 $this->debug('in buildVal, Java Map ' . $this->message[$pos]['name']);
7071 foreach ($children as $child_pos) {
7072 $kv = explode("|", $this->message[$child_pos]['children']);
7073 $params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result'];
7074 }
7075 // generic compound type
7076 //} elseif($this->message[$pos]['type'] == 'SOAPStruct' || $this->message[$pos]['type'] == 'struct') {
7077 } else {
7078 // Apache Vector type: treat as an array
7079 $this->debug('in buildVal, adding Java Vector or generic compound type ' . $this->message[$pos]['name']);
7080 if ($this->message[$pos]['type'] == 'Vector' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') {
7081 $notstruct = 1;
7082 } else {
7083 $notstruct = 0;
7084 }
7085 //
7086 foreach ($children as $child_pos) {
7087 if ($notstruct) {
7088 $params[] = &$this->message[$child_pos]['result'];
7089 } else {
7090 if (isset($params[$this->message[$child_pos]['name']])) {
7091 // de-serialize repeated element name into an array
7092 if ((!is_array($params[$this->message[$child_pos]['name']])) || (!isset($params[$this->message[$child_pos]['name']][0]))) {
7093 $params[$this->message[$child_pos]['name']] = array($params[$this->message[$child_pos]['name']]);
7094 }
7095 $params[$this->message[$child_pos]['name']][] = &$this->message[$child_pos]['result'];
7096 } else {
7097 $params[$this->message[$child_pos]['name']] = &$this->message[$child_pos]['result'];
7098 }
7099 }
7100 }
7101 }
7102 if (isset($this->message[$pos]['xattrs'])) {
7103 $this->debug('in buildVal, handling attributes');
7104 foreach ($this->message[$pos]['xattrs'] as $n => $v) {
7105 $params[$n] = $v;
7106 }
7107 }
7108 // handle simpleContent
7109 if (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
7110 $this->debug('in buildVal, handling simpleContent');
7111 if (isset($this->message[$pos]['type'])) {
7112 $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
7113 } else {
7114 $parent = $this->message[$pos]['parent'];
7115 if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
7116 $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
7117 } else {
7118 $params['!'] = $this->message[$pos]['cdata'];
7119 }
7120 }
7121 }
7122 $ret = is_array($params) ? $params : array();
7123 $this->debug('in buildVal, return:');
7124 $this->appendDebug($this->varDump($ret));
7125 return $ret;
7126 } else {
7127 $this->debug('in buildVal, no children, building scalar');
7128 $cdata = isset($this->message[$pos]['cdata']) ? $this->message[$pos]['cdata'] : '';
7129 if (isset($this->message[$pos]['type'])) {
7130 $ret = $this->decodeSimple($cdata, $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
7131 $this->debug("in buildVal, return: $ret");
7132 return $ret;
7133 }
7134 $parent = $this->message[$pos]['parent'];
7135 if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
7136 $ret = $this->decodeSimple($cdata, $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
7137 $this->debug("in buildVal, return: $ret");
7138 return $ret;
7139 }
7140 $ret = $this->message[$pos]['cdata'];
7141 $this->debug("in buildVal, return: $ret");
7142 return $ret;
7143 }
7144 }
varDump($data)
Returns a string with the output of var_dump.
Definition: nusoap.php:867
appendDebug($string)
adds debug data to the instance debug string without formatting
Definition: nusoap.php:263
decodeSimple($value, $type, $typens)
decodes simple types into PHP variables
Definition: nusoap.php:6993
$c
Definition: deliver.php:25
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31

References $c, $params, $parent, 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

Definition at line 6919 of file nusoap.php.

6920 {
6921 $pos = $this->depth_array[$this->depth];
6922 if ($this->xml_encoding == 'UTF-8') {
6923 // TODO: add an option to disable this for folks who want
6924 // raw UTF-8 that, e.g., might not map to iso-8859-1
6925 // TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1");
6926 if ($this->decode_utf8) {
6927 $data = utf8_decode($data);
6928 }
6929 }
6930 $this->message[$pos]['cdata'] .= $data;
6931 // for doclit
6932 if ($this->status == 'header') {
6933 $this->responseHeaders .= $data;
6934 } else {
6935 $this->document .= $data;
6936 }
6937 }

References $data, and $depth.

Referenced by __construct().

+ Here is the caller graph for this function:

◆ 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

Definition at line 6993 of file nusoap.php.

6994 {
6995 // TODO: use the namespace!
6996 if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') {
6997 return (string) $value;
6998 }
6999 if ($type == 'int' || $type == 'integer' || $type == 'short' || $type == 'byte') {
7000 return (int) $value;
7001 }
7002 if ($type == 'float' || $type == 'double' || $type == 'decimal') {
7003 return (float) $value;
7004 }
7005 if ($type == 'boolean') {
7006 if (strtolower($value) == 'false' || strtolower($value) == 'f') {
7007 return false;
7008 }
7009 return (bool) $value;
7010 }
7011 if ($type == 'base64' || $type == 'base64Binary') {
7012 $this->debug('Decode base64 value');
7013 return base64_decode($value);
7014 }
7015 // obscure numeric types
7016 if ($type == 'nonPositiveInteger' || $type == 'negativeInteger'
7017 || $type == 'nonNegativeInteger' || $type == 'positiveInteger'
7018 || $type == 'unsignedInt'
7019 || $type == 'unsignedShort' || $type == 'unsignedByte') {
7020 return (int) $value;
7021 }
7022 // bogus: parser treats array with no elements as a simple type
7023 if ($type == 'array') {
7024 return array();
7025 }
7026 // everything else
7027 return (string) $value;
7028 }

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

Definition at line 6814 of file nusoap.php.

6815 {
6816 // position of current element is equal to the last value left in depth_array for my depth
6817 $pos = $this->depth_array[$this->depth--];
6818
6819 // get element prefix
6820 if (strpos($name, ':')) {
6821 // get ns prefix
6822 $prefix = substr($name, 0, strpos($name, ':'));
6823 // get unqualified name
6824 $name = substr(strstr($name, ':'), 1);
6825 }
6826
6827 // build to native type
6828 if (isset($this->body_position) && $pos > $this->body_position) {
6829 // deal w/ multirefs
6830 if (isset($this->message[$pos]['attrs']['href'])) {
6831 // get id
6832 $id = substr($this->message[$pos]['attrs']['href'], 1);
6833 // add placeholder to href array
6834 $this->multirefs[$id][$pos] = 'placeholder';
6835 // add set a reference to it as the result value
6836 $this->message[$pos]['result'] = & $this->multirefs[$id][$pos];
6837 // build complexType values
6838 } elseif ($this->message[$pos]['children'] != '') {
6839 // if result has already been generated (struct/array)
6840 if (!isset($this->message[$pos]['result'])) {
6841 $this->message[$pos]['result'] = $this->buildVal($pos);
6842 }
6843 // build complexType values of attributes and possibly simpleContent
6844 } elseif (isset($this->message[$pos]['xattrs'])) {
6845 if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
6846 $this->message[$pos]['xattrs']['!'] = null;
6847 } elseif (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
6848 if (isset($this->message[$pos]['type'])) {
6849 $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'] : '');
6850 } else {
6851 $parent = $this->message[$pos]['parent'];
6852 if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
6853 $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
6854 } else {
6855 $this->message[$pos]['xattrs']['!'] = $this->message[$pos]['cdata'];
6856 }
6857 }
6858 }
6859 $this->message[$pos]['result'] = $this->message[$pos]['xattrs'];
6860 // set value of simpleType (or nil complexType)
6861 } else {
6862 //$this->debug('adding data for scalar value '.$this->message[$pos]['name'].' of value '.$this->message[$pos]['cdata']);
6863 if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
6864 $this->message[$pos]['xattrs']['!'] = null;
6865 } elseif (isset($this->message[$pos]['type'])) {
6866 $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'] : '');
6867 } else {
6868 $parent = $this->message[$pos]['parent'];
6869 if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
6870 $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
6871 } else {
6872 $this->message[$pos]['result'] = $this->message[$pos]['cdata'];
6873 }
6874 }
6875
6876 /* add value to parent's result, if parent is struct/array
6877 $parent = $this->message[$pos]['parent'];
6878 if($this->message[$parent]['type'] != 'map'){
6879 if(strtolower($this->message[$parent]['type']) == 'array'){
6880 $this->message[$parent]['result'][] = $this->message[$pos]['result'];
6881 } else {
6882 $this->message[$parent]['result'][$this->message[$pos]['name']] = $this->message[$pos]['result'];
6883 }
6884 }
6885 */
6886 }
6887 }
6888
6889 // for doclit
6890 if ($this->status == 'header') {
6891 if ($this->root_header != $pos) {
6892 $this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
6893 }
6894 } elseif ($pos >= $this->root_struct) {
6895 $this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
6896 }
6897 // switch status
6898 if ($pos == $this->root_struct) {
6899 $this->status = 'body';
6900 $this->root_struct_namespace = $this->message[$pos]['namespace'];
6901 } elseif ($name == 'Body') {
6902 $this->status = 'envelope';
6903 } elseif ($name == 'Header') {
6904 $this->status = 'envelope';
6905 } elseif ($name == 'Envelope') {
6906 //
6907 }
6908 // set parent back to my parent
6909 $this->parent = $this->message[$pos]['parent'];
6910 }

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

Referenced by __construct().

+ Here is the call graph for this function:
+ Here is the caller 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

Definition at line 6946 of file nusoap.php.

6947 {
6948 return $this->soapresponse;
6949 }

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

6958 {
6959 return $this->soapresponse;
6960 }

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

6969 {
6970 return $this->soapheader;
6971 }

References $soapheader.

◆ getHeaders()

nusoap_parser::getHeaders ( )

get the unparsed SOAP Header

Returns
string XML or empty if no Header @access public

Definition at line 6979 of file nusoap.php.

6980 {
6982 }

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

Definition at line 6658 of file nusoap.php.

6659 {
6660 // position in a total number of elements, starting from 0
6661 // update class level pos
6662 $pos = $this->position++;
6663 // and set mine
6664 $this->message[$pos] = array('pos' => $pos,'children' => '','cdata' => '');
6665 // depth = how many levels removed from root?
6666 // set mine as current global depth and increment global depth value
6667 $this->message[$pos]['depth'] = $this->depth++;
6668
6669 // else add self as child to whoever the current parent is
6670 if ($pos != 0) {
6671 $this->message[$this->parent]['children'] .= '|' . $pos;
6672 }
6673 // set my parent
6674 $this->message[$pos]['parent'] = $this->parent;
6675 // set self as current parent
6676 $this->parent = $pos;
6677 // set self as current value for this depth
6678 $this->depth_array[$this->depth] = $pos;
6679 // get element prefix
6680 if (strpos($name, ':')) {
6681 // get ns prefix
6682 $prefix = substr($name, 0, strpos($name, ':'));
6683 // get unqualified name
6684 $name = substr(strstr($name, ':'), 1);
6685 }
6686 // set status
6687 if ($name == 'Envelope') {
6688 $this->status = 'envelope';
6689 } elseif ($name == 'Header' && $this->status = 'envelope') {
6690 $this->root_header = $pos;
6691 $this->status = 'header';
6692 } elseif ($name == 'Body' && $this->status = 'envelope') {
6693 $this->status = 'body';
6694 $this->body_position = $pos;
6695 // set method
6696 } elseif ($this->status == 'body' && $pos == ($this->body_position + 1)) {
6697 $this->status = 'method';
6698 $this->root_struct_name = $name;
6699 $this->root_struct = $pos;
6700 $this->message[$pos]['type'] = 'struct';
6701 $this->debug("found root struct $this->root_struct_name, pos $this->root_struct");
6702 }
6703 // set my status
6704 $this->message[$pos]['status'] = $this->status;
6705 // set name
6706 $this->message[$pos]['name'] = htmlspecialchars($name);
6707 // set attrs
6708 $this->message[$pos]['attrs'] = $attrs;
6709
6710 // loop through atts, logging ns and type declarations
6711 $attstr = '';
6712 foreach ($attrs as $key => $value) {
6713 $key_prefix = $this->getPrefix($key);
6714 $key_localpart = $this->getLocalPart($key);
6715 // if ns declarations, add to class level array of valid namespaces
6716 if ($key_prefix == 'xmlns') {
6717 if (preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/', $value)) {
6718 $this->XMLSchemaVersion = $value;
6719 $this->namespaces['xsd'] = $this->XMLSchemaVersion;
6720 $this->namespaces['xsi'] = $this->XMLSchemaVersion . '-instance';
6721 }
6722 $this->namespaces[$key_localpart] = $value;
6723 // set method namespace
6724 if ($name == $this->root_struct_name) {
6725 $this->methodNamespace = $value;
6726 }
6727 // if it's a type declaration, set type
6728 } elseif ($key_localpart == 'type') {
6729 if (isset($this->message[$pos]['type']) && $this->message[$pos]['type'] == 'array') {
6730 // do nothing: already processed arrayType
6731 } else {
6732 $value_prefix = $this->getPrefix($value);
6733 $value_localpart = $this->getLocalPart($value);
6734 $this->message[$pos]['type'] = $value_localpart;
6735 $this->message[$pos]['typePrefix'] = $value_prefix;
6736 if (isset($this->namespaces[$value_prefix])) {
6737 $this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix];
6738 } elseif (isset($attrs['xmlns:' . $value_prefix])) {
6739 $this->message[$pos]['type_namespace'] = $attrs['xmlns:' . $value_prefix];
6740 }
6741 // should do something here with the namespace of specified type?
6742 }
6743 } elseif ($key_localpart == 'arrayType') {
6744 $this->message[$pos]['type'] = 'array';
6745 /* do arrayType ereg here
6746 [1] arrayTypeValue ::= atype asize
6747 [2] atype ::= QName rank*
6748 [3] rank ::= '[' (',')* ']'
6749 [4] asize ::= '[' length~ ']'
6750 [5] length ::= nextDimension* Digit+
6751 [6] nextDimension ::= Digit+ ','
6752 */
6753 $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/';
6754 if (preg_match($expr, $value, $regs)) {
6755 $this->message[$pos]['typePrefix'] = $regs[1];
6756 $this->message[$pos]['arrayTypePrefix'] = $regs[1];
6757 if (isset($this->namespaces[$regs[1]])) {
6758 $this->message[$pos]['arrayTypeNamespace'] = $this->namespaces[$regs[1]];
6759 } elseif (isset($attrs['xmlns:' . $regs[1]])) {
6760 $this->message[$pos]['arrayTypeNamespace'] = $attrs['xmlns:' . $regs[1]];
6761 }
6762 $this->message[$pos]['arrayType'] = $regs[2];
6763 $this->message[$pos]['arraySize'] = $regs[3];
6764 $this->message[$pos]['arrayCols'] = $regs[4];
6765 }
6766 // specifies nil value (or not)
6767 } elseif ($key_localpart == 'nil') {
6768 $this->message[$pos]['nil'] = ($value == 'true' || $value == '1');
6769 // some other attribute
6770 } elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') {
6771 $this->message[$pos]['xattrs']['!' . $key] = $value;
6772 }
6773
6774 if ($key == 'xmlns') {
6775 $this->default_namespace = $value;
6776 }
6777 // log id
6778 if ($key == 'id') {
6779 $this->ids[$value] = $pos;
6780 }
6781 // root
6782 if ($key_localpart == 'root' && $value == 1) {
6783 $this->status = 'method';
6784 $this->root_struct_name = $name;
6785 $this->root_struct = $pos;
6786 $this->debug("found root struct $this->root_struct_name, pos $pos");
6787 }
6788 // for doclit
6789 $attstr .= " $key=\"$value\"";
6790 }
6791 // get namespace - must be done after namespace atts are processed
6792 if (isset($prefix)) {
6793 $this->message[$pos]['namespace'] = $this->namespaces[$prefix];
6794 $this->default_namespace = $this->namespaces[$prefix];
6795 } else {
6796 $this->message[$pos]['namespace'] = $this->default_namespace;
6797 }
6798 if ($this->status == 'header') {
6799 if ($this->root_header != $pos) {
6800 $this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
6801 }
6802 } elseif ($this->root_struct_name != '') {
6803 $this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
6804 }
6805 }
getPrefix($str)
returns the prefix part of a prefixed string returns false, if not prefixed
Definition: nusoap.php:797
$XMLSchemaVersion
Definition: nusoap.php:113
getLocalPart($str)
returns the local part of a prefixed string returns the original string, if not prefixed
Definition: nusoap.php:779

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

Referenced by __construct().

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

Field Documentation

◆ $body_position

nusoap_parser::$body_position = 0

Definition at line 6546 of file nusoap.php.

◆ $debug_flag

nusoap_parser::$debug_flag = true

Definition at line 6542 of file nusoap.php.

◆ $decode_utf8

nusoap_parser::$decode_utf8 = true

Definition at line 6553 of file nusoap.php.

Referenced by __construct().

◆ $default_namespace

nusoap_parser::$default_namespace = ''

Definition at line 6533 of file nusoap.php.

Referenced by start_element().

◆ $depth

nusoap_parser::$depth = 0

Definition at line 6532 of file nusoap.php.

Referenced by character_data(), and start_element().

◆ $depth_array

nusoap_parser::$depth_array = array()

Definition at line 6541 of file nusoap.php.

◆ $document

nusoap_parser::$document = ''

Definition at line 6528 of file nusoap.php.

◆ $fault

nusoap_parser::$fault = false

Definition at line 6537 of file nusoap.php.

◆ $fault_code

nusoap_parser::$fault_code = ''

Definition at line 6538 of file nusoap.php.

◆ $fault_detail

nusoap_parser::$fault_detail = ''

Definition at line 6540 of file nusoap.php.

◆ $fault_str

nusoap_parser::$fault_str = ''

Definition at line 6539 of file nusoap.php.

◆ $ids

nusoap_parser::$ids = array()

Definition at line 6549 of file nusoap.php.

◆ $message

nusoap_parser::$message = array()

Definition at line 6535 of file nusoap.php.

◆ $method

nusoap_parser::$method = ''

Definition at line 6523 of file nusoap.php.

Referenced by __construct().

◆ $methodNamespace

nusoap_parser::$methodNamespace

Definition at line 6519 of file nusoap.php.

◆ $multirefs

nusoap_parser::$multirefs = array()

Definition at line 6551 of file nusoap.php.

◆ $namespaces

nusoap_parser::$namespaces = array()

Definition at line 6534 of file nusoap.php.

◆ $parent

nusoap_parser::$parent = ''

Definition at line 6536 of file nusoap.php.

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

◆ $parser

nusoap_parser::$parser

Definition at line 6520 of file nusoap.php.

◆ $position

nusoap_parser::$position = 0

Definition at line 6531 of file nusoap.php.

◆ $responseHeaders

nusoap_parser::$responseHeaders = ''

Definition at line 6545 of file nusoap.php.

Referenced by getHeaders().

◆ $root_header

nusoap_parser::$root_header = ''

Definition at line 6527 of file nusoap.php.

Referenced by __construct().

◆ $root_struct

nusoap_parser::$root_struct = ''

Definition at line 6524 of file nusoap.php.

Referenced by __construct().

◆ $root_struct_name

nusoap_parser::$root_struct_name = ''

Definition at line 6525 of file nusoap.php.

◆ $root_struct_namespace

nusoap_parser::$root_struct_namespace = ''

Definition at line 6526 of file nusoap.php.

◆ $soapheader

nusoap_parser::$soapheader = null

Definition at line 6544 of file nusoap.php.

Referenced by get_soapheader().

◆ $soapresponse

nusoap_parser::$soapresponse = null

Definition at line 6543 of file nusoap.php.

Referenced by get_response(), and get_soapbody().

◆ $status

nusoap_parser::$status = ''

Definition at line 6530 of file nusoap.php.

Referenced by start_element().

◆ $xml

nusoap_parser::$xml = ''

Definition at line 6521 of file nusoap.php.

Referenced by __construct().

◆ $xml_encoding

nusoap_parser::$xml_encoding = ''

Definition at line 6522 of file nusoap.php.

Referenced by __construct().


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