ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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 6565 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 6612 of file nusoap.php.

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

6613  {
6615  $this->xml = $xml;
6616  $this->xml_encoding = $encoding;
6617  $this->method = $method;
6618  $this->decode_utf8 = $decode_utf8;
6619 
6620  // Check whether content has been read.
6621  if (!empty($xml)) {
6622  // Check XML encoding
6623  $pos_xml = strpos($xml, '<?xml');
6624  if ($pos_xml !== false) {
6625  $xml_decl = substr($xml, $pos_xml, strpos($xml, '?>', $pos_xml + 2) - $pos_xml + 1);
6626  if (preg_match("/encoding=[\"']([^\"']*)[\"']/", $xml_decl, $res)) {
6627  $xml_encoding = $res[1];
6628  if (strtoupper($xml_encoding) != $encoding) {
6629  $err = "Charset from HTTP Content-Type '" . $encoding . "' does not match encoding from XML declaration '" . $xml_encoding . "'";
6630  $this->debug($err);
6631  if ($encoding != 'ISO-8859-1' || strtoupper($xml_encoding) != 'UTF-8') {
6632  $this->setError($err);
6633  return;
6634  }
6635  // when HTTP says ISO-8859-1 (the default) and XML says UTF-8 (the typical), assume the other endpoint is just sloppy and proceed
6636  } else {
6637  $this->debug('Charset from HTTP Content-Type matches encoding from XML declaration');
6638  }
6639  } else {
6640  $this->debug('No encoding specified in XML declaration');
6641  }
6642  } else {
6643  $this->debug('No XML declaration');
6644  }
6645  $this->debug('Entering nusoap_parser(), length=' . strlen($xml) . ', encoding=' . $encoding);
6646  // Create an XML parser - why not xml_parser_create_ns?
6647  $this->parser = xml_parser_create($this->xml_encoding);
6648  // Set the options for parsing the XML data.
6649  //xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1);
6650  xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
6651  xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->xml_encoding);
6652  // Set the object for the parser.
6653  xml_set_object($this->parser, $this);
6654  // Set the element handlers for the parser.
6655  xml_set_element_handler($this->parser, 'start_element', 'end_element');
6656  xml_set_character_data_handler($this->parser, 'character_data');
6657 
6658  // Parse the XML file.
6659  if (!xml_parse($this->parser, $xml, true)) {
6660  // Display an error message.
6661  $err = sprintf(
6662  'XML error parsing SOAP payload on line %d: %s',
6663  xml_get_current_line_number($this->parser),
6664  xml_error_string(xml_get_error_code($this->parser))
6665  );
6666  $this->debug($err);
6667  $this->debug("XML payload:\n" . $xml);
6668  $this->setError($err);
6669  } else {
6670  $this->debug('parsed successfully, found root struct: ' . $this->root_struct . ' of name ' . $this->root_struct_name);
6671  // get final value
6672  $this->soapresponse = $this->message[$this->root_struct]['result'];
6673  // get header value
6674  if ($this->root_header != '' && isset($this->message[$this->root_header]['result'])) {
6675  $this->soapheader = $this->message[$this->root_header]['result'];
6676  }
6677  // resolve hrefs/ids
6678  if (sizeof($this->multirefs) > 0) {
6679  foreach ($this->multirefs as $id => $hrefs) {
6680  $this->debug('resolving multirefs for id: ' . $id);
6681  $idVal = $this->buildVal($this->ids[$id]);
6682  if (is_array($idVal) && isset($idVal['!id'])) {
6683  unset($idVal['!id']);
6684  }
6685  foreach ($hrefs as $refPos => $ref) {
6686  $this->debug('resolving href at pos ' . $refPos);
6687  $this->multirefs[$id][$refPos] = $idVal;
6688  }
6689  }
6690  }
6691  }
6692  xml_parser_free($this->parser);
6693  } else {
6694  $this->debug('xml was empty, didn\'t parse!');
6695  $this->setError('xml was empty, didn\'t parse!');
6696  }
6697  }
$res
Definition: ltiservices.php:69
setError($str)
sets error string
Definition: nusoap.php:393
buildVal($pos)
builds response structures for compound values (arrays/structs) and scalars
Definition: nusoap.php:7087
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:290
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24
__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 7087 of file nusoap.php.

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

