function soap_parser::buildVal in Salesforce Suite 5
Same name in this branch
- 5 includes/nusoap.php \soap_parser::buildVal()
- 5 includes/nusoap.orig.php \soap_parser::buildVal()
Same name and namespace in other branches
- 5.2 includes/nusoap.php \soap_parser::buildVal()
- 5.2 includes/nusoap.orig.php \soap_parser::buildVal()
* builds response structures for compound values (arrays/structs) * and scalars * *
Parameters
integer $pos position in node tree: * @return mixed PHP value * @access private
4 calls to soap_parser::buildVal()
- soap_parser::end_element in includes/
nusoap.php - * end-element handler * *
- soap_parser::end_element in includes/
nusoap.orig.php - * end-element handler * *
- soap_parser::soap_parser in includes/
nusoap.php - * constructor that actually does the parsing * *
- soap_parser::soap_parser in includes/
nusoap.orig.php - * constructor that actually does the parsing * *
File
- includes/
nusoap.orig.php, line 6274
Class
- soap_parser
- soap_parser class parses SOAP XML messages into native PHP values
Code
function buildVal($pos) {
if (!isset($this->message[$pos]['type'])) {
$this->message[$pos]['type'] = '';
}
$this
->debug('in buildVal() for ' . $this->message[$pos]['name'] . "(pos {$pos}) of type " . $this->message[$pos]['type']);
// if there are children...
if ($this->message[$pos]['children'] != '') {
$this
->debug('in buildVal, there are children');
$children = explode('|', $this->message[$pos]['children']);
array_shift($children);
// knock off empty
// md array
if (isset($this->message[$pos]['arrayCols']) && $this->message[$pos]['arrayCols'] != '') {
$r = 0;
// rowcount
$c = 0;
// colcount
foreach ($children as $child_pos) {
$this
->debug("in buildVal, got an MD array element: {$r}, {$c}");
$params[$r][] = $this->message[$child_pos]['result'];
$c++;
if ($c == $this->message[$pos]['arrayCols']) {
$c = 0;
$r++;
}
}
// array
}
elseif ($this->message[$pos]['type'] == 'array' || $this->message[$pos]['type'] == 'Array') {
$this
->debug('in buildVal, adding array ' . $this->message[$pos]['name']);
foreach ($children as $child_pos) {
$params[] =& $this->message[$child_pos]['result'];
}
// apache Map type: java hashtable
}
elseif ($this->message[$pos]['type'] == 'Map' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') {
$this
->debug('in buildVal, Java Map ' . $this->message[$pos]['name']);
foreach ($children as $child_pos) {
$kv = explode("|", $this->message[$child_pos]['children']);
$params[$this->message[$kv[1]]['result']] =& $this->message[$kv[2]]['result'];
}
// generic compound type
//} elseif($this->message[$pos]['type'] == 'SOAPStruct' || $this->message[$pos]['type'] == 'struct') {
}
else {
// Apache Vector type: treat as an array
$this
->debug('in buildVal, adding Java Vector ' . $this->message[$pos]['name']);
if ($this->message[$pos]['type'] == 'Vector' && $this->message[$pos]['type_namespace'] == 'http://xml.apache.org/xml-soap') {
$notstruct = 1;
}
else {
$notstruct = 0;
}
//
foreach ($children as $child_pos) {
if ($notstruct) {
$params[] =& $this->message[$child_pos]['result'];
}
else {
if (isset($params[$this->message[$child_pos]['name']])) {
// de-serialize repeated element name into an array
if (!is_array($params[$this->message[$child_pos]['name']]) || !isset($params[$this->message[$child_pos]['name']][0])) {
$params[$this->message[$child_pos]['name']] = array(
$params[$this->message[$child_pos]['name']],
);
}
$params[$this->message[$child_pos]['name']][] =& $this->message[$child_pos]['result'];
}
else {
$params[$this->message[$child_pos]['name']] =& $this->message[$child_pos]['result'];
}
}
}
}
if (isset($this->message[$pos]['xattrs'])) {
$this
->debug('in buildVal, handling attributes');
foreach ($this->message[$pos]['xattrs'] as $n => $v) {
$params[$n] = $v;
}
}
// handle simpleContent
if (isset($this->message[$pos]['cdata']) && trim($this->message[$pos]['cdata']) != '') {
$this
->debug('in buildVal, handling simpleContent');
if (isset($this->message[$pos]['type'])) {
$params['!'] = $this
->decodeSimple($this->message[$pos]['cdata'], $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
}
else {
$parent = $this->message[$pos]['parent'];
if (isset($this->message[$parent]['type']) && $this->message[$parent]['type'] == 'array' && isset($this->message[$parent]['arrayType'])) {
$params['!'] = $this
->decodeSimple($this->message[$pos]['cdata'], $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
}
else {
$params['!'] = $this->message[$pos]['cdata'];
}
}
}
return is_array($params) ? $params : array();
}
else {
$this
->debug('in buildVal, no children, building scalar');
$cdata = isset($this->message[$pos]['cdata']) ? $this->message[$pos]['cdata'] : '';
if (isset($this->message[$pos]['type'])) {
return $this
->decodeSimple($cdata, $this->message[$pos]['type'], isset($this->message[$pos]['type_namespace']) ? $this->message[$pos]['type_namespace'] : '');
}
$parent = $this->message[$pos]['parent'];
if (isset($this->message[$parent]['type']) && $this->message[$parent]['type'] == 'array' && isset($this->message[$parent]['arrayType'])) {
return $this
->decodeSimple($cdata, $this->message[$parent]['arrayType'], isset($this->message[$parent]['arrayTypeNamespace']) ? $this->message[$parent]['arrayTypeNamespace'] : '');
}
return $this->message[$pos]['cdata'];
}
}