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