7088  {
7089  if (!isset($this->message[$pos]['type'])) {
7090  $this->message[$pos]['type'] = '';
7091  }
7092  $this->debug('in buildVal() for ' . $this->message[$pos]['name'] . "(pos $pos) of type " . $this->message[$pos]['type']);
7093  // if there are children...
7094  if ($this->message[$pos]['children'] != '') {
7095  $this->debug('in buildVal, there are children');
7096  $children = explode('|', $this->message[$pos]['children']);
7097  array_shift($children); // knock off empty
7098  // md array
7099  if (isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != '') {
7100  $r=0; // rowcount
7101  $c=0; // colcount
7102  foreach ($children as $child_pos) {
7103  $this->debug("in buildVal, got an MD array element: $r, $c");
7104  $params[$r][] = $this->message[$child_pos]['result'];
7105  $c++;
7106  if ($c == $this->message[$pos]['arrayCols']) {
7107  $c = 0;
7108  $r++;
7109  }
7110  }
7111  // array
7112  } elseif ($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array') {
7113  $this->debug('in buildVal, adding array ' . $this->message[$pos]['name']);
7114  foreach ($children as $child_pos) {
7115  $params[] = &$this->message[$child_pos]['result'];
7116  }
7117  // apache Map type: java hashtable
7118  } elseif ($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') {
7119  $this->debug('in buildVal, Java Map ' . $this->message[$pos]['name']);
7120  foreach ($children as $child_pos) {
7121  $kv = explode("|", $this->message[$child_pos]['children']);
7122  $params[$this->message[$kv[1]]['result']] = &$this->message[$kv[2]]['result'];
7123  }
7124  // generic compound type
7125  //} elseif($this->message[$pos]['type'] == 'SOAPStruct' || $this->message[$pos]['type'] == 'struct') {
7126  } else {
7127  // Apache Vector type: treat as an array
7128  $this->debug('in buildVal, adding Java Vector or generic compound type ' . $this->message[$pos]['name']);
7129  if ($this->message[$pos]['type'] == 'Vector' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') {
7130  $notstruct = 1;
7131  } else {
7132  $notstruct = 0;
7133  }
7134  //
7135  foreach ($children as $child_pos) {
7136  if ($notstruct) {
7137  $params[] = &$this->message[$child_pos]['result'];
7138  } else {
7139  if (isset($params[$this->message[$child_pos]['name']])) {
7140  // de-serialize repeated element name into an array
7141  if ((!is_array($params[$this->message[$child_pos]['name']])) || (!isset($params[$this->message[$child_pos]['name']][0]))) {
7142  $params[$this->message[$child_pos]['name']] = array($params[$this->message[$child_pos]['name']]);
7143  }
7144  $params[$this->message[$child_pos]['name']][] = &$this->message[$child_pos]['result'];
7145  } else {
7146  $params[$this->message[$child_pos]['name']] = &$this->message[$child_pos]['result'];
7147  }
7148  }
7149  }
7150  }
7151  if (isset($this->message[$pos]['xattrs'])) {
7152  $this->debug('in buildVal, handling attributes');
7153  foreach ($this->message[$pos]['xattrs'] as $n => $v) {
7154  $params[$n] = $v;
7155  }
7156  }
7157  // handle simpleContent
7158  if (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
7159  $this->debug('in buildVal, handling simpleContent');
7160  if (isset($this->message[$pos]['type'])) {
7161  $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
7162  } else {
7163  $parent = $this->message[$pos]['parent'];
7164  if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
7165  $params['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
7166  } else {
7167  $params['!'] = $this->message[$pos]['cdata'];
7168  }
7169  }
7170  }
7171  $ret = is_array($params) ? $params : array();
7172  $this->debug('in buildVal, return:');
7173  $this->appendDebug($this->varDump($ret));
7174  return $ret;
7175  } else {
7176  $this->debug('in buildVal, no children, building scalar');
7177  $cdata = isset($this->message[$pos]['cdata']) ? $this->message[$pos]['cdata'] : '';
7178  if (isset($this->message[$pos]['type'])) {
7179  $ret = $this->decodeSimple($cdata, $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
7180  $this->debug("in buildVal, return: $ret");
7181  return $ret;
7182  }
7183  $parent = $this->message[$pos]['parent'];
7184  if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
7185  $ret = $this->decodeSimple($cdata, $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
7186  $this->debug("in buildVal, return: $ret");
7187  return $ret;
7188  }
7189  $ret = $this->message[$pos]['cdata'];
7190  $this->debug("in buildVal, return: $ret");
7191  return $ret;
7192  }
7193  }
appendDebug($string)
adds debug data to the instance debug string without formatting
Definition: nusoap.php:303
decodeSimple($value, $type, $typens)
decodes simple types into PHP variables
Definition: nusoap.php:7042
if(! $DIC->user() ->getId()||!ilLTIConsumerAccess::hasCustomProviderCreationAccess()) $params
Definition: ltiregstart.php:31
$c
Definition: deliver.php:9
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:290
varDump($data)
Returns a string with the output of var_dump.
Definition: nusoap.php:907
$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 6968 of file nusoap.php.

References $data.

6969  {
6970  $pos = $this->depth_array[$this->depth];
6971  if ($this->xml_encoding=='UTF-8') {
6972  // TODO: add an option to disable this for folks who want
6973  // raw UTF-8 that, e.g., might not map to iso-8859-1
6974  // TODO: this can also be handled with xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1");
6975  if ($this->decode_utf8) {
6976  $data = utf8_decode($data);
6977  }
6978  }
6979  $this->message[$pos]['cdata'] .= $data;
6980  // for doclit
6981  if ($this->status == 'header') {
6982  $this->responseHeaders .= $data;
6983  } else {
6984  $this->document .= $data;
6985  }
6986  }

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

References nusoap_base\debug().

7043  {
7044  // TODO: use the namespace!
7045  if ((!isset($type)) || $type == 'string' || $type == 'long' || $type == 'unsignedLong') {
7046  return (string) $value;
7047  }
7048  if ($type == 'int' || $type == 'integer' || $type == 'short' || $type == 'byte') {
7049  return (int) $value;
7050  }
7051  if ($type == 'float' || $type == 'double' || $type == 'decimal') {
7052  return (float) $value;
7053  }
7054  if ($type == 'boolean') {
7055  if (strtolower($value) == 'false' || strtolower($value) == 'f') {
7056  return false;
7057  }
7058  return (bool) $value;
7059  }
7060  if ($type == 'base64' || $type == 'base64Binary') {
7061  $this->debug('Decode base64 value');
7062  return base64_decode($value);
7063  }
7064  // obscure numeric types
7065  if ($type == 'nonPositiveInteger' || $type == 'negativeInteger'
7066  || $type == 'nonNegativeInteger' || $type == 'positiveInteger'
7067  || $type == 'unsignedInt'
7068  || $type == 'unsignedShort' || $type == 'unsignedByte') {
7069  return (int) $value;
7070  }
7071  // bogus: parser treats array with no elements as a simple type
7072  if ($type == 'array') {
7073  return array();
7074  }
7075  // everything else
7076  return (string) $value;
7077  }
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:290
+ 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 6863 of file nusoap.php.

References $id.

6864  {
6865  // position of current element is equal to the last value left in depth_array for my depth
6866  $pos = $this->depth_array[$this->depth--];
6867 
6868  // get element prefix
6869  if (strpos($name, ':')) {
6870  // get ns prefix
6871  $prefix = substr($name, 0, strpos($name, ':'));
6872  // get unqualified name
6873  $name = substr(strstr($name, ':'), 1);
6874  }
6875 
6876  // build to native type
6877  if (isset($this->body_position) && $pos > $this->body_position) {
6878  // deal w/ multirefs
6879  if (isset($this->message[$pos]['attrs']['href'])) {
6880  // get id
6881  $id = substr($this->message[$pos]['attrs']['href'], 1);
6882  // add placeholder to href array
6883  $this->multirefs[$id][$pos] = 'placeholder';
6884  // add set a reference to it as the result value
6885  $this->message[$pos]['result'] =& $this->multirefs[$id][$pos];
6886  // build complexType values
6887  } elseif ($this->message[$pos]['children'] != '') {
6888  // if result has already been generated (struct/array)
6889  if (!isset($this->message[$pos]['result'])) {
6890  $this->message[$pos]['result'] = $this->buildVal($pos);
6891  }
6892  // build complexType values of attributes and possibly simpleContent
6893  } elseif (isset($this->message[$pos]['xattrs'])) {
6894  if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
6895  $this->message[$pos]['xattrs']['!'] = null;
6896  } elseif (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
6897  if (isset($this->message[$pos]['type'])) {
6898  $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'] : '');
6899  } else {
6900  $parent = $this->message[$pos]['parent'];
6901  if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
6902  $this->message[$pos]['xattrs']['!'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
6903  } else {
6904  $this->message[$pos]['xattrs']['!'] = $this->message[$pos]['cdata'];
6905  }
6906  }
6907  }
6908  $this->message[$pos]['result'] = $this->message[$pos]['xattrs'];
6909  // set value of simpleType (or nil complexType)
6910  } else {
6911  //$this->debug('adding data for scalar value '.$this->message[$pos]['name'].' of value '.$this->message[$pos]['cdata']);
6912  if (isset($this->message[$pos]['nil']) && $this->message[$pos]['nil']) {
6913  $this->message[$pos]['xattrs']['!'] = null;
6914  } elseif (isset($this->message[$pos]['type'])) {
6915  $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'] : '');
6916  } else {
6917  $parent = $this->message[$pos]['parent'];
6918  if (isset($this->message[$parent]['type']) && ($this->message[$parent]['type'] == 'array') && isset($this->message[$parent]['arrayType'])) {
6919  $this->message[$pos]['result'] = $this->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
6920  } else {
6921  $this->message[$pos]['result'] = $this->message[$pos]['cdata'];
6922  }
6923  }
6924 
6925  /* add value to parent's result, if parent is struct/array
6926  $parent = $this->message[$pos]['parent'];
6927  if($this->message[$parent]['type'] != 'map'){
6928  if(strtolower($this->message[$parent]['type']) == 'array'){
6929  $this->message[$parent]['result'][] = $this->message[$pos]['result'];
6930  } else {
6931  $this->message[$parent]['result'][$this->message[$pos]['name']] = $this->message[$pos]['result'];
6932  }
6933  }
6934  */
6935  }
6936  }
6937 
6938  // for doclit
6939  if ($this->status == 'header') {
6940  if ($this->root_header != $pos) {
6941  $this->responseHeaders .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
6942  }
6943  } elseif ($pos >= $this->root_struct) {
6944  $this->document .= "</" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
6945  }
6946  // switch status
6947  if ($pos == $this->root_struct) {
6948  $this->status = 'body';
6949  $this->root_struct_namespace = $this->message[$pos]['namespace'];
6950  } elseif ($name == 'Body') {
6951  $this->status = 'envelope';
6952  } elseif ($name == 'Header') {
6953  $this->status = 'envelope';
6954  } elseif ($name == 'Envelope') {
6955  //
6956  }
6957  // set parent back to my parent
6958  $this->parent = $this->message[$pos]['parent'];
6959  }
decodeSimple($value, $type, $typens)
decodes simple types into PHP variables
Definition: nusoap.php:7042
buildVal($pos)
builds response structures for compound values (arrays/structs) and scalars
Definition: nusoap.php:7087
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:24

