mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-06-26 04:41:41 +02:00
Formatting, add Id tags
This commit is contained in:
parent
d247b25603
commit
927fb55c0a
@ -30,6 +30,9 @@
|
|||||||
|
|
||||||
// $path can be a complete endpoint url, with the other parameters left blank:
|
// $path can be a complete endpoint url, with the other parameters left blank:
|
||||||
// $soap_client = new soap_client("http://path/to/soap/server");
|
// $soap_client = new soap_client("http://path/to/soap/server");
|
||||||
|
|
||||||
|
/* $Id$ */
|
||||||
|
|
||||||
class soap_client
|
class soap_client
|
||||||
{
|
{
|
||||||
function soap_client($path,$server=False,$port=False)
|
function soap_client($path,$server=False,$port=False)
|
||||||
@ -40,30 +43,30 @@
|
|||||||
$this->errno;
|
$this->errno;
|
||||||
$this->errstring;
|
$this->errstring;
|
||||||
$this->debug_flag = False;
|
$this->debug_flag = False;
|
||||||
$this->debug_str = "";
|
$this->debug_str = '';
|
||||||
$this->username = "";
|
$this->username = '';
|
||||||
$this->password = "";
|
$this->password = '';
|
||||||
$this->action = "";
|
$this->action = '';
|
||||||
$this->incoming_payload = "";
|
$this->incoming_payload = '';
|
||||||
$this->outgoing_payload = "";
|
$this->outgoing_payload = '';
|
||||||
$this->response = "";
|
$this->response = '';
|
||||||
$this->action = "";
|
$this->action = '';
|
||||||
|
|
||||||
// endpoint mangling
|
// endpoint mangling
|
||||||
if(ereg("^http://",$path))
|
if(ereg("^http://",$path))
|
||||||
{
|
{
|
||||||
$path = str_replace("http://","",$path);
|
$path = str_replace('http://','',$path);
|
||||||
$this->path = strstr($path,"/");
|
$this->path = strstr($path,'/');
|
||||||
$this->debug("path = $this->path");
|
$this->debug("path = $this->path");
|
||||||
if(ereg(":",$path))
|
if(ereg(':',$path))
|
||||||
{
|
{
|
||||||
$this->server = substr($path,0,strpos($path,":"));
|
$this->server = substr($path,0,strpos($path,':'));
|
||||||
$this->port = substr(strstr($path,":"),1);
|
$this->port = substr(strstr($path,':'),1);
|
||||||
$this->port = substr($this->port,0,strpos($this->port,"/"));
|
$this->port = substr($this->port,0,strpos($this->port,'/'));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->server = substr($path,0,strpos($path,"/"));
|
$this->server = substr($path,0,strpos($path,'/'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($port)
|
if($port)
|
||||||
@ -132,19 +135,21 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$soap_data = $msg->serialize();
|
$soap_data = $msg->serialize();
|
||||||
$this->outgoing_payload = "POST ".
|
$this->outgoing_payload = 'POST '
|
||||||
$this->path.
|
. $this->path
|
||||||
" HTTP/1.0\r\n".
|
. " HTTP/1.0\r\n"
|
||||||
"User-Agent: SOAPx4 v0.13492\r\n".
|
. 'User-Agent: phpGroupware/' . $cliversion . '(PHP) ' . "\r\n"
|
||||||
"Host: ".$this->server . "\r\n".
|
. 'X-PHPGW-Server: ' . $this->server . "\r\n"
|
||||||
$credentials.
|
. 'X-PHPGW-Version: ' . $GLOBALS['phpgw_info']['server']['versions']['phpgwapi'] . "\r\n"
|
||||||
"Content-Type: text/xml\r\nContent-Length: ".strlen($soap_data)."\r\n".
|
. 'Host: '.$this->server . "\r\n"
|
||||||
"SOAPAction: \"$this->action\""."\r\n\r\n".
|
. $credentials
|
||||||
$soap_data;
|
. "Content-Type: text/xml\r\nContent-Length: " . strlen($soap_data) . "\r\n"
|
||||||
|
. 'SOAPAction: "' . $this->action . '"' . "\r\n\r\n"
|
||||||
|
. $soap_data;
|
||||||
// send
|
// send
|
||||||
if(!fputs($fp, $this->outgoing_payload, strlen($this->outgoing_payload)))
|
if(!fputs($fp, $this->outgoing_payload, strlen($this->outgoing_payload)))
|
||||||
{
|
{
|
||||||
$this->debug("Write error");
|
$this->debug('Write error');
|
||||||
}
|
}
|
||||||
|
|
||||||
// get reponse
|
// get reponse
|
||||||
@ -181,15 +186,17 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$soap_data = $msg->serialize();
|
$soap_data = $msg->serialize();
|
||||||
$this->outgoing_payload = "POST ".
|
$this->outgoing_payload = 'POST '
|
||||||
$this->path.
|
. $this->path
|
||||||
" HTTP/1.0\r\n".
|
. " HTTP/1.0\r\n"
|
||||||
"User-Agent: SOAPx4 v0.13492\r\n".
|
. 'User-Agent: phpGroupware/' . $cliversion . '(PHP) ' . "\r\n"
|
||||||
"Host: ".$this->server . "\r\n".
|
. 'X-PHPGW-Server: ' . $this->server . "\r\n"
|
||||||
$credentials.
|
. 'X-PHPGW-Version: ' . $GLOBALS['phpgw_info']['server']['versions']['phpgwapi'] . "\r\n"
|
||||||
"Content-Type: text/xml\r\nContent-Length: ".strlen($soap_data)."\r\n".
|
. 'Host: ' . $this->server . "\r\n"
|
||||||
"SOAPAction: \"$this->action\""."\r\n\r\n".
|
. $credentials
|
||||||
$soap_data;
|
. "Content-Type: text/xml\r\nContent-Length: " . strlen($soap_data) . "\r\n"
|
||||||
|
. 'SOAPAction: "' . $this->action . '"' . "\r\n\r\n"
|
||||||
|
. $soap_data;
|
||||||
|
|
||||||
// send
|
// send
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/* $Id$ */
|
||||||
|
|
||||||
class soap_parser
|
class soap_parser
|
||||||
{
|
{
|
||||||
function soap_parser($xml='',$encoding='UTF-8')
|
function soap_parser($xml='',$encoding='UTF-8')
|
||||||
@ -11,35 +13,35 @@ class soap_parser
|
|||||||
$this->root_struct = "";
|
$this->root_struct = "";
|
||||||
// options: envelope,header,body,method
|
// options: envelope,header,body,method
|
||||||
// determines where in the message we are (envelope,header,body,method)
|
// determines where in the message we are (envelope,header,body,method)
|
||||||
$this->status = "";
|
$this->status = '';
|
||||||
$this->position = 0;
|
$this->position = 0;
|
||||||
$this->pos_stat = 0;
|
$this->pos_stat = 0;
|
||||||
$this->depth = 0;
|
$this->depth = 0;
|
||||||
$this->default_namespace = "";
|
$this->default_namespace = '';
|
||||||
$this->namespaces = array();
|
$this->namespaces = array();
|
||||||
$this->message = array();
|
$this->message = array();
|
||||||
$this->fault = false;
|
$this->fault = false;
|
||||||
$this->fault_code = "";
|
$this->fault_code = '';
|
||||||
$this->fault_str = "";
|
$this->fault_str = '';
|
||||||
$this->fault_detail = "";
|
$this->fault_detail = '';
|
||||||
$this->eval_str = "";
|
$this->eval_str = '';
|
||||||
$this->depth_array = array();
|
$this->depth_array = array();
|
||||||
$this->debug_flag = True;
|
$this->debug_flag = True;
|
||||||
$this->debug_str = "";
|
$this->debug_str = '';
|
||||||
$this->previous_element = "";
|
$this->previous_element = '';
|
||||||
|
|
||||||
$this->entities = array (
|
$this->entities = array (
|
||||||
"&" => "&",
|
'&' => '&',
|
||||||
"<" => "<",
|
'<' => '<',
|
||||||
">" => ">",
|
'>' => '>',
|
||||||
"'" => "'",
|
"'" => ''',
|
||||||
'"' => """
|
'"' => '"'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Check whether content has been read.
|
// Check whether content has been read.
|
||||||
if(!empty($xml))
|
if(!empty($xml))
|
||||||
{
|
{
|
||||||
$this->debug("Entering soap_parser()");
|
$this->debug('Entering soap_parser()');
|
||||||
//$this->debug("DATA DUMP:\n\n$xml");
|
//$this->debug("DATA DUMP:\n\n$xml");
|
||||||
// Create an XML parser.
|
// Create an XML parser.
|
||||||
$this->parser = xml_parser_create($this->xml_encoding);
|
$this->parser = xml_parser_create($this->xml_encoding);
|
||||||
@ -49,9 +51,9 @@ class soap_parser
|
|||||||
// Set the object for the parser.
|
// Set the object for the parser.
|
||||||
xml_set_object($this->parser, &$this);
|
xml_set_object($this->parser, &$this);
|
||||||
// Set the element handlers for the parser.
|
// Set the element handlers for the parser.
|
||||||
xml_set_element_handler($this->parser, "start_element","end_element");
|
xml_set_element_handler($this->parser, 'start_element','end_element');
|
||||||
xml_set_character_data_handler($this->parser,"character_data");
|
xml_set_character_data_handler($this->parser,'character_data');
|
||||||
xml_set_default_handler($this->parser, "default_handler");
|
xml_set_default_handler($this->parser, 'default_handler');
|
||||||
|
|
||||||
// Parse the XML file.
|
// Parse the XML file.
|
||||||
if(!xml_parse($this->parser,$xml,true))
|
if(!xml_parse($this->parser,$xml,true))
|
||||||
@ -79,28 +81,28 @@ class soap_parser
|
|||||||
function build_eval($pos)
|
function build_eval($pos)
|
||||||
{
|
{
|
||||||
$this->debug("inside build_eval() for $pos: ".$this->message[$pos]["name"]);
|
$this->debug("inside build_eval() for $pos: ".$this->message[$pos]["name"]);
|
||||||
$eval_str = $this->message[$pos]["eval_str"];
|
$eval_str = $this->message[$pos]['eval_str'];
|
||||||
// loop through children, building...
|
// loop through children, building...
|
||||||
if($this->message[$pos]["children"] != "")
|
if($this->message[$pos]['children'] != '')
|
||||||
{
|
{
|
||||||
$this->debug("children string = ".$this->message[$pos]["children"]);
|
$this->debug('children string = '.$this->message[$pos]['children']);
|
||||||
$children = explode("|",$this->message[$pos]["children"]);
|
$children = explode('|',$this->message[$pos]['children']);
|
||||||
$this->debug("it has ".count($children)." children");
|
$this->debug('it has '.count($children).' children');
|
||||||
@reset($children);
|
@reset($children);
|
||||||
while(list($c,$child_pos) = @each($children))
|
while(list($c,$child_pos) = @each($children))
|
||||||
/* foreach($children as $c => $child_pos) */
|
/* foreach($children as $c => $child_pos) */
|
||||||
{
|
{
|
||||||
//$this->debug("child pos $child_pos: ".$this->message[$child_pos]["name"]);
|
//$this->debug("child pos $child_pos: ".$this->message[$child_pos]["name"]);
|
||||||
if($this->message[$child_pos]["eval_str"] != "")
|
if($this->message[$child_pos]['eval_str'] != '')
|
||||||
{
|
{
|
||||||
$this->debug("entering build_eval() for ".$this->message[$child_pos]["name"].", array pos $c, pos: $child_pos");
|
$this->debug('entering build_eval() for '.$this->message[$child_pos]['name'].", array pos $c, pos: $child_pos");
|
||||||
$eval_str .= $this->build_eval($child_pos).", ";
|
$eval_str .= $this->build_eval($child_pos).', ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$eval_str = substr($eval_str,0,strlen($eval_str)-2);
|
$eval_str = substr($eval_str,0,strlen($eval_str)-2);
|
||||||
}
|
}
|
||||||
// add current node's eval_str
|
// add current node's eval_str
|
||||||
$eval_str .= $this->message[$pos]["end_eval_str"];
|
$eval_str .= $this->message[$pos]['end_eval_str'];
|
||||||
return $eval_str;
|
return $eval_str;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,21 +113,21 @@ class soap_parser
|
|||||||
// update class level pos
|
// update class level pos
|
||||||
$pos = $this->position++;
|
$pos = $this->position++;
|
||||||
// and set mine
|
// and set mine
|
||||||
$this->message[$pos]["pos"] = $pos;
|
$this->message[$pos]['pos'] = $pos;
|
||||||
|
|
||||||
// parent/child/depth determinations
|
// parent/child/depth determinations
|
||||||
|
|
||||||
// depth = how many levels removed from root?
|
// depth = how many levels removed from root?
|
||||||
// set mine as current global depth and increment global depth value
|
// set mine as current global depth and increment global depth value
|
||||||
$this->message[$pos]["depth"] = $this->depth++;
|
$this->message[$pos]['depth'] = $this->depth++;
|
||||||
|
|
||||||
// else add self as child to whoever the current parent is
|
// else add self as child to whoever the current parent is
|
||||||
if($pos != 0)
|
if($pos != 0)
|
||||||
{
|
{
|
||||||
$this->message[$this->parent]["children"] .= "|$pos";
|
$this->message[$this->parent]['children'] .= "|$pos";
|
||||||
}
|
}
|
||||||
// set my parent
|
// set my parent
|
||||||
$this->message[$pos]["parent"] = $this->parent;
|
$this->message[$pos]['parent'] = $this->parent;
|
||||||
// set self as current value for this depth
|
// set self as current value for this depth
|
||||||
$this->depth_array[$this->depth] = $pos;
|
$this->depth_array[$this->depth] = $pos;
|
||||||
// set self as current parent
|
// set self as current parent
|
||||||
@ -134,48 +136,48 @@ class soap_parser
|
|||||||
// set status
|
// set status
|
||||||
if(ereg(":Envelope$",$name))
|
if(ereg(":Envelope$",$name))
|
||||||
{
|
{
|
||||||
$this->status = "envelope";
|
$this->status = 'envelope';
|
||||||
}
|
}
|
||||||
elseif(ereg(":Header$",$name))
|
elseif(ereg(":Header$",$name))
|
||||||
{
|
{
|
||||||
$this->status = "header";
|
$this->status = 'header';
|
||||||
}
|
}
|
||||||
elseif(ereg(":Body$",$name))
|
elseif(ereg(":Body$",$name))
|
||||||
{
|
{
|
||||||
$this->status = "body";
|
$this->status = 'body';
|
||||||
// set method
|
// set method
|
||||||
}
|
}
|
||||||
elseif($this->status == "body")
|
elseif($this->status == 'body')
|
||||||
{
|
{
|
||||||
$this->status = "method";
|
$this->status = 'method';
|
||||||
if(ereg(":",$name))
|
if(ereg(':',$name))
|
||||||
{
|
{
|
||||||
$this->root_struct_name = substr(strrchr($name,":"),1);
|
$this->root_struct_name = substr(strrchr($name,':'),1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->root_struct_name = $name;
|
$this->root_struct_name = $name;
|
||||||
}
|
}
|
||||||
$this->root_struct = $pos;
|
$this->root_struct = $pos;
|
||||||
$this->message[$pos]["type"] = "struct";
|
$this->message[$pos]['type'] = 'struct';
|
||||||
}
|
}
|
||||||
// set my status
|
// set my status
|
||||||
$this->message[$pos]["status"] = $this->status;
|
$this->message[$pos]['status'] = $this->status;
|
||||||
|
|
||||||
// set name
|
// set name
|
||||||
$this->message[$pos]["name"] = htmlspecialchars($name);
|
$this->message[$pos]['name'] = htmlspecialchars($name);
|
||||||
// set attrs
|
// set attrs
|
||||||
$this->message[$pos]["attrs"] = $attrs;
|
$this->message[$pos]['attrs'] = $attrs;
|
||||||
// get namespace
|
// get namespace
|
||||||
if(ereg(":",$name))
|
if(ereg(":",$name))
|
||||||
{
|
{
|
||||||
$namespace = substr($name,0,strpos($name,":"));
|
$namespace = substr($name,0,strpos($name,':'));
|
||||||
$this->message[$pos]["namespace"] = $namespace;
|
$this->message[$pos]['namespace'] = $namespace;
|
||||||
$this->default_namespace = $namespace;
|
$this->default_namespace = $namespace;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->message[$pos]["namespace"] = $this->default_namespace;
|
$this->message[$pos]['namespace'] = $this->default_namespace;
|
||||||
}
|
}
|
||||||
// loop through atts, logging ns and type declarations
|
// loop through atts, logging ns and type declarations
|
||||||
@reset($attrs);
|
@reset($attrs);
|
||||||
@ -183,26 +185,26 @@ class soap_parser
|
|||||||
/* foreach($attrs as $key => $value) */
|
/* foreach($attrs as $key => $value) */
|
||||||
{
|
{
|
||||||
// if ns declarations, add to class level array of valid namespaces
|
// if ns declarations, add to class level array of valid namespaces
|
||||||
if(ereg("xmlns:",$key))
|
if(ereg('xmlns:',$key))
|
||||||
{
|
{
|
||||||
$namespaces[substr(strrchr($key,":"),1)] = $value;
|
$namespaces[substr(strrchr($key,':'),1)] = $value;
|
||||||
if($name == $this->root_struct_name)
|
if($name == $this->root_struct_name)
|
||||||
{
|
{
|
||||||
$this->methodNamespace = $value;
|
$this->methodNamespace = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if it's a type declaration, set type
|
// if it's a type declaration, set type
|
||||||
elseif($key == "xsi:type")
|
elseif($key == 'xsi:type')
|
||||||
{
|
{
|
||||||
// then get attname and set $type
|
// then get attname and set $type
|
||||||
$type = substr(strrchr($value,":"),1);
|
$type = substr(strrchr($value,':'),1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set type if available
|
// set type if available
|
||||||
if($type)
|
if($type)
|
||||||
{
|
{
|
||||||
$this->message[$pos]["type"] = $type;
|
$this->message[$pos]['type'] = $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
// debug
|
// debug
|
||||||
@ -218,84 +220,84 @@ class soap_parser
|
|||||||
$this->depth--;
|
$this->depth--;
|
||||||
|
|
||||||
// get type if not set already
|
// get type if not set already
|
||||||
if($this->message[$pos]["type"] == "")
|
if($this->message[$pos]['type'] == '')
|
||||||
{
|
{
|
||||||
// if($this->message[$pos]["cdata"] == "" && $this->message[$pos]["children"] != "")
|
// if($this->message[$pos]['cdata'] == '' && $this->message[$pos]['children'] != '')
|
||||||
if($this->message[$pos]["children"] != "")
|
if($this->message[$pos]['children'] != '')
|
||||||
{
|
{
|
||||||
$this->message[$pos]["type"] = "SOAPStruct";
|
$this->message[$pos]['type'] = 'SOAPStruct';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->message[$pos]["type"] = "string";
|
$this->message[$pos]['type'] = 'string';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// set eval str start if it has a valid type and is inside the method
|
// set eval str start if it has a valid type and is inside the method
|
||||||
if($pos >= $this->root_struct)
|
if($pos >= $this->root_struct)
|
||||||
{
|
{
|
||||||
$this->message[$pos]["eval_str"] .= "\n CreateObject(\"phpgwapi.soapval\",\"".htmlspecialchars($name)."\", \"".$this->message[$pos]["type"]."\" ";
|
$this->message[$pos]['eval_str'] .= "\n CreateObject(\"phpgwapi.soapval\",\"".htmlspecialchars($name)."\", \"".$this->message[$pos]["type"]."\" ";
|
||||||
$this->message[$pos]["end_eval_str"] = ")";
|
$this->message[$pos]['end_eval_str'] = ')';
|
||||||
$this->message[$pos]["inval"] = "true";
|
$this->message[$pos]['inval'] = 'true';
|
||||||
/*
|
/*
|
||||||
if($this->message[$pos]["name"] == $this->root_struct_name){
|
if($this->message[$pos]["name"] == $this->root_struct_name){
|
||||||
$this->message[$pos]["end_eval_str"] .= " ,\"$this->methodNamespace\"";
|
$this->message[$pos]["end_eval_str"] .= " ,\"$this->methodNamespace\"";
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if($this->message[$pos]["children"] != "")
|
if($this->message[$pos]['children'] != '')
|
||||||
{
|
{
|
||||||
$this->message[$pos]["eval_str"] .= ", array( ";
|
$this->message[$pos]['eval_str'] .= ', array( ';
|
||||||
$this->message[$pos]["end_eval_str"] .= " )";
|
$this->message[$pos]['end_eval_str'] .= ' )';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if i have no children and have cdata...then i must be a scalar value, so add my data to the eval_str
|
// if i have no children and have cdata...then i must be a scalar value, so add my data to the eval_str
|
||||||
if($this->status == "method" && $this->message[$pos]["children"] == "")
|
if($this->status == 'method' && $this->message[$pos]['children'] == '')
|
||||||
{
|
{
|
||||||
// add cdata w/ no quotes if only int/float/dbl
|
// add cdata w/ no quotes if only int/float/dbl
|
||||||
if($this->message[$pos]["type"] == "string")
|
if($this->message[$pos]['type'] == 'string')
|
||||||
{
|
{
|
||||||
$this->message[$pos]["eval_str"] .= ", \"".$this->message[$pos]["cdata"]."\"";
|
$this->message[$pos]['eval_str'] .= ", \"".$this->message[$pos]['cdata']."\"";
|
||||||
}
|
}
|
||||||
elseif($this->message[$pos]["type"] == "int" || $this->message[$pos]["type"] == "float" || $this->message[$pos]["type"] == "double")
|
elseif($this->message[$pos]['type'] == 'int' || $this->message[$pos]['type'] == 'float' || $this->message[$pos]['type'] == 'double')
|
||||||
{
|
{
|
||||||
//$this->debug("adding cdata w/o quotes");
|
//$this->debug("adding cdata w/o quotes");
|
||||||
$this->message[$pos]["eval_str"] .= ", ".trim($this->message[$pos]["cdata"]);
|
$this->message[$pos]['eval_str'] .= ', '.trim($this->message[$pos]['cdata']);
|
||||||
}
|
}
|
||||||
elseif(is_string($this->message[$pos]["cdata"]))
|
elseif(is_string($this->message[$pos]['cdata']))
|
||||||
{
|
{
|
||||||
//$this->debug("adding cdata w/ quotes");
|
//$this->debug("adding cdata w/ quotes");
|
||||||
$this->message[$pos]["eval_str"] .= ", \"".$this->message[$pos]["cdata"]."\"";
|
$this->message[$pos]['eval_str'] .= ", \"".$this->message[$pos]['cdata']."\"";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if in the process of making a soap_val, close the parentheses and move on...
|
// if in the process of making a soap_val, close the parentheses and move on...
|
||||||
if($this->message[$pos]["inval"] == "true")
|
if($this->message[$pos]['inval'] == 'true')
|
||||||
{
|
{
|
||||||
$this->message[$pos]["inval"] == "false";
|
$this->message[$pos]['inval'] == 'false';
|
||||||
}
|
}
|
||||||
// if tag we are currently closing is the method wrapper
|
// if tag we are currently closing is the method wrapper
|
||||||
if($pos == $this->root_struct)
|
if($pos == $this->root_struct)
|
||||||
{
|
{
|
||||||
$this->status = "body";
|
$this->status = 'body';
|
||||||
}
|
}
|
||||||
elseif(ereg(":Body",$name))
|
elseif(ereg(':Body',$name))
|
||||||
{
|
{
|
||||||
$this->status = "header";
|
$this->status = 'header';
|
||||||
}
|
}
|
||||||
elseif(ereg(":Header",$name))
|
elseif(ereg(':Header',$name))
|
||||||
{
|
{
|
||||||
$this->status = "envelope";
|
$this->status = 'envelope';
|
||||||
}
|
}
|
||||||
// set parent back to my parent
|
// set parent back to my parent
|
||||||
$this->parent = $this->message[$pos]["parent"];
|
$this->parent = $this->message[$pos]['parent'];
|
||||||
$this->debug("parsed $name end, type '".$this->message[$pos]["type"]."'eval_str = '".trim($this->message[$pos]["eval_str"])."' and children = ".$this->message[$pos]["children"]);
|
$this->debug("parsed $name end, type '".$this->message[$pos]['type']."'eval_str = '".trim($this->message[$pos]['eval_str'])."' and children = ".$this->message[$pos]['children']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// element content handler
|
// element content handler
|
||||||
function character_data($parser, $data)
|
function character_data($parser, $data)
|
||||||
{
|
{
|
||||||
$pos = $this->depth_array[$this->depth];
|
$pos = $this->depth_array[$this->depth];
|
||||||
$this->message[$pos]["cdata"] .= $data;
|
$this->message[$pos]['cdata'] .= $data;
|
||||||
//$this->debug("parsed ".$this->message[$pos]["name"]." cdata, eval = '$this->eval_str'");
|
//$this->debug("parsed ".$this->message[$pos]["name"]." cdata, eval = '$this->eval_str'");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,20 +332,20 @@ class soap_parser
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->debug("ERROR: did not successfully eval the msg");
|
$this->debug('ERROR: did not successfully eval the msg');
|
||||||
$this->fault = true;
|
$this->fault = true;
|
||||||
return CreateObject('phpgwapi.soapval',
|
return CreateObject('phpgwapi.soapval',
|
||||||
"Fault",
|
'Fault',
|
||||||
"struct",
|
'struct',
|
||||||
array(
|
array(
|
||||||
CreateObject('phpgwapi.soapval',
|
CreateObject('phpgwapi.soapval',
|
||||||
"faultcode",
|
'faultcode',
|
||||||
"string",
|
'string',
|
||||||
"SOAP-ENV:Server"
|
'SOAP-ENV:Server'
|
||||||
),
|
),
|
||||||
CreateObject('phpgwapi.soapval',
|
CreateObject('phpgwapi.soapval',
|
||||||
"faultstring",
|
'faultstring',
|
||||||
"string",
|
'string',
|
||||||
"couldn't eval \"$this->eval_str\""
|
"couldn't eval \"$this->eval_str\""
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -16,6 +16,7 @@ make sure that my response is *actually* encoded correctly
|
|||||||
- get_all_headers() check for windows compatibility
|
- get_all_headers() check for windows compatibility
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
/* $Id$ */
|
||||||
|
|
||||||
// make errors handle properly in windows
|
// make errors handle properly in windows
|
||||||
error_reporting(2039);
|
error_reporting(2039);
|
||||||
@ -79,11 +80,11 @@ class soap_server
|
|||||||
{
|
{
|
||||||
global $HTTP_SERVER_VARS;
|
global $HTTP_SERVER_VARS;
|
||||||
|
|
||||||
$this->debug("entering parse_request() on ".date("H:i Y-m-d"));
|
$this->debug('entering parse_request() on '.date('H:i Y-m-d'));
|
||||||
$request_uri = $HTTP_SERVER_VARS["REQUEST_URI"];
|
$request_uri = $HTTP_SERVER_VARS['REQUEST_URI'];
|
||||||
$this->debug("request uri: $request_uri");
|
$this->debug("request uri: $request_uri");
|
||||||
// get headers
|
// get headers
|
||||||
if(function_exists("getallheaders"))
|
if(function_exists('getallheaders'))
|
||||||
{
|
{
|
||||||
$this->headers = getallheaders();
|
$this->headers = getallheaders();
|
||||||
while(list($k,$v) = @each($this->headers))
|
while(list($k,$v) = @each($this->headers))
|
||||||
@ -92,19 +93,19 @@ class soap_server
|
|||||||
$dump .= "$k: $v\r\n";
|
$dump .= "$k: $v\r\n";
|
||||||
}
|
}
|
||||||
// get SOAPAction header
|
// get SOAPAction header
|
||||||
if($this->headers["SOAPAction"])
|
if($this->headers['SOAPAction'])
|
||||||
{
|
{
|
||||||
$this->SOAPAction = str_replace('"','',$this->headers["SOAPAction"]);
|
$this->SOAPAction = str_replace('"','',$this->headers['SOAPAction']);
|
||||||
$this->service = $this->SOAPAction;
|
$this->service = $this->SOAPAction;
|
||||||
}
|
}
|
||||||
// get character encoding
|
// get character encoding
|
||||||
if(ereg("=",$this->headers["Content-Type"]))
|
if(ereg("=",$this->headers['Content-Type']))
|
||||||
{
|
{
|
||||||
$this->xml_encoding = str_replace("\"","",substr(strstr($this->headers["Content-Type"],"="),1));
|
$this->xml_encoding = str_replace("\"","",substr(strstr($this->headers["Content-Type"],"="),1));
|
||||||
}
|
}
|
||||||
elseif(ereg("^text/xml",$this->headers["Content-Type"]))
|
elseif(ereg("^text/xml",$this->headers['Content-Type']))
|
||||||
{
|
{
|
||||||
$this->xml_encoding = "us-ascii";
|
$this->xml_encoding = 'us-ascii';
|
||||||
}
|
}
|
||||||
$this->debug("got encoding: $this->xml_encoding");
|
$this->debug("got encoding: $this->xml_encoding");
|
||||||
}
|
}
|
||||||
@ -139,7 +140,7 @@ class soap_server
|
|||||||
{
|
{
|
||||||
// parser debug
|
// parser debug
|
||||||
$this->debug($parser->debug_str);
|
$this->debug($parser->debug_str);
|
||||||
$this->result = "fault: error in msg parsing or eval";
|
$this->result = 'fault: error in msg parsing or eval';
|
||||||
$this->make_fault("Server","error in msg parsing or eval:\n".$parser->get_response());
|
$this->make_fault("Server","error in msg parsing or eval:\n".$parser->get_response());
|
||||||
// return soapresp
|
// return soapresp
|
||||||
return $this->fault();
|
return $this->fault();
|
||||||
@ -148,7 +149,7 @@ class soap_server
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// get eval_str
|
// get eval_str
|
||||||
$this->debug("calling parser->get_response()");
|
$this->debug('calling parser->get_response()');
|
||||||
// evaluate it, getting back a soapval object
|
// evaluate it, getting back a soapval object
|
||||||
if(!$request_val = $parser->get_response())
|
if(!$request_val = $parser->get_response())
|
||||||
{
|
{
|
||||||
@ -156,7 +157,7 @@ class soap_server
|
|||||||
}
|
}
|
||||||
// parser debug
|
// parser debug
|
||||||
$this->debug($parser->debug_str);
|
$this->debug($parser->debug_str);
|
||||||
if(get_class($request_val) == "soapval")
|
if(get_class($request_val) == 'soapval')
|
||||||
{
|
{
|
||||||
if (is_object($obj))
|
if (is_object($obj))
|
||||||
{
|
{
|
||||||
@ -204,7 +205,7 @@ class soap_server
|
|||||||
{
|
{
|
||||||
$code .= "\$request_data[$x]" . ',';
|
$code .= "\$request_data[$x]" . ',';
|
||||||
}
|
}
|
||||||
$code = substr($code,0,-1) .");";
|
$code = substr($code,0,-1) .');';
|
||||||
if(eval($code))
|
if(eval($code))
|
||||||
{
|
{
|
||||||
if (is_object($obj))
|
if (is_object($obj))
|
||||||
@ -252,7 +253,7 @@ class soap_server
|
|||||||
{
|
{
|
||||||
$code .= "\$request_data[$x]" . ',';
|
$code .= "\$request_data[$x]" . ',';
|
||||||
}
|
}
|
||||||
$code = substr($code,0,-1) .");";
|
$code = substr($code,0,-1) .');';
|
||||||
$this->debug("about to call method '$obj->method'");
|
$this->debug("about to call method '$obj->method'");
|
||||||
eval($code);
|
eval($code);
|
||||||
}
|
}
|
||||||
@ -264,9 +265,9 @@ class soap_server
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* return fault */
|
/* return fault */
|
||||||
if(get_class($method_response) == "soapmsg")
|
if(get_class($method_response) == 'soapmsg')
|
||||||
{
|
{
|
||||||
if(eregi("fault",$method_response->value->name))
|
if(eregi('fault',$method_response->value->name))
|
||||||
{
|
{
|
||||||
$this->fault = True;
|
$this->fault = True;
|
||||||
}
|
}
|
||||||
@ -276,7 +277,7 @@ class soap_server
|
|||||||
{
|
{
|
||||||
/* return soapval object */
|
/* return soapval object */
|
||||||
|
|
||||||
if(get_class($method_response) == "soapval")
|
if(get_class($method_response) == 'soapval')
|
||||||
{
|
{
|
||||||
$return_val = $method_response;
|
$return_val = $method_response;
|
||||||
/* create soap_val object w/ return values from method, use method signature to determine type */
|
/* create soap_val object w/ return values from method, use method signature to determine type */
|
||||||
@ -287,13 +288,13 @@ class soap_server
|
|||||||
}
|
}
|
||||||
$this->debug($return_val->debug_str);
|
$this->debug($return_val->debug_str);
|
||||||
/* response object is a soap_msg object */
|
/* response object is a soap_msg object */
|
||||||
$return_msg = CreateObject('phpgwapi.soapmsg',$method."Response",array($return_val),$this->service);
|
$return_msg = CreateObject('phpgwapi.soapmsg',$method.'Response',array($return_val),$this->service);
|
||||||
}
|
}
|
||||||
if($this->debug_flag)
|
if($this->debug_flag)
|
||||||
{
|
{
|
||||||
$return_msg->debug_flag = true;
|
$return_msg->debug_flag = true;
|
||||||
}
|
}
|
||||||
$this->result = "successful";
|
$this->result = 'successful';
|
||||||
return $return_msg;
|
return $return_msg;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -311,7 +312,7 @@ class soap_server
|
|||||||
$this->debug("ERROR: parser did not return soapval object: $request_val ".get_class($request_val));
|
$this->debug("ERROR: parser did not return soapval object: $request_val ".get_class($request_val));
|
||||||
$this->result = "fault: parser did not return soapval object: $request_val";
|
$this->result = "fault: parser did not return soapval object: $request_val";
|
||||||
// return fault
|
// return fault
|
||||||
$this->make_fault("Server","parser did not return soapval object: $request_val");
|
$this->make_fault('Server',"parser did not return soapval object: $request_val");
|
||||||
return $this->fault();
|
return $this->fault();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -320,7 +321,7 @@ class soap_server
|
|||||||
function verify_method($request)
|
function verify_method($request)
|
||||||
{
|
{
|
||||||
//return true;
|
//return true;
|
||||||
$this->debug("entered verify_method() w/ request name: ".$request->name);
|
$this->debug('entered verify_method() w/ request name: '.$request->name);
|
||||||
$params = $request->value;
|
$params = $request->value;
|
||||||
// if there are input parameters required...
|
// if there are input parameters required...
|
||||||
if($sig = $this->dispatch_map[$this->methodname]["in"])
|
if($sig = $this->dispatch_map[$this->methodname]["in"])
|
||||||
@ -328,7 +329,7 @@ class soap_server
|
|||||||
$this->input_value = count($sig);
|
$this->input_value = count($sig);
|
||||||
if(is_array($params))
|
if(is_array($params))
|
||||||
{
|
{
|
||||||
$this->debug("entered verify_method() with ".count($params)." parameters");
|
$this->debug('entered verify_method() with '.count($params).' parameters');
|
||||||
@reset($params);
|
@reset($params);
|
||||||
while(list($null,$v) = @each($params))
|
while(list($null,$v) = @each($params))
|
||||||
/* foreach($params as $v) */
|
/* foreach($params as $v) */
|
||||||
@ -353,7 +354,7 @@ class soap_server
|
|||||||
if(strtolower($sig[$i]) != strtolower($p[$i]))
|
if(strtolower($sig[$i]) != strtolower($p[$i]))
|
||||||
{
|
{
|
||||||
$this->debug("mismatched parameter types: $sig[$i] != $p[$i]");
|
$this->debug("mismatched parameter types: $sig[$i] != $p[$i]");
|
||||||
$this->make_fault("Client","soap request contained mismatching parameters of name $v->name had type $p[$i], which did not match signature's type: $sig[$i]");
|
$this->make_fault('Client',"soap request contained mismatching parameters of name $v->name had type $p[$i], which did not match signature's type: $sig[$i]");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$this->debug("parameter type match: $sig[$i] = $p[$i]");
|
$this->debug("parameter type match: $sig[$i] = $p[$i]");
|
||||||
@ -363,8 +364,8 @@ class soap_server
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->debug("oops, wrong number of parameter!");
|
$this->debug('oops, wrong number of parameter!');
|
||||||
$this->make_fault("Client","soap request contained incorrect number of parameters. method '$this->methodname' required ".count($sig)." and request provided ".count($params));
|
$this->make_fault('Client',"soap request contained incorrect number of parameters. method '$this->methodname' required ".count($sig)." and request provided ".count($params));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// oops, no params...
|
// oops, no params...
|
||||||
@ -372,7 +373,7 @@ class soap_server
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->debug("oops, no parameters sent! Method '$this->methodname' requires ".count($sig)." input parameters!");
|
$this->debug("oops, no parameters sent! Method '$this->methodname' requires ".count($sig)." input parameters!");
|
||||||
$this->make_fault("Client","soap request contained incorrect number of parameters. method '$this->methodname' requires ".count($sig)." parameters, and request provided none");
|
$this->make_fault('Client',"soap request contained incorrect number of parameters. method '$this->methodname' requires ".count($sig)." parameters, and request provided none");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// no params
|
// no params
|
||||||
@ -393,9 +394,9 @@ class soap_server
|
|||||||
// get string return type from dispatch map
|
// get string return type from dispatch map
|
||||||
function get_return_type()
|
function get_return_type()
|
||||||
{
|
{
|
||||||
if(count($this->dispatch_map[$this->methodname]["out"]) >= 1)
|
if(count($this->dispatch_map[$this->methodname]['out']) >= 1)
|
||||||
{
|
{
|
||||||
$type = array_shift($this->dispatch_map[$this->methodname]["out"]);
|
$type = array_shift($this->dispatch_map[$this->methodname]['out']);
|
||||||
$this->debug("got return type from dispatch map: '$type'");
|
$this->debug("got return type from dispatch map: '$type'");
|
||||||
return $type;
|
return $type;
|
||||||
}
|
}
|
||||||
@ -414,22 +415,22 @@ class soap_server
|
|||||||
// add a method to the dispatch map
|
// add a method to the dispatch map
|
||||||
function add_to_map($methodname,$in,$out)
|
function add_to_map($methodname,$in,$out)
|
||||||
{
|
{
|
||||||
$this->dispatch_map[$methodname]["in"] = $in;
|
$this->dispatch_map[$methodname]['in'] = $in;
|
||||||
$this->dispatch_map[$methodname]["out"] = $out;
|
$this->dispatch_map[$methodname]['out'] = $out;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set up a fault
|
// set up a fault
|
||||||
function fault()
|
function fault()
|
||||||
{
|
{
|
||||||
return CreateObject('phpgwapi.soapmsg',
|
return CreateObject('phpgwapi.soapmsg',
|
||||||
"Fault",
|
'Fault',
|
||||||
array(
|
array(
|
||||||
"faultcode" => $this->fault_code,
|
'faultcode' => $this->fault_code,
|
||||||
"faultstring" => $this->fault_str,
|
'faultstring' => $this->fault_str,
|
||||||
"faultactor" => $this->fault_actor,
|
'faultactor' => $this->fault_actor,
|
||||||
"faultdetail" => $this->fault_detail.$this->debug_str
|
'faultdetail' => $this->fault_detail.$this->debug_str
|
||||||
),
|
),
|
||||||
"http://schemas.xmlsoap.org/soap/envelope/"
|
'http://schemas.xmlsoap.org/soap/envelope/'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/* soapx4 high level class
|
/* soapx4 high level class
|
||||||
|
|
||||||
usage:
|
usage:
|
||||||
@ -14,6 +13,7 @@ echo $soapclient->call( string methodname [ ,array parameters] );
|
|||||||
unset($soapclient);
|
unset($soapclient);
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
/* $Id$ */
|
||||||
|
|
||||||
class soapclient
|
class soapclient
|
||||||
{
|
{
|
||||||
@ -56,7 +56,7 @@ class soapclient
|
|||||||
// get soapAction
|
// get soapAction
|
||||||
if(!$soapAction)
|
if(!$soapAction)
|
||||||
{
|
{
|
||||||
if($this->endpointType != "wsdl")
|
if($this->endpointType != 'wsdl')
|
||||||
{
|
{
|
||||||
die("method call requires soapAction if wsdl is not available!");
|
die("method call requires soapAction if wsdl is not available!");
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ class soapclient
|
|||||||
// get namespace
|
// get namespace
|
||||||
if(!$namespace)
|
if(!$namespace)
|
||||||
{
|
{
|
||||||
if($this->endpointType != "wsdl")
|
if($this->endpointType != 'wsdl')
|
||||||
{
|
{
|
||||||
die("method call requires namespace if wsdl is not available!");
|
die("method call requires namespace if wsdl is not available!");
|
||||||
}
|
}
|
||||||
@ -89,7 +89,7 @@ class soapclient
|
|||||||
if($soap_client = CreateObject('phpgwapi.soap_client',$this->endpoint))
|
if($soap_client = CreateObject('phpgwapi.soap_client',$this->endpoint))
|
||||||
{
|
{
|
||||||
//$soap_client->debug_flag = true;
|
//$soap_client->debug_flag = true;
|
||||||
$this->debug($dbg."instantiated client successfully");
|
$this->debug($dbg.'instantiated client successfully');
|
||||||
$this->debug("client data:<br>server: $soap_client->server<br>path: $soap_client->path<br>port: $soap_client->port");
|
$this->debug("client data:<br>server: $soap_client->server<br>path: $soap_client->path<br>port: $soap_client->port");
|
||||||
// send
|
// send
|
||||||
$dbg = "sending msg w/ soapaction '$soapAction'...";
|
$dbg = "sending msg w/ soapaction '$soapAction'...";
|
||||||
@ -99,12 +99,12 @@ class soapclient
|
|||||||
$this->response = $soap_client->incoming_payload;
|
$this->response = $soap_client->incoming_payload;
|
||||||
$this->debug($dbg . "sent message successfully and got a '$return' back");
|
$this->debug($dbg . "sent message successfully and got a '$return' back");
|
||||||
// check for valid response
|
// check for valid response
|
||||||
if(get_class($return) == "soapval")
|
if(get_class($return) == 'soapval')
|
||||||
{
|
{
|
||||||
// fault?
|
// fault?
|
||||||
if(eregi("fault",$return->name))
|
if(eregi('fault',$return->name))
|
||||||
{
|
{
|
||||||
$this->debug("got fault");
|
$this->debug('got fault');
|
||||||
$faultArray = $return->decode();
|
$faultArray = $return->decode();
|
||||||
@reset($faultArray);
|
@reset($faultArray);
|
||||||
while(list($k,$v) = @each($faultArray))
|
while(list($k,$v) = @each($faultArray))
|
||||||
@ -136,7 +136,7 @@ class soapclient
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->debug("client send/recieve error");
|
$this->debug('client send/recieve error');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -146,7 +146,7 @@ class soapclient
|
|||||||
{
|
{
|
||||||
if($this->debug_flag)
|
if($this->debug_flag)
|
||||||
{
|
{
|
||||||
print $string."<br>";
|
print $string . '<br>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/* $Id$ */
|
||||||
|
|
||||||
// soap message class
|
// soap message class
|
||||||
class soapmsg
|
class soapmsg
|
||||||
{
|
{
|
||||||
@ -18,7 +20,7 @@ class soapmsg
|
|||||||
while(list($null,$v) = @each($new_namespaces))
|
while(list($null,$v) = @each($new_namespaces))
|
||||||
/* foreach($new_namespaces as $v) */
|
/* foreach($new_namespaces as $v) */
|
||||||
{
|
{
|
||||||
$namespaces[$v] = "ns".$i++;
|
$namespaces[$v] = 'ns' . $i++;
|
||||||
}
|
}
|
||||||
$this->namespaces = $namespaces;
|
$this->namespaces = $namespaces;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
/* $Id$ */
|
||||||
|
|
||||||
// soap value object
|
// soap value object
|
||||||
class soapval
|
class soapval
|
||||||
{
|
{
|
||||||
@ -14,20 +16,20 @@ class soapval
|
|||||||
{
|
{
|
||||||
if(ereg("[a-zA-Z0-9\-]*",key($v)))
|
if(ereg("[a-zA-Z0-9\-]*",key($v)))
|
||||||
{
|
{
|
||||||
$type = "struct";
|
$type = 'struct';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$type = "array";
|
$type = 'array';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif(is_int($v))
|
elseif(is_int($v))
|
||||||
{
|
{
|
||||||
$type = "int";
|
$type = 'int';
|
||||||
}
|
}
|
||||||
elseif(is_float($v) || $v == "NaN" || $v == "INF")
|
elseif(is_float($v) || $v == 'NaN' || $v == 'INF')
|
||||||
{
|
{
|
||||||
$type = "float";
|
$type = 'float';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -35,20 +37,20 @@ class soapval
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// php type name mangle
|
// php type name mangle
|
||||||
if($type == "integer")
|
if($type == 'integer')
|
||||||
{
|
{
|
||||||
$type = "int";
|
$type = 'int';
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->soapTypes = $soapTypes;
|
$this->soapTypes = $soapTypes;
|
||||||
$this->name = $name;
|
$this->name = $name;
|
||||||
$this->value = "";
|
$this->value = '';
|
||||||
$this->type = $type;
|
$this->type = $type;
|
||||||
$this->type_code = 0;
|
$this->type_code = 0;
|
||||||
$this->type_prefix = false;
|
$this->type_prefix = false;
|
||||||
$this->array_type = "";
|
$this->array_type = '';
|
||||||
$this->debug_flag = True;
|
$this->debug_flag = True;
|
||||||
$this->debug_str = "";
|
$this->debug_str = '';
|
||||||
$this->debug("Entering soapval - name: '$name' type: '$type'");
|
$this->debug("Entering soapval - name: '$name' type: '$type'");
|
||||||
|
|
||||||
if($namespace)
|
if($namespace)
|
||||||
@ -64,14 +66,14 @@ class soapval
|
|||||||
// get type prefix
|
// get type prefix
|
||||||
if(ereg(":",$type))
|
if(ereg(":",$type))
|
||||||
{
|
{
|
||||||
$this->type = substr(strrchr($type,":"),1,strlen(strrchr($type,":")));
|
$this->type = substr(strrchr($type,':'),1,strlen(strrchr($type,':')));
|
||||||
$this->type_prefix = substr($type,0,strpos($type,":"));
|
$this->type_prefix = substr($type,0,strpos($type,':'));
|
||||||
}
|
}
|
||||||
elseif($type_namespace)
|
elseif($type_namespace)
|
||||||
{
|
{
|
||||||
if(!isset($namespaces[$type_namespace]))
|
if(!isset($namespaces[$type_namespace]))
|
||||||
{
|
{
|
||||||
$namespaces[$type_namespace] = "ns".(count($namespaces)+1);
|
$namespaces[$type_namespace] = 'ns'.(count($namespaces)+1);
|
||||||
}
|
}
|
||||||
$this->type_prefix = $namespaces[$type_namespace];
|
$this->type_prefix = $namespaces[$type_namespace];
|
||||||
}
|
}
|
||||||
@ -147,7 +149,7 @@ class soapval
|
|||||||
{
|
{
|
||||||
$this->debug("checking value $k : $v");
|
$this->debug("checking value $k : $v");
|
||||||
// if soapval, add..
|
// if soapval, add..
|
||||||
if(get_class($v) == "soapval")
|
if(get_class($v) == 'soapval')
|
||||||
{
|
{
|
||||||
$this->value[] = $v;
|
$this->value[] = $v;
|
||||||
$this->debug($v->debug_str);
|
$this->debug($v->debug_str);
|
||||||
@ -159,11 +161,11 @@ class soapval
|
|||||||
{
|
{
|
||||||
if(ereg("[a-zA-Z\-]*",key($v)))
|
if(ereg("[a-zA-Z\-]*",key($v)))
|
||||||
{
|
{
|
||||||
$type = "struct";
|
$type = 'struct';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$type = "array";
|
$type = 'array';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif(!ereg("^[0-9]*$",$k) && in_array($k,array_keys($this->soapTypes)))
|
elseif(!ereg("^[0-9]*$",$k) && in_array($k,array_keys($this->soapTypes)))
|
||||||
@ -172,17 +174,17 @@ class soapval
|
|||||||
}
|
}
|
||||||
elseif(is_int($v))
|
elseif(is_int($v))
|
||||||
{
|
{
|
||||||
$type = "int";
|
$type = 'int';
|
||||||
}
|
}
|
||||||
elseif(is_float($v) || $v == "NaN" || $v == "INF")
|
elseif(is_float($v) || $v == 'NaN' || $v == 'INF')
|
||||||
{
|
{
|
||||||
$type = "float";
|
$type = 'float';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$type = gettype($v);
|
$type = gettype($v);
|
||||||
}
|
}
|
||||||
$new_val = CreateObject('phpgwapi.soapval',"item",$type,$v);
|
$new_val = CreateObject('phpgwapi.soapval','item',$type,$v);
|
||||||
$this->debug($new_val->debug_str);
|
$this->debug($new_val->debug_str);
|
||||||
$this->value[] = $new_val;
|
$this->value[] = $new_val;
|
||||||
}
|
}
|
||||||
@ -193,7 +195,7 @@ class soapval
|
|||||||
|
|
||||||
function addStruct($vals)
|
function addStruct($vals)
|
||||||
{
|
{
|
||||||
$this->debug("adding struct '$this->name' with ".count($vals)." vals");
|
$this->debug("adding struct '$this->name' with ".count($vals).' vals');
|
||||||
if(is_array($vals) && count($vals) >= 1)
|
if(is_array($vals) && count($vals) >= 1)
|
||||||
{
|
{
|
||||||
@reset($vals);
|
@reset($vals);
|
||||||
@ -201,7 +203,7 @@ class soapval
|
|||||||
/* foreach($vals as $k => $v) */
|
/* foreach($vals as $k => $v) */
|
||||||
{
|
{
|
||||||
// if serialize, if soapval
|
// if serialize, if soapval
|
||||||
if(get_class($v) == "soapval")
|
if(get_class($v) == 'soapval')
|
||||||
{
|
{
|
||||||
$this->value[] = $v;
|
$this->value[] = $v;
|
||||||
$this->debug($v->debug_str);
|
$this->debug($v->debug_str);
|
||||||
@ -217,11 +219,11 @@ class soapval
|
|||||||
{
|
{
|
||||||
if($a == "0")
|
if($a == "0")
|
||||||
{
|
{
|
||||||
$type = "array";
|
$type = 'array';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$type = "struct";
|
$type = 'struct';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -234,11 +236,11 @@ class soapval
|
|||||||
}
|
}
|
||||||
elseif(is_int($v))
|
elseif(is_int($v))
|
||||||
{
|
{
|
||||||
$type = "int";
|
$type = 'int';
|
||||||
}
|
}
|
||||||
elseif(is_float($v) || $v == "NaN" || $v == "INF")
|
elseif(is_float($v) || $v == "NaN" || $v == "INF")
|
||||||
{
|
{
|
||||||
$type = "float";
|
$type = 'float';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -266,16 +268,16 @@ class soapval
|
|||||||
$soapval = $this;
|
$soapval = $this;
|
||||||
}
|
}
|
||||||
$this->debug("serializing '$soapval->name' of type '$soapval->type'");
|
$this->debug("serializing '$soapval->name' of type '$soapval->type'");
|
||||||
if($soapval->name == "")
|
if($soapval->name == '')
|
||||||
{
|
{
|
||||||
$soapval->name = "return";
|
$soapval->name = 'return';
|
||||||
}
|
}
|
||||||
|
|
||||||
switch($soapval->type_code)
|
switch($soapval->type_code)
|
||||||
{
|
{
|
||||||
case 3:
|
case 3:
|
||||||
// struct
|
// struct
|
||||||
$this->debug("got a struct");
|
$this->debug('got a struct');
|
||||||
if($soapval->prefix && $soapval->type_prefix)
|
if($soapval->prefix && $soapval->type_prefix)
|
||||||
{
|
{
|
||||||
$xml .= "<$soapval->prefix:$soapval->name xsi:type=\"$soapval->type_prefix:$soapval->type\">\n";
|
$xml .= "<$soapval->prefix:$soapval->name xsi:type=\"$soapval->type_prefix:$soapval->type\">\n";
|
||||||
@ -321,7 +323,7 @@ class soapval
|
|||||||
}
|
}
|
||||||
if(count($array_types) > 1)
|
if(count($array_types) > 1)
|
||||||
{
|
{
|
||||||
$array_type = "xsd:ur-type";
|
$array_type = 'xsd:ur-type';
|
||||||
}
|
}
|
||||||
elseif(count($array_types) >= 1)
|
elseif(count($array_types) >= 1)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user