ILIAS  trunk Revision v11.0_alpha-2645-g16283d3b3f8
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$ public

Definition at line 6521 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 public

Definition at line 6568 of file nusoap.php.

References $id, $res, ILIAS\GlobalScreen\Provider\__construct(), nusoap_base\debug(), and nusoap_base\setError().

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

Definition at line 7042 of file nusoap.php.

References $c, $params, $r, nusoap_base\appendDebug(), nusoap_base\debug(), and nusoap_base\varDump().

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

◆ character_data()

nusoap_parser::character_data (   $parser,
  $data 
)

element content handler

Parameters
resource$parserXML parser object
string$dataelement content private

Definition at line 6923 of file nusoap.php.

References $data.

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

◆ 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 private

Definition at line 6997 of file nusoap.php.

References nusoap_base\debug().

6998  {
6999  // TODO: use the namespace!
7000  if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') {
7001  return (string) $value;
7002  }
7003  if ($type == 'int' || $type == 'integer' || $type == 'short' || $type == 'byte') {
7004  return (int) $value;
7005  }
7006  if ($type == 'float' || $type == 'double' || $type == 'decimal') {
7007  return (float) $value;
7008  }
7009  if ($type == 'boolean') {
7010  if (strtolower($value) == 'false' || strtolower($value) == 'f') {
7011  return false;
7012  }
7013  return (bool) $value;
7014  }
7015  if ($type == 'base64' || $type == 'base64Binary') {
7016  $this->debug('Decode base64 value');
7017  return base64_decode($value);
7018  }
7019  // obscure numeric types
7020  if ($type == 'nonPositiveInteger' || $type == 'negativeInteger'
7021  || $type == 'nonNegativeInteger' || $type == 'positiveInteger'
7022  || $type == 'unsignedInt'
7023  || $type == 'unsignedShort' || $type == 'unsignedByte') {
7024  return (int) $value;
7025  }
7026  // bogus: parser treats array with no elements as a simple type
7027  if ($type == 'array') {
7028  return array();
7029  }
7030  // everything else
7031  return (string) $value;
7032  }
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:250
+ Here is the call graph for this function:

◆ end_element()

nusoap_parser::end_element (   $parser,
  $name 
)

end-element handler

Parameters
resource$parserXML parser object
string$nameelement name private

Definition at line 6818 of file nusoap.php.

References $id, and null.

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

◆ get_response()

nusoap_parser::get_response ( )

get the parsed message (SOAP Body)

Returns
mixed public
Deprecated:
use get_soapbody instead

Definition at line 6950 of file nusoap.php.

6951  {
6952  return $this->soapresponse;
6953  }

◆ get_soapbody()

nusoap_parser::get_soapbody ( )

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

Returns
mixed public

Definition at line 6961 of file nusoap.php.

6962  {
6963  return $this->soapresponse;
6964  }

◆ get_soapheader()

nusoap_parser::get_soapheader ( )

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

Returns
mixed public

Definition at line 6972 of file nusoap.php.

6973  {
6974  return $this->soapheader;
6975  }

◆ getHeaders()

nusoap_parser::getHeaders ( )

get the unparsed SOAP Header

Returns
string XML or empty if no Header public

Definition at line 6983 of file nusoap.php.

6984  {
6985  return $this->responseHeaders;
6986  }

◆ 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 private

Definition at line 6662 of file nusoap.php.

References nusoap_base\$XMLSchemaVersion, nusoap_base\debug(), nusoap_base\getLocalPart(), and nusoap_base\getPrefix().

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

Field Documentation

◆ $body_position

nusoap_parser::$body_position = 0

Definition at line 6550 of file nusoap.php.

◆ $debug_flag

nusoap_parser::$debug_flag = true

Definition at line 6546 of file nusoap.php.

◆ $decode_utf8

nusoap_parser::$decode_utf8 = true

Definition at line 6557 of file nusoap.php.

◆ $default_namespace

nusoap_parser::$default_namespace = ''

Definition at line 6537 of file nusoap.php.

◆ $depth

nusoap_parser::$depth = 0

Definition at line 6536 of file nusoap.php.

◆ $depth_array

nusoap_parser::$depth_array = array()

Definition at line 6545 of file nusoap.php.

◆ $document

nusoap_parser::$document = ''

Definition at line 6532 of file nusoap.php.

◆ $fault

nusoap_parser::$fault = false

Definition at line 6541 of file nusoap.php.

◆ $fault_code

nusoap_parser::$fault_code = ''

Definition at line 6542 of file nusoap.php.

◆ $fault_detail

nusoap_parser::$fault_detail = ''

Definition at line 6544 of file nusoap.php.

◆ $fault_str

nusoap_parser::$fault_str = ''

Definition at line 6543 of file nusoap.php.

◆ $ids

nusoap_parser::$ids = array()

Definition at line 6553 of file nusoap.php.

◆ $message

nusoap_parser::$message = array()

Definition at line 6539 of file nusoap.php.

◆ $method

nusoap_parser::$method = ''

Definition at line 6527 of file nusoap.php.

◆ $methodNamespace

nusoap_parser::$methodNamespace

Definition at line 6523 of file nusoap.php.

◆ $multirefs

nusoap_parser::$multirefs = array()

Definition at line 6555 of file nusoap.php.

◆ $namespaces

nusoap_parser::$namespaces = array()

Definition at line 6538 of file nusoap.php.

◆ $parent

nusoap_parser::$parent = ''

Definition at line 6540 of file nusoap.php.

◆ $parser

nusoap_parser::$parser

Definition at line 6524 of file nusoap.php.

◆ $position

nusoap_parser::$position = 0

Definition at line 6535 of file nusoap.php.

◆ $responseHeaders

nusoap_parser::$responseHeaders = ''

Definition at line 6549 of file nusoap.php.

◆ $root_header

nusoap_parser::$root_header = ''

Definition at line 6531 of file nusoap.php.

◆ $root_struct

nusoap_parser::$root_struct = ''

Definition at line 6528 of file nusoap.php.

◆ $root_struct_name

nusoap_parser::$root_struct_name = ''

Definition at line 6529 of file nusoap.php.

◆ $root_struct_namespace

nusoap_parser::$root_struct_namespace = ''

Definition at line 6530 of file nusoap.php.

◆ $soapheader

nusoap_parser::$soapheader = null

Definition at line 6548 of file nusoap.php.

◆ $soapresponse

nusoap_parser::$soapresponse = null

Definition at line 6547 of file nusoap.php.

◆ $status

nusoap_parser::$status = ''

Definition at line 6534 of file nusoap.php.

◆ $xml

nusoap_parser::$xml = ''

Definition at line 6525 of file nusoap.php.

◆ $xml_encoding

nusoap_parser::$xml_encoding = ''

Definition at line 6526 of file nusoap.php.


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