◆ get_response()

nusoap_parser::get_response ( )

get the parsed message (SOAP Body)

Returns
mixed public
Deprecated:
use get_soapbody instead

Definition at line 6995 of file nusoap.php.

6996  {
6997  return $this->soapresponse;
6998  }

◆ get_soapbody()

nusoap_parser::get_soapbody ( )

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

Returns
mixed public

Definition at line 7006 of file nusoap.php.

7007  {
7008  return $this->soapresponse;
7009  }

◆ get_soapheader()

nusoap_parser::get_soapheader ( )

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

Returns
mixed public

Definition at line 7017 of file nusoap.php.

7018  {
7019  return $this->soapheader;
7020  }

◆ getHeaders()

nusoap_parser::getHeaders ( )

get the unparsed SOAP Header

Returns
string XML or empty if no Header public

Definition at line 7028 of file nusoap.php.

7029  {
7030  return $this->responseHeaders;
7031  }

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

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

6708  {
6709  // position in a total number of elements, starting from 0
6710  // update class level pos
6711  $pos = $this->position++;
6712  // and set mine
6713  $this->message[$pos] = array('pos' => $pos,'children'=>'','cdata'=>'');
6714  // depth = how many levels removed from root?
6715  // set mine as current global depth and increment global depth value
6716  $this->message[$pos]['depth'] = $this->depth++;
6717 
6718  // else add self as child to whoever the current parent is
6719  if ($pos != 0) {
6720  $this->message[$this->parent]['children'] .= '|' . $pos;
6721  }
6722  // set my parent
6723  $this->message[$pos]['parent'] = $this->parent;
6724  // set self as current parent
6725  $this->parent = $pos;
6726  // set self as current value for this depth
6727  $this->depth_array[$this->depth] = $pos;
6728  // get element prefix
6729  if (strpos($name, ':')) {
6730  // get ns prefix
6731  $prefix = substr($name, 0, strpos($name, ':'));
6732  // get unqualified name
6733  $name = substr(strstr($name, ':'), 1);
6734  }
6735  // set status
6736  if ($name == 'Envelope') {
6737  $this->status = 'envelope';
6738  } elseif ($name == 'Header' && $this->status = 'envelope') {
6739  $this->root_header = $pos;
6740  $this->status = 'header';
6741  } elseif ($name == 'Body' && $this->status = 'envelope') {
6742  $this->status = 'body';
6743  $this->body_position = $pos;
6744  // set method
6745  } elseif ($this->status == 'body' && $pos == ($this->body_position+1)) {
6746  $this->status = 'method';
6747  $this->root_struct_name = $name;
6748  $this->root_struct = $pos;
6749  $this->message[$pos]['type'] = 'struct';
6750  $this->debug("found root struct $this->root_struct_name, pos $this->root_struct");
6751  }
6752  // set my status
6753  $this->message[$pos]['status'] = $this->status;
6754  // set name
6755  $this->message[$pos]['name'] = htmlspecialchars($name);
6756  // set attrs
6757  $this->message[$pos]['attrs'] = $attrs;
6758 
6759  // loop through atts, logging ns and type declarations
6760  $attstr = '';
6761  foreach ($attrs as $key => $value) {
6762  $key_prefix = $this->getPrefix($key);
6763  $key_localpart = $this->getLocalPart($key);
6764  // if ns declarations, add to class level array of valid namespaces
6765  if ($key_prefix == 'xmlns') {
6766  if (preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/', $value)) {
6767  $this->XMLSchemaVersion = $value;
6768  $this->namespaces['xsd'] = $this->XMLSchemaVersion;
6769  $this->namespaces['xsi'] = $this->XMLSchemaVersion . '-instance';
6770  }
6771  $this->namespaces[$key_localpart] = $value;
6772  // set method namespace
6773  if ($name == $this->root_struct_name) {
6774  $this->methodNamespace = $value;
6775  }
6776  // if it's a type declaration, set type
6777  } elseif ($key_localpart == 'type') {
6778  if (isset($this->message[$pos]['type']) && $this->message[$pos]['type'] == 'array') {
6779  // do nothing: already processed arrayType
6780  } else {
6781  $value_prefix = $this->getPrefix($value);
6782  $value_localpart = $this->getLocalPart($value);
6783  $this->message[$pos]['type'] = $value_localpart;
6784  $this->message[$pos]['typePrefix'] = $value_prefix;
6785  if (isset($this->namespaces[$value_prefix])) {
6786  $this->message[$pos]['type_namespace'] = $this->namespaces[$value_prefix];
6787  } elseif (isset($attrs['xmlns:' . $value_prefix])) {
6788  $this->message[$pos]['type_namespace'] = $attrs['xmlns:' . $value_prefix];
6789  }
6790  // should do something here with the namespace of specified type?
6791  }
6792  } elseif ($key_localpart == 'arrayType') {
6793  $this->message[$pos]['type'] = 'array';
6794  /* do arrayType ereg here
6795  [1] arrayTypeValue ::= atype asize
6796  [2] atype ::= QName rank*
6797  [3] rank ::= '[' (',')* ']'
6798  [4] asize ::= '[' length~ ']'
6799  [5] length ::= nextDimension* Digit+
6800  [6] nextDimension ::= Digit+ ','
6801  */
6802  $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/';
6803  if (preg_match($expr, $value, $regs)) {
6804  $this->message[$pos]['typePrefix'] = $regs[1];
6805  $this->message[$pos]['arrayTypePrefix'] = $regs[1];
6806  if (isset($this->namespaces[$regs[1]])) {
6807  $this->message[$pos]['arrayTypeNamespace'] = $this->namespaces[$regs[1]];
6808  } elseif (isset($attrs['xmlns:' . $regs[1]])) {
6809  $this->message[$pos]['arrayTypeNamespace'] = $attrs['xmlns:' . $regs[1]];
6810  }
6811  $this->message[$pos]['arrayType'] = $regs[2];
6812  $this->message[$pos]['arraySize'] = $regs[3];
6813  $this->message[$pos]['arrayCols'] = $regs[4];
6814  }
6815  // specifies nil value (or not)
6816  } elseif ($key_localpart == 'nil') {
6817  $this->message[$pos]['nil'] = ($value == 'true' || $value == '1');
6818  // some other attribute
6819  } elseif ($key != 'href' && $key != 'xmlns' && $key_localpart != 'encodingStyle' && $key_localpart != 'root') {
6820  $this->message[$pos]['xattrs']['!' . $key] = $value;
6821  }
6822 
6823  if ($key == 'xmlns') {
6824  $this->default_namespace = $value;
6825  }
6826  // log id
6827  if ($key == 'id') {
6828  $this->ids[$value] = $pos;
6829  }
6830  // root
6831  if ($key_localpart == 'root' && $value == 1) {
6832  $this->status = 'method';
6833  $this->root_struct_name = $name;
6834  $this->root_struct = $pos;
6835  $this->debug("found root struct $this->root_struct_name, pos $pos");
6836  }
6837  // for doclit
6838  $attstr .= " $key=\"$value\"";
6839  }
6840  // get namespace - must be done after namespace atts are processed
6841  if (isset($prefix)) {
6842  $this->message[$pos]['namespace'] = $this->namespaces[$prefix];
6843  $this->default_namespace = $this->namespaces[$prefix];
6844  } else {
6845  $this->message[$pos]['namespace'] = $this->default_namespace;
6846  }
6847  if ($this->status == 'header') {
6848  if ($this->root_header != $pos) {
6849  $this->responseHeaders .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
6850  }
6851  } elseif ($this->root_struct_name != '') {
6852  $this->document .= "<" . (isset($prefix) ? $prefix . ':' : '') . "$name$attstr>";
6853  }
6854  }
$XMLSchemaVersion
Definition: nusoap.php:153
getLocalPart($str)
returns the local part of a prefixed string returns the original string, if not prefixed ...
Definition: nusoap.php:819
debug($string)
adds debug data to the instance debug string with formatting
Definition: nusoap.php:290
getPrefix($str)
returns the prefix part of a prefixed string returns false, if not prefixed
Definition: nusoap.php:837
+ Here is the call graph for this function:

