ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
nusoap_parser Class Reference

nusoap_parser class parses SOAP XML messages into native PHP values More...

+ Inheritance diagram for nusoap_parser:
+ Collaboration diagram for nusoap_parser:

Public Member Functions

 __construct ($xml, $encoding='UTF-8', $method='', $decode_utf8=true)
 constructor that actually does the parsing More...
 
 start_element ($parser, $name, $attrs)
 start-element handler More...
 
 end_element ($parser, $name)
 end-element handler More...
 
 character_data ($parser, $data)
 element content handler More...
 
 get_response ()
 get the parsed message (SOAP Body) More...
 
 get_soapbody ()
 get the parsed SOAP Body (NULL if there was none) More...
 
 get_soapheader ()
 get the parsed SOAP Header (NULL if there was none) More...
 
 getHeaders ()
 get the unparsed SOAP Header More...
 
 decodeSimple ($value, $type, $typens)
 decodes simple types into PHP variables More...
 
 buildVal ($pos)
 builds response structures for compound values (arrays/structs) and scalars More...
 
- Public Member Functions inherited from nusoap_base
 debug ($string)
 adds debug data to the class level debug string More...
 
 expandEntities ($val)
 expands entities, e.g. More...
 
 getError ()
 returns error string if present More...
 
 setError ($str)
 sets error string More...
 
 isArraySimpleOrStruct ($val)
 detect if array is a simple array or a struct (associative array) More...
 
 serialize_val ($val, $name=false, $type=false, $name_ns=false, $type_ns=false, $attributes=false, $use='encoded')
 serializes PHP values in accordance w/ section 5. More...
 
 serializeEnvelope ($body, $headers=false, $namespaces=array(), $style='rpc', $use='encoded')
 serialize message More...
 
 formatDump ($str)
 
 contractQname ($qname)
 contracts a qualified name More...
 
 expandQname ($qname)
 expands a qualified name More...
 
 getLocalPart ($str)
 returns the local part of a prefixed string returns the original string, if not prefixed More...
 
 getPrefix ($str)
 returns the prefix part of a prefixed string returns false, if not prefixed More...
 
 getNamespaceFromPrefix ($prefix)
 pass it a prefix, it returns a namespace returns false if no namespace registered with the given prefix More...
 
 getPrefixFromNamespace ($ns)
 returns the prefix for a given namespace (or prefix) or false if no prefixes registered for the given namespace More...
 
 varDump ($data)
 
 __construct ()
 constructor More...
 
 getGlobalDebugLevel ()
 gets the global debug level, which applies to future instances More...
 
 setGlobalDebugLevel ($level)
 sets the global debug level, which applies to future instances More...
 
 getDebugLevel ()
 gets the debug level for this instance More...
 
 setDebugLevel ($level)
 sets the debug level for this instance More...
 
 debug ($string)
 adds debug data to the instance debug string with formatting More...
 
 appendDebug ($string)
 adds debug data to the instance debug string without formatting More...
 
 clearDebug ()
 clears the current debug data for this instance More...
 
getDebug ()
 gets the current debug data for this instance More...
 
getDebugAsXMLComment ()
 gets the current debug data for this instance as an XML comment this may change the contents of the debug data More...
 
 expandEntities ($val)
 expands entities, e.g. More...
 
 getError ()
 returns error string if present More...
 
 setError ($str)
 sets error string More...
 
 isArraySimpleOrStruct ($val)
 detect if array is a simple array or a struct (associative array) More...
 
 serialize_val ($val, $name=false, $type=false, $name_ns=false, $type_ns=false, $attributes=false, $use='encoded', $soapval=false)
 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

 $xml = ''
 
 $xml_encoding = ''
 
 $method = ''
 
 $root_struct = ''
 
 $root_struct_name = ''
 
 $root_struct_namespace = ''
 
 $root_header = ''
 
 $document = ''
 
 $status = ''
 
 $position = 0
 
 $depth = 0
 
 $default_namespace = ''
 
 $namespaces = array()
 
 $message = array()
 
 $parent = ''
 
 $fault = false
 
 $fault_code = ''
 
 $fault_str = ''
 
 $fault_detail = ''
 
 $depth_array = array()
 
 $debug_flag = true
 
 $soapresponse = NULL
 
 $soapheader = NULL
 
 $responseHeaders = ''
 
 $body_position = 0
 
 $ids = array()
 
 $multirefs = array()
 
 $decode_utf8 = true
 
- Data Fields inherited from nusoap_base
 $title = 'NuSOAP'
 
 $version = '0.6.7'
 
 $revision = '$Revision$'
 
 $error_str = false
 
 $debug_str = ''
 
 $charencoding = true
 
 $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema'
 
 $soap_defencoding = 'UTF-8'
 
 $namespaces
 
 $usedNamespaces = array()
 
 $typemap
 
 $xmlEntities
 
 $debugLevel
 