Field Documentation

◆ $body_position

nusoap_parser::$body_position = 0

Definition at line 6594 of file nusoap.php.

◆ $debug_flag

nusoap_parser::$debug_flag = true

Definition at line 6590 of file nusoap.php.

◆ $decode_utf8

nusoap_parser::$decode_utf8 = true

Definition at line 6601 of file nusoap.php.

◆ $default_namespace

nusoap_parser::$default_namespace = ''

Definition at line 6581 of file nusoap.php.

◆ $depth

nusoap_parser::$depth = 0

Definition at line 6580 of file nusoap.php.

◆ $depth_array

nusoap_parser::$depth_array = array()

Definition at line 6589 of file nusoap.php.

◆ $document

nusoap_parser::$document = ''

Definition at line 6576 of file nusoap.php.

◆ $fault

nusoap_parser::$fault = false

Definition at line 6585 of file nusoap.php.

◆ $fault_code

nusoap_parser::$fault_code = ''

Definition at line 6586 of file nusoap.php.

◆ $fault_detail

nusoap_parser::$fault_detail = ''

Definition at line 6588 of file nusoap.php.

◆ $fault_str

nusoap_parser::$fault_str = ''

Definition at line 6587 of file nusoap.php.

◆ $ids

nusoap_parser::$ids = array()

Definition at line 6597 of file nusoap.php.

◆ $message

nusoap_parser::$message = array()

Definition at line 6583 of file nusoap.php.

◆ $method

nusoap_parser::$method = ''

Definition at line 6571 of file nusoap.php.

◆ $methodNamespace

nusoap_parser::$methodNamespace

Definition at line 6567 of file nusoap.php.

◆ $multirefs

nusoap_parser::$multirefs = array()

Definition at line 6599 of file nusoap.php.

◆ $namespaces

nusoap_parser::$namespaces = array()

Definition at line 6582 of file nusoap.php.

◆ $parent

nusoap_parser::$parent = ''

Definition at line 6584 of file nusoap.php.

◆ $parser

nusoap_parser::$parser

Definition at line 6568 of file nusoap.php.

◆ $position

nusoap_parser::$position = 0

Definition at line 6579 of file nusoap.php.

◆ $responseHeaders

nusoap_parser::$responseHeaders = ''

Definition at line 6593 of file nusoap.php.

◆ $root_header

nusoap_parser::$root_header = ''

Definition at line 6575 of file nusoap.php.

◆ $root_struct

nusoap_parser::$root_struct = ''

Definition at line 6572 of file nusoap.php.

◆ $root_struct_name

nusoap_parser::$root_struct_name = ''

Definition at line 6573 of file nusoap.php.

◆ $root_struct_namespace

nusoap_parser::$root_struct_namespace = ''

Definition at line 6574 of file nusoap.php.

◆ $soapheader

nusoap_parser::$soapheader = null

Definition at line 6592 of file nusoap.php.

◆ $soapresponse

nusoap_parser::$soapresponse = null

Definition at line 6591 of file nusoap.php.

◆ $status

nusoap_parser::$status = ''

Definition at line 6578 of file nusoap.php.

◆ $xml

nusoap_parser::$xml = ''

Definition at line 6569 of file nusoap.php.

◆ $xml_encoding

nusoap_parser::$xml_encoding = ''

Definition at line 6570 of file nusoap.php.


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