Detailed Description

nusoap_parser class parses SOAP XML messages into native PHP values

Author
Dietrich Ayala dietr.nosp@m.ich@.nosp@m.ganx4.nosp@m..com
Scott Nichol snich.nosp@m.ol@u.nosp@m.sers..nosp@m.sour.nosp@m.cefor.nosp@m.ge.n.nosp@m.et
Version
$Id$ public

Definition at line 6425 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 6470 of file nusoap.php.

References $id, $res, $xml, nusoap_base\debug(), and nusoap_base\setError().

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

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

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

References $data.

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

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

References $type, and nusoap_base\debug().

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

References $id, and $name.

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

◆ get_response()

nusoap_parser::get_response ( )

get the parsed message (SOAP Body)

Returns
mixed public
Deprecated:
use get_soapbody instead

Definition at line 6847 of file nusoap.php.

6847  {
6848  return $this->soapresponse;
6849  }

◆ get_soapbody()

nusoap_parser::get_soapbody ( )

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

Returns
mixed public

Definition at line 6857 of file nusoap.php.

6857  {
6858  return $this->soapresponse;
6859  }

◆ get_soapheader()

nusoap_parser::get_soapheader ( )

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

Returns
mixed public

Definition at line 6867 of file nusoap.php.

6867  {
6868  return $this->soapheader;
6869  }

◆ getHeaders()

nusoap_parser::getHeaders ( )

get the unparsed SOAP Header

Returns
string XML or empty if no Header public

Definition at line 6877 of file nusoap.php.

6877  {
6878  return $this->responseHeaders;
6879  }

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

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

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

Field Documentation

◆ $body_position

nusoap_parser::$body_position = 0

Definition at line 6452 of file nusoap.php.

◆ $debug_flag

nusoap_parser::$debug_flag = true

Definition at line 6448 of file nusoap.php.

◆ $decode_utf8

nusoap_parser::$decode_utf8 = true

Definition at line 6459 of file nusoap.php.

◆ $default_namespace

nusoap_parser::$default_namespace = ''

Definition at line 6439 of file nusoap.php.

◆ $depth

nusoap_parser::$depth = 0

Definition at line 6438 of file nusoap.php.

◆ $depth_array

nusoap_parser::$depth_array = array()

Definition at line 6447 of file nusoap.php.

◆ $document

nusoap_parser::$document = ''

Definition at line 6434 of file nusoap.php.

◆ $fault

nusoap_parser::$fault = false

Definition at line 6443 of file nusoap.php.

◆ $fault_code

nusoap_parser::$fault_code = ''

Definition at line 6444 of file nusoap.php.

◆ $fault_detail

nusoap_parser::$fault_detail = ''

Definition at line 6446 of file nusoap.php.

◆ $fault_str

nusoap_parser::$fault_str = ''

Definition at line 6445 of file nusoap.php.

◆ $ids

nusoap_parser::$ids = array()

Definition at line 6455 of file nusoap.php.

◆ $message

nusoap_parser::$message = array()

Definition at line 6441 of file nusoap.php.

◆ $method

nusoap_parser::$method = ''

Definition at line 6429 of file nusoap.php.

◆ $multirefs

nusoap_parser::$multirefs = array()

Definition at line 6457 of file nusoap.php.

◆ $namespaces

nusoap_parser::$namespaces = array()

Definition at line 6440 of file nusoap.php.

◆ $parent

nusoap_parser::$parent = ''

Definition at line 6442 of file nusoap.php.

◆ $position

nusoap_parser::$position = 0

Definition at line 6437 of file nusoap.php.

◆ $responseHeaders

nusoap_parser::$responseHeaders = ''

Definition at line 6451 of file nusoap.php.

◆ $root_header

nusoap_parser::$root_header = ''

Definition at line 6433 of file nusoap.php.

◆ $root_struct

nusoap_parser::$root_struct = ''

Definition at line 6430 of file nusoap.php.

◆ $root_struct_name

nusoap_parser::$root_struct_name = ''

Definition at line 6431 of file nusoap.php.

◆ $root_struct_namespace

nusoap_parser::$root_struct_namespace = ''

Definition at line 6432 of file nusoap.php.

◆ $soapheader

nusoap_parser::$soapheader = NULL

Definition at line 6450 of file nusoap.php.

◆ $soapresponse

nusoap_parser::$soapresponse = NULL

Definition at line 6449 of file nusoap.php.

◆ $status

nusoap_parser::$status = ''

Definition at line 6436 of file nusoap.php.

◆ $xml

nusoap_parser::$xml = ''

Definition at line 6427 of file nusoap.php.

◆ $xml_encoding

nusoap_parser::$xml_encoding = ''

Definition at line 6428 of file nusoap.php.


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