[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] CVS: phpgwapi/inc class.common.inc.php,1.123.2.9.2.8
From: |
Dave Hall <address@hidden> |
Subject: |
[Phpgroupware-cvs] CVS: phpgwapi/inc class.common.inc.php,1.123.2.9.2.8,1.123.2.9.2.9 class.soap_client.inc.php,1.6,1.6.4.1class.soap_parser.inc.php,1.5,1.5.4.1 class.soap_server.inc.php,1.10,1.10.4.1 class.soapclient.inc.php,1.7,1.7.4.1 class.soapmsg.inc.php,1.8,1.8.4.1 class.soapval.inc.php,1.8,1.8.4.1 class.wsdl.inc.php,1.3,1.3.4.1 soaplib.soapinterop.php,1.4,1.4.4.1 |
Date: |
Thu, 29 May 2003 22:34:28 -0400 |
Update of /cvsroot/phpgroupware/phpgwapi/inc
In directory subversions:/tmp/cvs-serv21085/inc
Modified Files:
Tag: Version-0_9_16-branch
class.common.inc.php class.soap_client.inc.php
class.soap_parser.inc.php class.soap_server.inc.php
class.soapclient.inc.php class.soapmsg.inc.php
class.soapval.inc.php class.wsdl.inc.php
soaplib.soapinterop.php
Log Message:
changed css in tpls and dos2unix the api
Index: class.common.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.common.inc.php,v
retrieving revision 1.123.2.9.2.8
retrieving revision 1.123.2.9.2.9
diff -C2 -r1.123.2.9.2.8 -r1.123.2.9.2.9
*** class.common.inc.php 17 May 2003 20:30:12 -0000 1.123.2.9.2.8
--- class.common.inc.php 30 May 2003 02:34:25 -0000 1.123.2.9.2.9
***************
*** 1087,1092 ****
function phpgw_footer()
{
- global $HTMLCOMPLIANT;
-
if (!isset($GLOBALS['phpgw_info']['flags']['nofooter'])
|| !$GLOBALS['phpgw_info']['flags']['nofooter'])
{
--- 1087,1090 ----
***************
*** 1102,1105 ****
--- 1100,1130 ----
}
+ function get_css()
+ {
+ $tpl = createObject('phpgwapi.Template',
$this->get_tpl_dir('phpgwapi'));
+ $tpl->set_file('css', 'css.tpl');
+ $tpl->set_var($GLOBALS['phpgw_info']['theme']);
+ $app_css = '';
+ if(@isset($GLOBALS['HTTP_GET_VARS']['menuaction']))
+ {
+ list($app,$class,$method) =
explode('.',$GLOBALS['HTTP_GET_VARS']['menuaction']);
+ if(is_array($GLOBALS[$class]->public_functions) &&
$GLOBALS[$class]->public_functions['css'])
+ {
+ $app_css .= $GLOBALS[$class]->css();
+ }
+ if(is_array($GLOBALS[$class]->public_functions) &&
$GLOBALS[$class]->public_functions['java_script'])
+ {
+ $java_script = $GLOBALS[$class]->java_script();
+ }
+ }
+ if (isset($GLOBALS['phpgw_info']['flags']['css']))
+ {
+ $app_css .= $GLOBALS['phpgw_info']['flags']['css'];
+ }
+ $tpl->set_var('app_css', $app_css);
+
+ return $tpl->subst('css');
+ }
+
function hex2bin($data)
{
Index: class.soap_client.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.soap_client.inc.php,v
retrieving revision 1.6
retrieving revision 1.6.4.1
diff -C2 -r1.6 -r1.6.4.1
*** class.soap_client.inc.php 18 Aug 2001 20:31:47 -0000 1.6
--- class.soap_client.inc.php 30 May 2003 02:34:26 -0000 1.6.4.1
***************
*** 1,225 ****
! <?php
! /*
!
! SOAPx4
! by Dietrich Ayala (C) 2001 address@hidden
!
! This project began based on code from the 2 projects below,
! and still contains some original code. The licenses of both must be
respected.
!
! XML-RPC for PHP
! originally by Edd Dumbill (C) 1999-2000
!
! SOAP for PHP
! by Victor Zou (C) 2000-2001 <address@hidden>
!
! */
!
! /* changelog:
! 2001-07-04
! - abstract type system to support either 1999 or 2001 schema (arg,
typing still needs much
! solidification.)
! - implemented proxy support, based on sample code from miles lott
<address@hidden>
! - much general cleanup of code & cleaned out what was left of original
xml-rpc/gigaideas code
! - implemented a transport argument into send() that allows you to
specify different transports
! (assuming you have implemented the function, and added it to the
conditional statement in send()
! - abstracted the determination of charset in Content-type header
! 2001-07-5
! - fixed more weird type/namespace issues
! */
!
! // $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)
! {
! $this->port = 80;
! $this->path = $path;
! $this->server = $server;
! $this->errno;
! $this->errstring;
! $this->debug_flag = True;
! $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,'/');
! $this->debug("path = $this->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,'/'));
! }
! else
! {
! $this->server =
substr($path,0,strpos($path,'/'));
! }
! }
! if($port)
! {
! $this->port = $port;
! }
! }
!
! function setCredentials($u, $p)
! {
! $this->username = $u;
! $this->password = $p;
! }
!
! function send($msg, $action, $timeout=0, $ssl=False)
! {
! // where msg is an soapmsg
! $msg->debug_flag = $this->debug_flag;
! $this->action = $action;
! if($ssl)
! {
! return $this->ssl_sendPayloadHTTP10(
! $msg,
! $this->server,
! $this->port,
! $timeout,
! $this->username,
! $this->password
! );
! }
! else
! {
! return $this->sendPayloadHTTP10(
! $msg,
! $this->server,
! $this->port,
! $timeout,
! $this->username,
! $this->password
! );
! }
! }
!
! function sendPayloadHTTP10($msg, $server, $port, $timeout=0,
$username='', $password='')
! {
! if($timeout > 0)
! {
! $fp = fsockopen($server, $port,&$this->errno,
&$this->errstr, $timeout);
! }
! else
! {
! $fp = fsockopen($server, $port,&$this->errno,
&$this->errstr);
! }
! if (!$fp)
! {
! $this->debug("Couldn't open socket connection
to server!");
! $this->debug("Server: $this->server");
! return 0;
! }
!
! // thanks to Grant Rauscher <address@hidden> for this
! $credentials = '';
! if ($username != '')
! {
! $credentials = "Authorization: Basic " .
base64_encode($username . ":" . $password) . "\r\n";
! }
!
! $soap_data = $msg->serialize();
! $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');
! }
!
! // get reponse
! while($data = fread($fp, 32768))
! {
! $incoming_payload .= $data;
! }
!
! fclose($fp);
! $this->incoming_payload = $incoming_payload;
! // $response is a soapmsg object
! $this->response =
$msg->parseResponse($incoming_payload);
! $this->debug($msg->debug_str);
! return $this->response;
! }
!
! function ssl_sendPayloadHTTP10($msg, $server, $port,
$timeout=0,$username='', $password='')
! {
! if(!function_exists(curl_init))
! {
! $this->errstr = 'No curl functions available -
use of ssl is invalid';
! return False;
! }
! /* curl Method borrowed from:
!
http://sourceforge.net/tracker/index.php?func=detail&aid=427359&group_id=23199&atid=377731
! */
!
! // thanks to Grant Rauscher <address@hidden>
! // for this
! $credentials = '';
! if ($username!='')
! {
! $credentials = "Authorization: Basic " .
base64_encode($username . ':' . $password) . "\r\n";
! }
!
! $soap_data = $msg->serialize();
! $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();
! curl_setopt($ch, CURLOPT_URL,$this->server);
! curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
! curl_setopt($ch, CURLOPT_CUSTOMREQUEST,
$this->outgoing_payload);
! curl_setopt($ch, CURLOPT_HEADER, 0);
! $incoming_payload = curl_exec($ch);
! curl_close($ch);
!
! $this->incoming_payload = $incoming_payload;
! // $response is a soapmsg object
! $this->response =
$msg->parseResponse($incoming_payload);
! $this->debug($msg->debug_str);
! return $this->response;
! }
!
! function debug($string)
! {
! if($this->debug_flag)
! {
! $this->debug_str .= "$string\n";
! }
! }
! } // end class soap_client
! ?>
--- 1,225 ----
! <?php
! /*
!
! SOAPx4
! by Dietrich Ayala (C) 2001 address@hidden
!
! This project began based on code from the 2 projects below,
! and still contains some original code. The licenses of both must be
respected.
!
! XML-RPC for PHP
! originally by Edd Dumbill (C) 1999-2000
!
! SOAP for PHP
! by Victor Zou (C) 2000-2001 <address@hidden>
!
! */
!
! /* changelog:
! 2001-07-04
! - abstract type system to support either 1999 or 2001 schema (arg,
typing still needs much
! solidification.)
! - implemented proxy support, based on sample code from miles lott
<address@hidden>
! - much general cleanup of code & cleaned out what was left of original
xml-rpc/gigaideas code
! - implemented a transport argument into send() that allows you to
specify different transports
! (assuming you have implemented the function, and added it to the
conditional statement in send()
! - abstracted the determination of charset in Content-type header
! 2001-07-5
! - fixed more weird type/namespace issues
! */
!
! // $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)
! {
! $this->port = 80;
! $this->path = $path;
! $this->server = $server;
! $this->errno;
! $this->errstring;
! $this->debug_flag = True;
! $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,'/');
! $this->debug("path = $this->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,'/'));
! }
! else
! {
! $this->server =
substr($path,0,strpos($path,'/'));
! }
! }
! if($port)
! {
! $this->port = $port;
! }
! }
!
! function setCredentials($u, $p)
! {
! $this->username = $u;
! $this->password = $p;
! }
!
! function send($msg, $action, $timeout=0, $ssl=False)
! {
! // where msg is an soapmsg
! $msg->debug_flag = $this->debug_flag;
! $this->action = $action;
! if($ssl)
! {
! return $this->ssl_sendPayloadHTTP10(
! $msg,
! $this->server,
! $this->port,
! $timeout,
! $this->username,
! $this->password
! );
! }
! else
! {
! return $this->sendPayloadHTTP10(
! $msg,
! $this->server,
! $this->port,
! $timeout,
! $this->username,
! $this->password
! );
! }
! }
!
! function sendPayloadHTTP10($msg, $server, $port, $timeout=0,
$username='', $password='')
! {
! if($timeout > 0)
! {
! $fp = fsockopen($server, $port,&$this->errno,
&$this->errstr, $timeout);
! }
! else
! {
! $fp = fsockopen($server, $port,&$this->errno,
&$this->errstr);
! }
! if (!$fp)
! {
! $this->debug("Couldn't open socket connection
to server!");
! $this->debug("Server: $this->server");
! return 0;
! }
!
! // thanks to Grant Rauscher <address@hidden> for this
! $credentials = '';
! if ($username != '')
! {
! $credentials = "Authorization: Basic " .
base64_encode($username . ":" . $password) . "\r\n";
! }
!
! $soap_data = $msg->serialize();
! $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');
! }
!
! // get reponse
! while($data = fread($fp, 32768))
! {
! $incoming_payload .= $data;
! }
!
! fclose($fp);
! $this->incoming_payload = $incoming_payload;
! // $response is a soapmsg object
! $this->response =
$msg->parseResponse($incoming_payload);
! $this->debug($msg->debug_str);
! return $this->response;
! }
!
! function ssl_sendPayloadHTTP10($msg, $server, $port,
$timeout=0,$username='', $password='')
! {
! if(!function_exists(curl_init))
! {
! $this->errstr = 'No curl functions available -
use of ssl is invalid';
! return False;
! }
! /* curl Method borrowed from:
!
http://sourceforge.net/tracker/index.php?func=detail&aid=427359&group_id=23199&atid=377731
! */
!
! // thanks to Grant Rauscher <address@hidden>
! // for this
! $credentials = '';
! if ($username!='')
! {
! $credentials = "Authorization: Basic " .
base64_encode($username . ':' . $password) . "\r\n";
! }
!
! $soap_data = $msg->serialize();
! $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();
! curl_setopt($ch, CURLOPT_URL,$this->server);
! curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
! curl_setopt($ch, CURLOPT_CUSTOMREQUEST,
$this->outgoing_payload);
! curl_setopt($ch, CURLOPT_HEADER, 0);
! $incoming_payload = curl_exec($ch);
! curl_close($ch);
!
! $this->incoming_payload = $incoming_payload;
! // $response is a soapmsg object
! $this->response =
$msg->parseResponse($incoming_payload);
! $this->debug($msg->debug_str);
! return $this->response;
! }
!
! function debug($string)
! {
! if($this->debug_flag)
! {
! $this->debug_str .= "$string\n";
! }
! }
! } // end class soap_client
! ?>
Index: class.soap_parser.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.soap_parser.inc.php,v
retrieving revision 1.5
retrieving revision 1.5.4.1
diff -C2 -r1.5 -r1.5.4.1
*** class.soap_parser.inc.php 18 Aug 2001 14:37:52 -0000 1.5
--- class.soap_parser.inc.php 30 May 2003 02:34:26 -0000 1.5.4.1
***************
*** 1,375 ****
! <?php
! /* $Id$ */
!
! class soap_parser
! {
! function soap_parser($xml='',$encoding='UTF-8')
! {
! global $soapTypes;
!
! $this->soapTypes = $soapTypes;
! $this->xml = $xml;
! $this->xml_encoding = $encoding;
! $this->root_struct = "";
! // options: envelope,header,body,method
! // determines where in the message we are
(envelope,header,body,method)
! $this->status = '';
! $this->position = 0;
! $this->pos_stat = 0;
! $this->depth = 0;
! $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->depth_array = array();
! $this->debug_flag = True;
! $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("DATA DUMP:\n\n$xml");
! // Create an XML parser.
! $this->parser =
xml_parser_create($this->xml_encoding);
! // Set the options for parsing the XML data.
! //xml_parser_set_option($parser,
XML_OPTION_SKIP_WHITE, 1);
! xml_parser_set_option($this->parser,
XML_OPTION_CASE_FOLDING, 0);
! // 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');
!
! // Parse the XML file.
! if(!xml_parse($this->parser,$xml,true))
! {
! // Display an error message.
! $this->debug(sprintf("XML error on line
%d: %s",
!
xml_get_current_line_number($this->parser),
!
xml_error_string(xml_get_error_code($this->parser))));
! $this->fault = true;
! }
! else
! {
! // get final eval string
! $this->eval_str = "\$response =
".trim($this->build_eval($this->root_struct)).";";
! }
! xml_parser_free($this->parser);
! }
! else
! {
! $this->debug("xml was empty, didn't parse!");
! }
! }
!
! // loop through msg, building eval_str
! function build_eval($pos)
! {
! $this->debug("inside build_eval() for $pos:
".$this->message[$pos]["name"]);
! $eval_str = $this->message[$pos]['eval_str'];
! // loop through children, building...
! 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');
! @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'] != '')
! {
! $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'];
! return $eval_str;
! }
!
! // start-element handler
! function start_element($parser, $name, $attrs)
! {
! // position in a total number of elements, starting
from 0
! // update class level pos
! $pos = $this->position++;
! // and set mine
! $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++;
!
! // else add self as child to whoever the current parent
is
! if($pos != 0)
! {
! $this->message[$this->parent]['children'] .=
"|$pos";
! }
! // set my 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
! $this->parent = $pos;
!
! // set status
! if(ereg(":Envelope$",$name))
! {
! $this->status = 'envelope';
! }
! elseif(ereg(":Header$",$name))
! {
! $this->status = 'header';
! }
! elseif(ereg(":Body$",$name))
! {
! $this->status = 'body';
! // set method
! }
! elseif($this->status == 'body')
! {
! $this->status = 'method';
! if(ereg(':',$name))
! {
! $this->root_struct_name =
substr(strrchr($name,':'),1);
! }
! else
! {
! $this->root_struct_name = $name;
! }
! $this->root_struct = $pos;
! $this->message[$pos]['type'] = 'struct';
! }
! // set my status
! $this->message[$pos]['status'] = $this->status;
!
! // set name
! $this->message[$pos]['name'] = htmlspecialchars($name);
! // set attrs
! $this->message[$pos]['attrs'] = $attrs;
! // get namespace
! if(ereg(":",$name))
! {
! $namespace = substr($name,0,strpos($name,':'));
! $this->message[$pos]['namespace'] = $namespace;
! $this->default_namespace = $namespace;
! }
! else
! {
! $this->message[$pos]['namespace'] =
$this->default_namespace;
! }
! // loop through atts, logging ns and type declarations
! @reset($attrs);
! while (list($key,$value) = @each($attrs))
! /* foreach($attrs as $key => $value) */
! {
! // if ns declarations, add to class level array
of valid namespaces
! if(ereg('xmlns:',$key))
! {
!
$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')
! {
! // then get attname and set $type
! $type = substr(strrchr($value,':'),1);
! }
! }
!
! // set type if available
! if($type)
! {
! $this->message[$pos]['type'] = $type;
! }
!
! // debug
! //$this->debug("parsed $name start, eval =
'".$this->message[$pos]["eval_str"]."'");
! }
!
! // end-element handler
! function end_element($parser, $name)
! {
! // position of current element is equal to the last
value left in depth_array for my depth
! $pos = $this->depth_array[$this->depth];
! // bring depth down a notch
! $this->depth--;
!
! // get type if not set already
! if($this->message[$pos]['type'] == '')
! {
! // if($this->message[$pos]['cdata'] == '' &&
$this->message[$pos]['children'] != '')
! if($this->message[$pos]['children'] != '')
! {
! $this->message[$pos]['type'] =
'SOAPStruct';
! }
! else
! {
! $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';
! /*
! if($this->message[$pos]["name"] ==
$this->root_struct_name){
! $this->message[$pos]["end_eval_str"] .=
" ,\"$this->methodNamespace\"";
! }
! */
! if($this->message[$pos]['children'] != '')
! {
! $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'] == '')
! {
! // add cdata w/ no quotes if only int/float/dbl
! if($this->message[$pos]['type'] == 'string')
! {
! $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')
! {
! //$this->debug("adding cdata w/o
quotes");
! $this->message[$pos]['eval_str'] .= ',
'.trim($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']."\"";
! }
! }
! // if in the process of making a soap_val, close the
parentheses and move on...
! if($this->message[$pos]['inval'] == 'true')
! {
! $this->message[$pos]['inval'] == 'false';
! }
! // if tag we are currently closing is the method wrapper
! if($pos == $this->root_struct)
! {
! $this->status = 'body';
! }
! elseif(ereg(':Body',$name))
! {
! $this->status = 'header';
! }
! elseif(ereg(':Header',$name))
! {
! $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']);
! }
!
! // element content handler
! function character_data($parser, $data)
! {
! $pos = $this->depth_array[$this->depth];
! $this->message[$pos]['cdata'] .= $data;
! //$this->debug("parsed ".$this->message[$pos]["name"]."
cdata, eval = '$this->eval_str'");
! }
!
! // default handler
! function default_handler($parser, $data)
! {
! //$this->debug("DEFAULT HANDLER: $data");
! }
!
! // function to get fault code
! function fault()
! {
! if($this->fault)
! {
! return true;
! }
! else
! {
! return false;
! }
! }
!
! // have this return a soap_val object
! function get_response()
! {
! $this->debug("eval()ing eval_str: $this->eval_str");
! @eval("$this->eval_str");
! if($response)
! {
! $this->debug("successfully eval'd msg");
! return $response;
! }
! else
! {
! $this->debug('ERROR: did not successfully eval
the msg');
! $this->fault = true;
! return CreateObject('phpgwapi.soapval',
! 'Fault',
! 'struct',
! array(
! CreateObject('phpgwapi.soapval',
! 'faultcode',
! 'string',
! 'SOAP-ENV:Server'
! ),
! CreateObject('phpgwapi.soapval',
! 'faultstring',
! 'string',
! "couldn't eval
\"$this->eval_str\""
! )
! )
! );
! }
! }
!
! function debug($string)
! {
! if($this->debug_flag)
! {
! $this->debug_str .= "$string\n";
! }
! }
!
! function decode_entities($text)
! {
! @reset($this->entities);
! while(list($entity,$encoded) = @each($this->entities))
! /* foreach($this->entities as $entity => $encoded) */
! {
! $text = str_replace($encoded,$entity,$text);
! }
! return $text;
! }
! }
! ?>
--- 1,375 ----
! <?php
! /* $Id$ */
!
! class soap_parser
! {
! function soap_parser($xml='',$encoding='UTF-8')
! {
! global $soapTypes;
!
! $this->soapTypes = $soapTypes;
! $this->xml = $xml;
! $this->xml_encoding = $encoding;
! $this->root_struct = "";
! // options: envelope,header,body,method
! // determines where in the message we are
(envelope,header,body,method)
! $this->status = '';
! $this->position = 0;
! $this->pos_stat = 0;
! $this->depth = 0;
! $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->depth_array = array();
! $this->debug_flag = True;
! $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("DATA DUMP:\n\n$xml");
! // Create an XML parser.
! $this->parser =
xml_parser_create($this->xml_encoding);
! // Set the options for parsing the XML data.
! //xml_parser_set_option($parser,
XML_OPTION_SKIP_WHITE, 1);
! xml_parser_set_option($this->parser,
XML_OPTION_CASE_FOLDING, 0);
! // 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');
!
! // Parse the XML file.
! if(!xml_parse($this->parser,$xml,true))
! {
! // Display an error message.
! $this->debug(sprintf("XML error on line
%d: %s",
!
xml_get_current_line_number($this->parser),
!
xml_error_string(xml_get_error_code($this->parser))));
! $this->fault = true;
! }
! else
! {
! // get final eval string
! $this->eval_str = "\$response =
".trim($this->build_eval($this->root_struct)).";";
! }
! xml_parser_free($this->parser);
! }
! else
! {
! $this->debug("xml was empty, didn't parse!");
! }
! }
!
! // loop through msg, building eval_str
! function build_eval($pos)
! {
! $this->debug("inside build_eval() for $pos:
".$this->message[$pos]["name"]);
! $eval_str = $this->message[$pos]['eval_str'];
! // loop through children, building...
! 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');
! @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'] != '')
! {
! $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'];
! return $eval_str;
! }
!
! // start-element handler
! function start_element($parser, $name, $attrs)
! {
! // position in a total number of elements, starting
from 0
! // update class level pos
! $pos = $this->position++;
! // and set mine
! $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++;
!
! // else add self as child to whoever the current parent
is
! if($pos != 0)
! {
! $this->message[$this->parent]['children'] .=
"|$pos";
! }
! // set my 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
! $this->parent = $pos;
!
! // set status
! if(ereg(":Envelope$",$name))
! {
! $this->status = 'envelope';
! }
! elseif(ereg(":Header$",$name))
! {
! $this->status = 'header';
! }
! elseif(ereg(":Body$",$name))
! {
! $this->status = 'body';
! // set method
! }
! elseif($this->status == 'body')
! {
! $this->status = 'method';
! if(ereg(':',$name))
! {
! $this->root_struct_name =
substr(strrchr($name,':'),1);
! }
! else
! {
! $this->root_struct_name = $name;
! }
! $this->root_struct = $pos;
! $this->message[$pos]['type'] = 'struct';
! }
! // set my status
! $this->message[$pos]['status'] = $this->status;
!
! // set name
! $this->message[$pos]['name'] = htmlspecialchars($name);
! // set attrs
! $this->message[$pos]['attrs'] = $attrs;
! // get namespace
! if(ereg(":",$name))
! {
! $namespace = substr($name,0,strpos($name,':'));
! $this->message[$pos]['namespace'] = $namespace;
! $this->default_namespace = $namespace;
! }
! else
! {
! $this->message[$pos]['namespace'] =
$this->default_namespace;
! }
! // loop through atts, logging ns and type declarations
! @reset($attrs);
! while (list($key,$value) = @each($attrs))
! /* foreach($attrs as $key => $value) */
! {
! // if ns declarations, add to class level array
of valid namespaces
! if(ereg('xmlns:',$key))
! {
!
$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')
! {
! // then get attname and set $type
! $type = substr(strrchr($value,':'),1);
! }
! }
!
! // set type if available
! if($type)
! {
! $this->message[$pos]['type'] = $type;
! }
!
! // debug
! //$this->debug("parsed $name start, eval =
'".$this->message[$pos]["eval_str"]."'");
! }
!
! // end-element handler
! function end_element($parser, $name)
! {
! // position of current element is equal to the last
value left in depth_array for my depth
! $pos = $this->depth_array[$this->depth];
! // bring depth down a notch
! $this->depth--;
!
! // get type if not set already
! if($this->message[$pos]['type'] == '')
! {
! // if($this->message[$pos]['cdata'] == '' &&
$this->message[$pos]['children'] != '')
! if($this->message[$pos]['children'] != '')
! {
! $this->message[$pos]['type'] =
'SOAPStruct';
! }
! else
! {
! $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';
! /*
! if($this->message[$pos]["name"] ==
$this->root_struct_name){
! $this->message[$pos]["end_eval_str"] .=
" ,\"$this->methodNamespace\"";
! }
! */
! if($this->message[$pos]['children'] != '')
! {
! $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'] == '')
! {
! // add cdata w/ no quotes if only int/float/dbl
! if($this->message[$pos]['type'] == 'string')
! {
! $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')
! {
! //$this->debug("adding cdata w/o
quotes");
! $this->message[$pos]['eval_str'] .= ',
'.trim($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']."\"";
! }
! }
! // if in the process of making a soap_val, close the
parentheses and move on...
! if($this->message[$pos]['inval'] == 'true')
! {
! $this->message[$pos]['inval'] == 'false';
! }
! // if tag we are currently closing is the method wrapper
! if($pos == $this->root_struct)
! {
! $this->status = 'body';
! }
! elseif(ereg(':Body',$name))
! {
! $this->status = 'header';
! }
! elseif(ereg(':Header',$name))
! {
! $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']);
! }
!
! // element content handler
! function character_data($parser, $data)
! {
! $pos = $this->depth_array[$this->depth];
! $this->message[$pos]['cdata'] .= $data;
! //$this->debug("parsed ".$this->message[$pos]["name"]."
cdata, eval = '$this->eval_str'");
! }
!
! // default handler
! function default_handler($parser, $data)
! {
! //$this->debug("DEFAULT HANDLER: $data");
! }
!
! // function to get fault code
! function fault()
! {
! if($this->fault)
! {
! return true;
! }
! else
! {
! return false;
! }
! }
!
! // have this return a soap_val object
! function get_response()
! {
! $this->debug("eval()ing eval_str: $this->eval_str");
! @eval("$this->eval_str");
! if($response)
! {
! $this->debug("successfully eval'd msg");
! return $response;
! }
! else
! {
! $this->debug('ERROR: did not successfully eval
the msg');
! $this->fault = true;
! return CreateObject('phpgwapi.soapval',
! 'Fault',
! 'struct',
! array(
! CreateObject('phpgwapi.soapval',
! 'faultcode',
! 'string',
! 'SOAP-ENV:Server'
! ),
! CreateObject('phpgwapi.soapval',
! 'faultstring',
! 'string',
! "couldn't eval
\"$this->eval_str\""
! )
! )
! );
! }
! }
!
! function debug($string)
! {
! if($this->debug_flag)
! {
! $this->debug_str .= "$string\n";
! }
! }
!
! function decode_entities($text)
! {
! @reset($this->entities);
! while(list($entity,$encoded) = @each($this->entities))
! /* foreach($this->entities as $entity => $encoded) */
! {
! $text = str_replace($encoded,$entity,$text);
! }
! return $text;
! }
! }
! ?>
Index: class.soap_server.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.soap_server.inc.php,v
retrieving revision 1.10
retrieving revision 1.10.4.1
diff -C2 -r1.10 -r1.10.4.1
*** class.soap_server.inc.php 10 Dec 2001 02:09:17 -0000 1.10
--- class.soap_server.inc.php 30 May 2003 02:34:26 -0000 1.10.4.1
***************
*** 1,444 ****
! <?php
! // SOAP server class
!
! // for example usage, see the test_server.php file.
!
! class soap_server
! {
! function soap_server($data='',$serviceNow=False)
! {
! // create empty dispatch map
! $this->dispatch_map = array();
! $this->debug_flag = True;
! $this->debug_str = '';
! $this->headers = '';
! $this->request = '';
! $this->result = 'successful';
! $this->fault = false;
! $this->fault_code = '';
! $this->fault_str = '';
! $this->fault_actor = '';
!
! if($serviceNow == 1)
! {
! $this->service($data);
! }
! }
!
! // parses request and posts response
! function service($data)
! {
! // $response is a soap_msg object
! $response = $this->parseRequest($data);
! $this->debug("parsed request and got an object of this
class '".get_class($response)."'");
! $this->debug("server sending...");
! // pass along the debug string
! if($this->debug_flag)
! {
! $response->debug($this->debug_str);
! }
! $payload = $response->serialize();
! // print headers
! if($this->fault)
! {
! $header[] = "HTTP/1.0 500 Internal Server
Error\r\n";
! }
! else
! {
! $header[] = "HTTP/1.0 200 OK\r\n";
! $header[] = "Status: 200\r\n";
! }
! $header[] = "Server: SOAPx4 Server v0.344359s\r\n";
! $header[] = "Connection: Close\r\n";
! $header[] = "Content-Type: text/xml; charset=UTF-8\r\n";
! $header[] = "Content-Length:
".strlen($payload)."\r\n\r\n";
! reset($header);
! foreach($header as $hdr)
! {
! header($hdr);
! }
! print $payload;
! }
!
! function parseRequest($data="")
! {
! global $HTTP_SERVER_VARS;
!
! $this->debug("entering parseRequest() on ".date("H:i
Y-m-d"));
! $request_uri = $HTTP_SERVER_VARS["REQUEST_URI"];
! $this->debug("request uri: $request_uri");
! // get headers
! $headers_array = getallheaders();
! foreach($headers_array as $k=>$v)
! {
! $dump .= "$k: $v\r\n";
! }
! $dump .= "\r\n\r\n".$data;
! $this->headers = $headers_array;
! $this->request = $dump;
!
! // get SOAPAction header -> methodname
! if($headers_array["SOAPAction"])
! {
! $action =
str_replace('"','',$headers_array["SOAPAction"]);
! if(ereg("^urn:",$action))
! {
! $this->service = substr($action,4);
! }
! elseif(ereg(".php",$action))
! {
! $this->service =
ereg_replace('"|/','',substr(strrchr($action,".php"),4,strlen(strrchr($action,"/"))));
! }
! $this->debug("got service: $this->service");
! }
! else
! {
! // throw a fault if no soapaction
! $this->debug("ERROR: no SOAPAction header
found");
! }
! // NOTE:::: throw a fault for no/bad soapaction here?
!
! // parse response, get soap parser obj
! $parser = CreateObject('phpgwapi.soap_parser',$data);
! // get/set methodname
! $this->methodname = $parser->root_struct_name;
! $this->debug("method name: $this->methodname");
!
! // does method exist?
! $test = ereg_replace("\.",'_',$this->methodname);
! if(function_exists($test))
! {
! $method = $this->methodname = $test;
! $this->debug("method '$this->methodname'
exists");
! }
! else
! {
! /* phpgroupware customization - createobject
based on methodname */
! list($app,$class,$method) =
explode('.',$this->methodname);
! if(ereg("^service",$app))
! {
! $args = $class;
! $class = 'service';
! $app = 'phpgwapi';
! $obj =
CreateObject(sprintf('%s.%s',$app,$class),$args);
! unset($args);
! }
! else
! {
! $obj =
CreateObject(sprintf('%s.%s',$app,$class));
! }
! $this->debug('app: ' . $app . ', class: ' .
$class . ', method: ' . $method);
! /*
! // "method not found" fault here
! $this->debug("method '$obj->method' not
found!");
! $this->result = "fault: method not found";
! $this->make_fault("Server","method
'$obj->method' not defined in service '$this->service'");
! return $this->fault();
! */
! }
!
! // if fault occurred during message parsing
! if($parser->fault())
! {
! // parser debug
! $this->debug($parser->debug_str);
! $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();
! // else successfully parsed request into
soapval object
! }
! else
! {
! // get eval_str
! $this->debug("calling parser->get_response()");
! // evaluate it, getting back a soapval object
! if(!$request_val = $parser->get_response())
! {
! return $this->fault();
! }
! // parser debug
! $this->debug($parser->debug_str);
! if(get_class($request_val) == "soapval")
! {
! if (is_object($obj))
! {
! /* Add the function to the
server map */
! $in = "array('" .
implode("','",$obj->soap_functions[$method]['in']) . "')";
! $out = "array('" .
implode("','",$obj->soap_functions[$method]['out']) . "')";
! $evalmap =
"\$this->add_to_map(\$this->methodname,$in,$out);";
! eval($evalmap);
! }
! /* verify that soapval objects in
request match the methods signature */
! if($this->verify_method($request_val))
! {
! $this->debug("request data -
name: $request_val->name, type: $request_val->type, value:
$request_val->value");
! if($this->input_value)
! {
! /* decode the soapval
object, and pass resulting values to the requested method */
! if(!$request_data =
$request_val->decode())
! {
!
$this->make_fault("Server","Unable to decode response from soapval object into
native php type.");
! return
$this->fault();
! }
! $this->debug("request
data: $request_data");
! }
!
! /* if there are return values */
! if($this->return_type =
$this->get_return_type())
! {
! $this->debug("got
return type: '$this->return_type'");
! /* if there are
parameters to pass */
! if($request_data)
! {
! if
(is_object($obj))
! {
! $code =
"\$method_response = call_user_method($method,$obj,";
!
$this->debug("about to call object method '$class\-\>$method' with args");
! }
! else
! {
! $code =
'$method_response = ' . $this->methodname . "('";
! $args =
implode("','",$request_data['return']);
!
$this->debug("about to call method '$this->methodname' with args: $args");
! }
! /* call method
with parameters */
! $code .=
implode("','",$request_data['return']);
! /*
!
while(list($x,$y) = each($request_data))
! {
! $code
.= "\$request_data[$x]" . ',';
! }
! $code =
substr($code,0,-1) .");";
! */
! $code .= "');";
!
$this->debug('CODE: ' . $code);
! if(eval($code))
! {
! if
(is_object($obj))
! {
!
$this->make_fault("Server","Object method call failed for '$class\-\>$method'
with params: ".join(',',$request_data));
! }
! else
! {
!
$this->make_fault("Server","Method call failed for '$this->methodname' with
params: ".join(',',$request_data));
! }
! return
$this->fault();
! }
!
$this->debug('Response: ' . $method_response);
! //
_debug_array($method_response);
! }
! else
! {
! /* call method
w/ no parameters */
! if
(is_object($obj))
! {
!
$this->debug("about to call object method '$obj\-\>$method'");
!
if(!$method_response = call_user_method($method,$obj))
! {
!
$this->make_fault("Server","Method call failed for '$obj->method' with no
params");
!
return $this->fault();
! }
! }
! else
! {
!
$this->debug("about to call method '$this->methodname'");
!
if(!$method_response = call_user_func($this->methodname))
! {
!
$this->make_fault("Server","Method call failed for '$this->methodname' with no
params");
!
return $this->fault();
! }
! }
! }
! /* no return values */
! }
! else
! {
! if($request_data)
! {
! /* call method
with parameters */
! $code =
"\$method_response = call_user_method(\$method,\$obj,";
!
while(list($x,$y) = each($request_data))
! {
! $code
.= "\$request_data[$x]" . ',';
! }
! $code =
substr($code,0,-1) .");";
!
$this->debug("about to call object method '$obj\-\>$method'");
! eval($code);
! }
! else
! {
! /* call method
w/ no parameters */
!
if(is_object($obj))
! {
!
$this->debug("about to call object method '$obj\-\>$method'");
!
call_user_method($method,$obj);
! }
! else
! {
!
$this->debug("about to call method '$method'");
!
call_user_func($method);
! }
! }
! }
!
! /* create soap_val object w/
return values from method, use method signature to determine type */
! if(get_class($method_response)
!= 'soapval')
! {
! $return_val =
CreateObject('phpgwapi.soapval',$method,$this->return_type,$method_response);
! }
! else
! {
! $return_val =
$method_response;
! }
!
$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);
! if($this->debug_flag)
! {
! $return_msg->debug_flag
= true;
! }
! $this->result = "successful";
! return $return_msg;
! }
! else
! {
! // debug
! $this->debug("ERROR: request
not verified against method signature");
! $this->result = "fault: request
failed validation against method signature";
! // return soapresp
! return $this->fault();
! }
! }
! else
! {
! // debug
! $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");
! return $this->fault();
! }
! }
! }
!
! function verify_method($request)
! {
! //return true;
! $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"])
! {
! $this->input_value = count($sig);
! if(is_array($params))
! {
! $this->debug("entered verify_method()
with ".count($params)." parameters");
! foreach($params as $v)
! {
! $this->debug("param '$v->name'
of type '$v->type'");
! }
! // validate the number of parameters
! if(count($params) == count($sig))
! {
! $this->debug("got correct
number of parameters: ".count($sig));
! // make array of param types
! foreach($params as $param)
! {
! $p[] =
strtolower($param->type);
! }
! // validate each param's type
! for($i=0; $i < count($p); $i++)
! {
! // type not match
! 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]");
! return false;
! }
! $this->debug("parameter
type match: $sig[$i] = $p[$i]");
! }
! return true;
! // oops, wrong number of paramss
! }
! 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));
! return false;
! }
! // oops, no params...
! }
! 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");
! return false;
! }
! // no params
! }
! elseif( (count($params)==0) && (count($sig) <= 1) )
! {
! $this->input_values = 0;
! return true;
! }
! else
! {
! //$this->debug("well, request passed parameters
to a method that requires none?");
! //$this->make_fault("Client","method
'$this->methodname' requires no parameters. The request passed in
".count($params).": "address@hidden(" param: ",$params) );
! return true;
! }
! }
!
! // get string return type from dispatch map
! function get_return_type()
! {
! if(count($this->dispatch_map[$this->methodname]["out"])
>= 1)
! {
! $type =
array_shift($this->dispatch_map[$this->methodname]["out"]);
! $this->debug("got return type from dispatch
map: '$type'");
! return $type;
! }
! return false;
! }
!
! // dbg
! function debug($string)
! {
! if($this->debug_flag)
! {
! $this->debug_str .= "$string\n";
! }
! }
!
! // 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;
! }
!
! // set up a fault
! function fault()
! {
! return CreateObject('phpgwapi.soapmsg',
! "Fault",
! array(
! "faultcode" => $this->fault_code,
! "faultstring" => $this->fault_str,
! "faultactor" => $this->fault_actor,
! "faultdetail" =>
$this->fault_detail.$this->debug_str
! ),
! "http://schemas.xmlphpgwapi.org/soap/envelope/"
! );
! }
!
! function make_fault($fault_code,$fault_string)
! {
! $this->fault_code = $fault_code;
! $this->fault_str = $fault_string;
! $this->fault = true;
! }
! }
! ?>
--- 1,444 ----
! <?php
! // SOAP server class
!
! // for example usage, see the test_server.php file.
!
! class soap_server
! {
! function soap_server($data='',$serviceNow=False)
! {
! // create empty dispatch map
! $this->dispatch_map = array();
! $this->debug_flag = True;
! $this->debug_str = '';
! $this->headers = '';
! $this->request = '';
! $this->result = 'successful';
! $this->fault = false;
! $this->fault_code = '';
! $this->fault_str = '';
! $this->fault_actor = '';
!
! if($serviceNow == 1)
! {
! $this->service($data);
! }
! }
!
! // parses request and posts response
! function service($data)
! {
! // $response is a soap_msg object
! $response = $this->parseRequest($data);
! $this->debug("parsed request and got an object of this
class '".get_class($response)."'");
! $this->debug("server sending...");
! // pass along the debug string
! if($this->debug_flag)
! {
! $response->debug($this->debug_str);
! }
! $payload = $response->serialize();
! // print headers
! if($this->fault)
! {
! $header[] = "HTTP/1.0 500 Internal Server
Error\r\n";
! }
! else
! {
! $header[] = "HTTP/1.0 200 OK\r\n";
! $header[] = "Status: 200\r\n";
! }
! $header[] = "Server: SOAPx4 Server v0.344359s\r\n";
! $header[] = "Connection: Close\r\n";
! $header[] = "Content-Type: text/xml; charset=UTF-8\r\n";
! $header[] = "Content-Length:
".strlen($payload)."\r\n\r\n";
! reset($header);
! foreach($header as $hdr)
! {
! header($hdr);
! }
! print $payload;
! }
!
! function parseRequest($data="")
! {
! global $HTTP_SERVER_VARS;
!
! $this->debug("entering parseRequest() on ".date("H:i
Y-m-d"));
! $request_uri = $HTTP_SERVER_VARS["REQUEST_URI"];
! $this->debug("request uri: $request_uri");
! // get headers
! $headers_array = getallheaders();
! foreach($headers_array as $k=>$v)
! {
! $dump .= "$k: $v\r\n";
! }
! $dump .= "\r\n\r\n".$data;
! $this->headers = $headers_array;
! $this->request = $dump;
!
! // get SOAPAction header -> methodname
! if($headers_array["SOAPAction"])
! {
! $action =
str_replace('"','',$headers_array["SOAPAction"]);
! if(ereg("^urn:",$action))
! {
! $this->service = substr($action,4);
! }
! elseif(ereg(".php",$action))
! {
! $this->service =
ereg_replace('"|/','',substr(strrchr($action,".php"),4,strlen(strrchr($action,"/"))));
! }
! $this->debug("got service: $this->service");
! }
! else
! {
! // throw a fault if no soapaction
! $this->debug("ERROR: no SOAPAction header
found");
! }
! // NOTE:::: throw a fault for no/bad soapaction here?
!
! // parse response, get soap parser obj
! $parser = CreateObject('phpgwapi.soap_parser',$data);
! // get/set methodname
! $this->methodname = $parser->root_struct_name;
! $this->debug("method name: $this->methodname");
!
! // does method exist?
! $test = ereg_replace("\.",'_',$this->methodname);
! if(function_exists($test))
! {
! $method = $this->methodname = $test;
! $this->debug("method '$this->methodname'
exists");
! }
! else
! {
! /* phpgroupware customization - createobject
based on methodname */
! list($app,$class,$method) =
explode('.',$this->methodname);
! if(ereg("^service",$app))
! {
! $args = $class;
! $class = 'service';
! $app = 'phpgwapi';
! $obj =
CreateObject(sprintf('%s.%s',$app,$class),$args);
! unset($args);
! }
! else
! {
! $obj =
CreateObject(sprintf('%s.%s',$app,$class));
! }
! $this->debug('app: ' . $app . ', class: ' .
$class . ', method: ' . $method);
! /*
! // "method not found" fault here
! $this->debug("method '$obj->method' not
found!");
! $this->result = "fault: method not found";
! $this->make_fault("Server","method
'$obj->method' not defined in service '$this->service'");
! return $this->fault();
! */
! }
!
! // if fault occurred during message parsing
! if($parser->fault())
! {
! // parser debug
! $this->debug($parser->debug_str);
! $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();
! // else successfully parsed request into
soapval object
! }
! else
! {
! // get eval_str
! $this->debug("calling parser->get_response()");
! // evaluate it, getting back a soapval object
! if(!$request_val = $parser->get_response())
! {
! return $this->fault();
! }
! // parser debug
! $this->debug($parser->debug_str);
! if(get_class($request_val) == "soapval")
! {
! if (is_object($obj))
! {
! /* Add the function to the
server map */
! $in = "array('" .
implode("','",$obj->soap_functions[$method]['in']) . "')";
! $out = "array('" .
implode("','",$obj->soap_functions[$method]['out']) . "')";
! $evalmap =
"\$this->add_to_map(\$this->methodname,$in,$out);";
! eval($evalmap);
! }
! /* verify that soapval objects in
request match the methods signature */
! if($this->verify_method($request_val))
! {
! $this->debug("request data -
name: $request_val->name, type: $request_val->type, value:
$request_val->value");
! if($this->input_value)
! {
! /* decode the soapval
object, and pass resulting values to the requested method */
! if(!$request_data =
$request_val->decode())
! {
!
$this->make_fault("Server","Unable to decode response from soapval object into
native php type.");
! return
$this->fault();
! }
! $this->debug("request
data: $request_data");
! }
!
! /* if there are return values */
! if($this->return_type =
$this->get_return_type())
! {
! $this->debug("got
return type: '$this->return_type'");
! /* if there are
parameters to pass */
! if($request_data)
! {
! if
(is_object($obj))
! {
! $code =
"\$method_response = call_user_method($method,$obj,";
!
$this->debug("about to call object method '$class\-\>$method' with args");
! }
! else
! {
! $code =
'$method_response = ' . $this->methodname . "('";
! $args =
implode("','",$request_data['return']);
!
$this->debug("about to call method '$this->methodname' with args: $args");
! }
! /* call method
with parameters */
! $code .=
implode("','",$request_data['return']);
! /*
!
while(list($x,$y) = each($request_data))
! {
! $code
.= "\$request_data[$x]" . ',';
! }
! $code =
substr($code,0,-1) .");";
! */
! $code .= "');";
!
$this->debug('CODE: ' . $code);
! if(eval($code))
! {
! if
(is_object($obj))
! {
!
$this->make_fault("Server","Object method call failed for '$class\-\>$method'
with params: ".join(',',$request_data));
! }
! else
! {
!
$this->make_fault("Server","Method call failed for '$this->methodname' with
params: ".join(',',$request_data));
! }
! return
$this->fault();
! }
!
$this->debug('Response: ' . $method_response);
! //
_debug_array($method_response);
! }
! else
! {
! /* call method
w/ no parameters */
! if
(is_object($obj))
! {
!
$this->debug("about to call object method '$obj\-\>$method'");
!
if(!$method_response = call_user_method($method,$obj))
! {
!
$this->make_fault("Server","Method call failed for '$obj->method' with no
params");
!
return $this->fault();
! }
! }
! else
! {
!
$this->debug("about to call method '$this->methodname'");
!
if(!$method_response = call_user_func($this->methodname))
! {
!
$this->make_fault("Server","Method call failed for '$this->methodname' with no
params");
!
return $this->fault();
! }
! }
! }
! /* no return values */
! }
! else
! {
! if($request_data)
! {
! /* call method
with parameters */
! $code =
"\$method_response = call_user_method(\$method,\$obj,";
!
while(list($x,$y) = each($request_data))
! {
! $code
.= "\$request_data[$x]" . ',';
! }
! $code =
substr($code,0,-1) .");";
!
$this->debug("about to call object method '$obj\-\>$method'");
! eval($code);
! }
! else
! {
! /* call method
w/ no parameters */
!
if(is_object($obj))
! {
!
$this->debug("about to call object method '$obj\-\>$method'");
!
call_user_method($method,$obj);
! }
! else
! {
!
$this->debug("about to call method '$method'");
!
call_user_func($method);
! }
! }
! }
!
! /* create soap_val object w/
return values from method, use method signature to determine type */
! if(get_class($method_response)
!= 'soapval')
! {
! $return_val =
CreateObject('phpgwapi.soapval',$method,$this->return_type,$method_response);
! }
! else
! {
! $return_val =
$method_response;
! }
!
$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);
! if($this->debug_flag)
! {
! $return_msg->debug_flag
= true;
! }
! $this->result = "successful";
! return $return_msg;
! }
! else
! {
! // debug
! $this->debug("ERROR: request
not verified against method signature");
! $this->result = "fault: request
failed validation against method signature";
! // return soapresp
! return $this->fault();
! }
! }
! else
! {
! // debug
! $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");
! return $this->fault();
! }
! }
! }
!
! function verify_method($request)
! {
! //return true;
! $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"])
! {
! $this->input_value = count($sig);
! if(is_array($params))
! {
! $this->debug("entered verify_method()
with ".count($params)." parameters");
! foreach($params as $v)
! {
! $this->debug("param '$v->name'
of type '$v->type'");
! }
! // validate the number of parameters
! if(count($params) == count($sig))
! {
! $this->debug("got correct
number of parameters: ".count($sig));
! // make array of param types
! foreach($params as $param)
! {
! $p[] =
strtolower($param->type);
! }
! // validate each param's type
! for($i=0; $i < count($p); $i++)
! {
! // type not match
! 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]");
! return false;
! }
! $this->debug("parameter
type match: $sig[$i] = $p[$i]");
! }
! return true;
! // oops, wrong number of paramss
! }
! 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));
! return false;
! }
! // oops, no params...
! }
! 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");
! return false;
! }
! // no params
! }
! elseif( (count($params)==0) && (count($sig) <= 1) )
! {
! $this->input_values = 0;
! return true;
! }
! else
! {
! //$this->debug("well, request passed parameters
to a method that requires none?");
! //$this->make_fault("Client","method
'$this->methodname' requires no parameters. The request passed in
".count($params).": "address@hidden(" param: ",$params) );
! return true;
! }
! }
!
! // get string return type from dispatch map
! function get_return_type()
! {
! if(count($this->dispatch_map[$this->methodname]["out"])
>= 1)
! {
! $type =
array_shift($this->dispatch_map[$this->methodname]["out"]);
! $this->debug("got return type from dispatch
map: '$type'");
! return $type;
! }
! return false;
! }
!
! // dbg
! function debug($string)
! {
! if($this->debug_flag)
! {
! $this->debug_str .= "$string\n";
! }
! }
!
! // 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;
! }
!
! // set up a fault
! function fault()
! {
! return CreateObject('phpgwapi.soapmsg',
! "Fault",
! array(
! "faultcode" => $this->fault_code,
! "faultstring" => $this->fault_str,
! "faultactor" => $this->fault_actor,
! "faultdetail" =>
$this->fault_detail.$this->debug_str
! ),
! "http://schemas.xmlphpgwapi.org/soap/envelope/"
! );
! }
!
! function make_fault($fault_code,$fault_string)
! {
! $this->fault_code = $fault_code;
! $this->fault_str = $fault_string;
! $this->fault = true;
! }
! }
! ?>
Index: class.soapclient.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.soapclient.inc.php,v
retrieving revision 1.7
retrieving revision 1.7.4.1
diff -C2 -r1.7 -r1.7.4.1
*** class.soapclient.inc.php 28 Sep 2001 21:31:00 -0000 1.7
--- class.soapclient.inc.php 30 May 2003 02:34:26 -0000 1.7.4.1
***************
*** 1,185 ****
! <?php
! /*
!
! SOAPx4
! by Dietrich Ayala (C) 2001 address@hidden
!
! This project began based on code from the 2 projects below,
! and still contains some original code. The licenses of both must be
respected.
!
! XML-RPC for PHP
! originally by Edd Dumbill (C) 1999-2000
!
! SOAP for PHP
! by Victor Zou (C) 2000-2001 <address@hidden>
!
! */
!
! /* changelog:
! 2001-07-04
! - abstract type system to support either 1999 or 2001 schema (arg,
typing still needs much
! solidification.)
! - implemented proxy support, based on sample code from miles lott
<address@hidden>
! - much general cleanup of code & cleaned out what was left of original
xml-rpc/gigaideas code
! - implemented a transport argument into send() that allows you to
specify different transports
! (assuming you have implemented the function, and added it to the
conditional statement in send()
! - abstracted the determination of charset in Content-type header
! 2001-07-5
! - fixed more weird type/namespace issues
! */
!
! // $path can be a complete endpoint url, with the other parameters left
blank:
! // $soap_client = new soap_client("http://path/to/soap/server");
!
! /* soapx4 high level class
!
! usage:
!
! // instantiate client with server info
! $soapclient = new soapclient( string path [ ,boolean wsdl] );
!
! // call method, get results
! echo $soapclient->call( string methodname [ ,array parameters] );
!
! // bye bye client
! unset($soapclient);
!
! */
! /* $Id$ */
!
! class soapclient
! {
! function soapclient($endpoint,$wsdl=False,$portName=False)
! {
! $this->debug_flag = True;
! $this->endpoint = $endpoint;
! $this->portName = False;
!
! // make values
! if($wsdl)
! {
! $this->endpointType = 'wsdl';
! if($portName)
! {
! $this->portName = $portName;
! }
! }
! }
!
! function
call($method,$params='',$namespace=false,$soapAction=false)
! {
! if($this->endpointType == 'wsdl')
! {
! // instantiate wsdl class
! $this->wsdl =
CreateObject('phpgwapi.wsdl',$this->endpoint);
! // get portName
! if(!$this->portName)
! {
! $this->portName =
$this->wsdl->getPortName($method);
! }
! // get endpoint
! if(!$this->endpoint =
$this->wsdl->getEndpoint($this->portName))
! {
! die("no port of name '$this->portName'
in the wsdl at that location!");
! }
! $this->debug("endpoint: $this->endpoint");
! $this->debug("portName: $this->portName");
! }
! // get soapAction
! if(!$soapAction)
! {
! if($this->endpointType != 'wsdl')
! {
! die("method call requires soapAction if
wsdl is not available!");
! }
! if(!$soapAction =
$this->wsdl->getSoapAction($this->portName,$method))
! {
! die("no soapAction for operation:
$method!");
! }
! }
! $this->debug("soapAction: $soapAction");
! // get namespace
! if(!$namespace)
! {
! if($this->endpointType != 'wsdl')
! {
! die("method call requires namespace if
wsdl is not available!");
! }
! if(!$namespace =
$this->wsdl->getNamespace($this->portName,$method))
! {
! die("no soapAction for operation:
$method!");
! }
! }
! $this->debug("namespace: $namespace");
!
! // make message
! $soapmsg =
CreateObject('phpgwapi.soapmsg',$method,$params,$namespace);
! /* _debug_array($soapmsg); */
!
! // instantiate client
! $dbg = "calling server at '$this->endpoint'...";
! if($soap_client =
CreateObject('phpgwapi.soap_client',$this->endpoint))
! {
! //$soap_client->debug_flag = true;
! $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'...";
! if($return =
$soap_client->send($soapmsg,$soapAction))
! {
! $this->request =
$soap_client->outgoing_payload;
! $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')
! {
! // fault?
! if(eregi('fault',$return->name))
! {
! $this->debug('got
fault');
! $faultArray =
$return->decode();
! @reset($faultArray);
! while(list($k,$v) =
@each($faultArray))
! /* foreach($faultArray
as $k => $v) */
! {
! print "$k =
$v<br>";
! }
! return false;
! }
! else
! {
! $returnArray =
$return->decode();
!
if(is_array($returnArray))
! {
! return
array_shift($returnArray);
! }
! else
! {
!
$this->debug("didn't get array back from decode() for $return->name");
! return false;
! }
! }
! }
! else
! {
! $this->debug("didn't get
soapval object back from client");
! return false;
! }
! }
! else
! {
! $this->debug('client send/recieve
error');
! return false;
! }
! }
! }
!
! function debug($string)
! {
! if($this->debug_flag)
! {
! print $string . '<br>';
! }
! }
! }
! ?>
--- 1,185 ----
! <?php
! /*
!
! SOAPx4
! by Dietrich Ayala (C) 2001 address@hidden
!
! This project began based on code from the 2 projects below,
! and still contains some original code. The licenses of both must be
respected.
!
! XML-RPC for PHP
! originally by Edd Dumbill (C) 1999-2000
!
! SOAP for PHP
! by Victor Zou (C) 2000-2001 <address@hidden>
!
! */
!
! /* changelog:
! 2001-07-04
! - abstract type system to support either 1999 or 2001 schema (arg,
typing still needs much
! solidification.)
! - implemented proxy support, based on sample code from miles lott
<address@hidden>
! - much general cleanup of code & cleaned out what was left of original
xml-rpc/gigaideas code
! - implemented a transport argument into send() that allows you to
specify different transports
! (assuming you have implemented the function, and added it to the
conditional statement in send()
! - abstracted the determination of charset in Content-type header
! 2001-07-5
! - fixed more weird type/namespace issues
! */
!
! // $path can be a complete endpoint url, with the other parameters left
blank:
! // $soap_client = new soap_client("http://path/to/soap/server");
!
! /* soapx4 high level class
!
! usage:
!
! // instantiate client with server info
! $soapclient = new soapclient( string path [ ,boolean wsdl] );
!
! // call method, get results
! echo $soapclient->call( string methodname [ ,array parameters] );
!
! // bye bye client
! unset($soapclient);
!
! */
! /* $Id$ */
!
! class soapclient
! {
! function soapclient($endpoint,$wsdl=False,$portName=False)
! {
! $this->debug_flag = True;
! $this->endpoint = $endpoint;
! $this->portName = False;
!
! // make values
! if($wsdl)
! {
! $this->endpointType = 'wsdl';
! if($portName)
! {
! $this->portName = $portName;
! }
! }
! }
!
! function
call($method,$params='',$namespace=false,$soapAction=false)
! {
! if($this->endpointType == 'wsdl')
! {
! // instantiate wsdl class
! $this->wsdl =
CreateObject('phpgwapi.wsdl',$this->endpoint);
! // get portName
! if(!$this->portName)
! {
! $this->portName =
$this->wsdl->getPortName($method);
! }
! // get endpoint
! if(!$this->endpoint =
$this->wsdl->getEndpoint($this->portName))
! {
! die("no port of name '$this->portName'
in the wsdl at that location!");
! }
! $this->debug("endpoint: $this->endpoint");
! $this->debug("portName: $this->portName");
! }
! // get soapAction
! if(!$soapAction)
! {
! if($this->endpointType != 'wsdl')
! {
! die("method call requires soapAction if
wsdl is not available!");
! }
! if(!$soapAction =
$this->wsdl->getSoapAction($this->portName,$method))
! {
! die("no soapAction for operation:
$method!");
! }
! }
! $this->debug("soapAction: $soapAction");
! // get namespace
! if(!$namespace)
! {
! if($this->endpointType != 'wsdl')
! {
! die("method call requires namespace if
wsdl is not available!");
! }
! if(!$namespace =
$this->wsdl->getNamespace($this->portName,$method))
! {
! die("no soapAction for operation:
$method!");
! }
! }
! $this->debug("namespace: $namespace");
!
! // make message
! $soapmsg =
CreateObject('phpgwapi.soapmsg',$method,$params,$namespace);
! /* _debug_array($soapmsg); */
!
! // instantiate client
! $dbg = "calling server at '$this->endpoint'...";
! if($soap_client =
CreateObject('phpgwapi.soap_client',$this->endpoint))
! {
! //$soap_client->debug_flag = true;
! $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'...";
! if($return =
$soap_client->send($soapmsg,$soapAction))
! {
! $this->request =
$soap_client->outgoing_payload;
! $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')
! {
! // fault?
! if(eregi('fault',$return->name))
! {
! $this->debug('got
fault');
! $faultArray =
$return->decode();
! @reset($faultArray);
! while(list($k,$v) =
@each($faultArray))
! /* foreach($faultArray
as $k => $v) */
! {
! print "$k =
$v<br>";
! }
! return false;
! }
! else
! {
! $returnArray =
$return->decode();
!
if(is_array($returnArray))
! {
! return
array_shift($returnArray);
! }
! else
! {
!
$this->debug("didn't get array back from decode() for $return->name");
! return false;
! }
! }
! }
! else
! {
! $this->debug("didn't get
soapval object back from client");
! return false;
! }
! }
! else
! {
! $this->debug('client send/recieve
error');
! return false;
! }
! }
! }
!
! function debug($string)
! {
! if($this->debug_flag)
! {
! print $string . '<br>';
! }
! }
! }
! ?>
Index: class.soapmsg.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.soapmsg.inc.php,v
retrieving revision 1.8
retrieving revision 1.8.4.1
diff -C2 -r1.8 -r1.8.4.1
*** class.soapmsg.inc.php 10 Dec 2001 02:09:17 -0000 1.8
--- class.soapmsg.inc.php 30 May 2003 02:34:26 -0000 1.8.4.1
***************
*** 1,183 ****
! <?php
! /*
!
! SOAPx4
! by Dietrich Ayala (C) 2001 address@hidden
!
! This project began based on code from the 2 projects below,
! and still contains some original code. The licenses of both must be
respected.
!
! XML-RPC for PHP
! originally by Edd Dumbill (C) 1999-2000
!
! SOAP for PHP
! by Victor Zou (C) 2000-2001 <address@hidden>
!
! */
!
! /* changelog:
! 2001-07-04
! - abstract type system to support either 1999 or 2001 schema (arg,
typing still needs much
! solidification.)
! - implemented proxy support, based on sample code from miles lott
<address@hidden>
! - much general cleanup of code & cleaned out what was left of original
xml-rpc/gigaideas code
! - implemented a transport argument into send() that allows you to
specify different transports
! (assuming you have implemented the function, and added it to the
conditional statement in send()
! - abstracted the determination of charset in Content-type header
! 2001-07-5
! - fixed more weird type/namespace issues
! */
!
! // $path can be a complete endpoint url, with the other parameters left
blank:
! // $soap_client = new soap_client("http://path/to/soap/server");
!
! /* $Id$ */
!
! // soap message class
! class soapmsg
! {
! // params is an array of soapval objects
! function
soapmsg($method,$params,$method_namespace='http://testuri.org',$new_namespaces=False)
! {
! // globalize method namespace
! $GLOBALS['methodNamespace'] = $method_namespace;
! $namespaces = $GLOBALS['namespaces'];
!
! // make method struct
! $this->value =
CreateObject('phpgwapi.soapval',$method,"struct",$params,$method_namespace);
! if(is_array($new_namespaces))
! {
! $i = count($namespaces);
! @reset($new_namespaces);
! while(list($null,$v) = @each($new_namespaces))
! /* foreach($new_namespaces as $v) */
! {
! $namespaces[$v] = 'ns' . $i++;
! }
! $this->namespaces = $namespaces;
! }
! $this->payload = '';
! $this->debug_flag = True;
! $this->debug_str = "entering soapmsg() with soapval
".$this->value->name."\n";
! }
!
! function make_envelope($payload)
! {
! $namespaces = $GLOBALS['namespaces'];
! @reset($namespaces);
! while(list($k,$v) = @each($namespaces))
! /* foreach($namespaces as $k => $v) */
! {
! $ns_string .= " xmlns:$v=\"$k\"";
! }
! return "<SOAP-ENV:Envelope $ns_string
SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\n"
! . $payload . "</SOAP-ENV:Envelope>\n";
! }
!
! function make_body($payload)
! {
! return "<SOAP-ENV:Body>\n" . $payload .
"</SOAP-ENV:Body>\n";
! }
!
! function createPayload()
! {
! $value = $this->value;
! $payload =
$this->make_envelope($this->make_body($value->serialize()));
! $this->debug($value->debug_str);
! $payload = "<?xml version=\"1.0\"?>\n".$payload;
! if($this->debug_flag)
! {
! $payload .= $this->serializeDebug();
! }
! $this->payload = str_replace("\n","\r\n", $payload);
! }
!
! function serialize()
! {
! if($this->payload == '')
! {
! $this->createPayload();
! return $this->payload;
! }
! else
! {
! return $this->payload;
! }
! }
!
! // returns a soapval object
! function parseResponse($data)
! {
! $this->debug("Entering parseResponse()");
! //$this->debug(" w/ data $data");
! // strip headers here
! //$clean_data = ereg_replace("\r\n","\n", $data);
! if(ereg("^.*\r\n\r\n<",$data))
! {
! $this->debug("found proper seperation of
headers and document");
! $this->debug("getting rid of headers,
stringlen: ".strlen($data));
! $clean_data = ereg_replace("^.*\r\n\r\n<","<",
$data);
! $this->debug("cleaned data, stringlen:
".strlen($clean_data));
! }
! else
! {
! // return fault
! return CreateObject('phpgwapi.soapval',
! 'fault',
! 'SOAPStruct',
! Array(
!
CreateObject('phpgwapi.soapval','faultcode','string','SOAP-MSG'),
!
CreateObject('phpgwapi.soapval','faultstring','string','HTTP Error'),
!
CreateObject('phpgwapi.soapval','faultdetail','string','HTTP headers were not
immediately followed by \'\r\n\r\n\'')
! )
! );
! }
! /*
! // if response is a proper http response, and is not a
200
! if(ereg("^HTTP",$clean_data) && !ereg("200$",
$clean_data))
! {
! // get error data
! $errstr = substr($clean_data, 0,
strpos($clean_data, "\n")-1);
! // return fault
! return CreateObject('phpgwapi.soapval',
! "fault",
! "SOAPStruct",
! array(
!
CreateObject('phpgwapi.soapval',"faultcode","string","SOAP-MSG"),
!
CreateObject('phpgwapi.soapval',"faultstring","string","HTTP error")
! )
! );
! }
! */
! $this->debug("about to create parser instance w/ data:
$clean_data");
! // parse response
! $response =
CreateObject('phpgwapi.soap_parser',$clean_data);
! // return array of parameters
! $ret = $response->get_response();
! $this->debug($response->debug_str);
! return $ret;
! }
!
! // dbg
! function debug($string)
! {
! if($this->debug_flag)
! {
! $this->debug_str .= "$string\n";
! }
! }
!
! // preps debug data for encoding into soapmsg
! function serializeDebug()
! {
! if($this->debug_flag)
! {
! return "<!-- DEBUG
INFO:\n".$this->debug_str."-->\n";
! }
! else
! {
! return '';
! }
! }
! }
! ?>
--- 1,183 ----
! <?php
! /*
!
! SOAPx4
! by Dietrich Ayala (C) 2001 address@hidden
!
! This project began based on code from the 2 projects below,
! and still contains some original code. The licenses of both must be
respected.
!
! XML-RPC for PHP
! originally by Edd Dumbill (C) 1999-2000
!
! SOAP for PHP
! by Victor Zou (C) 2000-2001 <address@hidden>
!
! */
!
! /* changelog:
! 2001-07-04
! - abstract type system to support either 1999 or 2001 schema (arg,
typing still needs much
! solidification.)
! - implemented proxy support, based on sample code from miles lott
<address@hidden>
! - much general cleanup of code & cleaned out what was left of original
xml-rpc/gigaideas code
! - implemented a transport argument into send() that allows you to
specify different transports
! (assuming you have implemented the function, and added it to the
conditional statement in send()
! - abstracted the determination of charset in Content-type header
! 2001-07-5
! - fixed more weird type/namespace issues
! */
!
! // $path can be a complete endpoint url, with the other parameters left
blank:
! // $soap_client = new soap_client("http://path/to/soap/server");
!
! /* $Id$ */
!
! // soap message class
! class soapmsg
! {
! // params is an array of soapval objects
! function
soapmsg($method,$params,$method_namespace='http://testuri.org',$new_namespaces=False)
! {
! // globalize method namespace
! $GLOBALS['methodNamespace'] = $method_namespace;
! $namespaces = $GLOBALS['namespaces'];
!
! // make method struct
! $this->value =
CreateObject('phpgwapi.soapval',$method,"struct",$params,$method_namespace);
! if(is_array($new_namespaces))
! {
! $i = count($namespaces);
! @reset($new_namespaces);
! while(list($null,$v) = @each($new_namespaces))
! /* foreach($new_namespaces as $v) */
! {
! $namespaces[$v] = 'ns' . $i++;
! }
! $this->namespaces = $namespaces;
! }
! $this->payload = '';
! $this->debug_flag = True;
! $this->debug_str = "entering soapmsg() with soapval
".$this->value->name."\n";
! }
!
! function make_envelope($payload)
! {
! $namespaces = $GLOBALS['namespaces'];
! @reset($namespaces);
! while(list($k,$v) = @each($namespaces))
! /* foreach($namespaces as $k => $v) */
! {
! $ns_string .= " xmlns:$v=\"$k\"";
! }
! return "<SOAP-ENV:Envelope $ns_string
SOAP-ENV:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\">\n"
! . $payload . "</SOAP-ENV:Envelope>\n";
! }
!
! function make_body($payload)
! {
! return "<SOAP-ENV:Body>\n" . $payload .
"</SOAP-ENV:Body>\n";
! }
!
! function createPayload()
! {
! $value = $this->value;
! $payload =
$this->make_envelope($this->make_body($value->serialize()));
! $this->debug($value->debug_str);
! $payload = "<?xml version=\"1.0\"?>\n".$payload;
! if($this->debug_flag)
! {
! $payload .= $this->serializeDebug();
! }
! $this->payload = str_replace("\n","\r\n", $payload);
! }
!
! function serialize()
! {
! if($this->payload == '')
! {
! $this->createPayload();
! return $this->payload;
! }
! else
! {
! return $this->payload;
! }
! }
!
! // returns a soapval object
! function parseResponse($data)
! {
! $this->debug("Entering parseResponse()");
! //$this->debug(" w/ data $data");
! // strip headers here
! //$clean_data = ereg_replace("\r\n","\n", $data);
! if(ereg("^.*\r\n\r\n<",$data))
! {
! $this->debug("found proper seperation of
headers and document");
! $this->debug("getting rid of headers,
stringlen: ".strlen($data));
! $clean_data = ereg_replace("^.*\r\n\r\n<","<",
$data);
! $this->debug("cleaned data, stringlen:
".strlen($clean_data));
! }
! else
! {
! // return fault
! return CreateObject('phpgwapi.soapval',
! 'fault',
! 'SOAPStruct',
! Array(
!
CreateObject('phpgwapi.soapval','faultcode','string','SOAP-MSG'),
!
CreateObject('phpgwapi.soapval','faultstring','string','HTTP Error'),
!
CreateObject('phpgwapi.soapval','faultdetail','string','HTTP headers were not
immediately followed by \'\r\n\r\n\'')
! )
! );
! }
! /*
! // if response is a proper http response, and is not a
200
! if(ereg("^HTTP",$clean_data) && !ereg("200$",
$clean_data))
! {
! // get error data
! $errstr = substr($clean_data, 0,
strpos($clean_data, "\n")-1);
! // return fault
! return CreateObject('phpgwapi.soapval',
! "fault",
! "SOAPStruct",
! array(
!
CreateObject('phpgwapi.soapval',"faultcode","string","SOAP-MSG"),
!
CreateObject('phpgwapi.soapval',"faultstring","string","HTTP error")
! )
! );
! }
! */
! $this->debug("about to create parser instance w/ data:
$clean_data");
! // parse response
! $response =
CreateObject('phpgwapi.soap_parser',$clean_data);
! // return array of parameters
! $ret = $response->get_response();
! $this->debug($response->debug_str);
! return $ret;
! }
!
! // dbg
! function debug($string)
! {
! if($this->debug_flag)
! {
! $this->debug_str .= "$string\n";
! }
! }
!
! // preps debug data for encoding into soapmsg
! function serializeDebug()
! {
! if($this->debug_flag)
! {
! return "<!-- DEBUG
INFO:\n".$this->debug_str."-->\n";
! }
! else
! {
! return '';
! }
! }
! }
! ?>
Index: class.soapval.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.soapval.inc.php,v
retrieving revision 1.8
retrieving revision 1.8.4.1
diff -C2 -r1.8 -r1.8.4.1
*** class.soapval.inc.php 10 Dec 2001 02:09:17 -0000 1.8
--- class.soapval.inc.php 30 May 2003 02:34:26 -0000 1.8.4.1
***************
*** 1,468 ****
! <?php
! /*
!
! SOAPx4
! by Dietrich Ayala (C) 2001 address@hidden
!
! This project began based on code from the 2 projects below,
! and still contains some original code. The licenses of both must be
respected.
!
! XML-RPC for PHP
! originally by Edd Dumbill (C) 1999-2000
!
! SOAP for PHP
! by Victor Zou (C) 2000-2001 <address@hidden>
!
! */
!
! /* changelog:
! 2001-07-04
! - abstract type system to support either 1999 or 2001 schema (arg,
typing still needs much
! solidification.)
! - implemented proxy support, based on sample code from miles lott
<address@hidden>
! - much general cleanup of code & cleaned out what was left of original
xml-rpc/gigaideas code
! - implemented a transport argument into send() that allows you to
specify different transports
! (assuming you have implemented the function, and added it to the
conditional statement in send()
! - abstracted the determination of charset in Content-type header
! 2001-07-5
! - fixed more weird type/namespace issues
! */
!
! // $path can be a complete endpoint url, with the other parameters left
blank:
! // $soap_client = new soap_client("http://path/to/soap/server");
!
! /* $Id$ */
!
! // soap value object
! class soapval
! {
! // function
soapval($name='',$type=False,$value=-1,$namespace=False,$type_namespace=False)
! function
soapval($name='',$type=False,$value=0,$namespace=False,$type_namespace=False)
! {
! // detect type if not passed
! if(!$type)
! {
! if(is_array($value) && count($value) >= 1)
! {
! if(ereg("[a-zA-Z0-9\-]*",key($v)))
! {
! $type = 'struct';
! }
! else
! {
! $type = 'array';
! }
! }
! elseif(is_int($v))
! {
! $type = 'int';
! }
! elseif(is_float($v) || $v == 'NaN' || $v ==
'INF')
! {
! $type = 'float';
! }
! else
! {
! $type = gettype($value);
! }
! }
! // php type name mangle
! if($type == 'integer')
! {
! $type = 'int';
! }
!
! $this->soapTypes = $GLOBALS['soapTypes'];
! $this->name = $name;
! $this->value = '';
! $this->type = $type;
! $this->type_code = 0;
! $this->type_prefix = false;
! $this->array_type = '';
! $this->debug_flag = False;
! $this->debug_str = '';
! $this->debug("Entering soapval - name: '$name' type:
'$type'");
!
! if($namespace)
! {
! $this->namespace = $namespace;
! if(!isset($GLOBALS['namespaces'][$namespace]))
! {
! $GLOBALS['namespaces'][$namespace] =
"ns".(count($GLOBALS['namespaces'])+1);
! }
! $this->prefix =
$GLOBALS['namespaces'][$namespace];
! }
!
! // get type prefix
! if(ereg(":",$type))
! {
! $this->type =
substr(strrchr($type,':'),1,strlen(strrchr($type,':')));
! $this->type_prefix =
substr($type,0,strpos($type,':'));
! }
! elseif($type_namespace)
! {
!
if(!isset($GLOBALS['namespaces'][$type_namespace]))
! {
! $GLOBALS['namespaces'][$type_namespace]
= 'ns'.(count($GLOBALS['namespaces'])+1);
! }
! $this->type_prefix =
$GLOBALS['namespaces'][$type_namespace];
! }
!
! // if type namespace was not explicitly passed, and
we're not in a method struct:
! elseif(!$this->type_prefix && !isset($this->namespace))
! {
! // try to get type prefix from typeMap
! if(!$this->type_prefix =
$this->verify_type($type))
! {
! // else default to method namespace
! $this->type_prefix =
$GLOBALS['namespaces'][$GLOBALS['methodNamespace']];
! }
! }
!
! // if scalar
! if($this->soapTypes[$this->type] == 1)
! {
! $this->type_code = 1;
! $this->addScalar($value,$this->type,$name);
! // if array
! }
! elseif($this->soapTypes[$this->type] == 2)
! {
! $this->type_code = 2;
! $this->addArray($value);
! // if struct
! }
! elseif($this->soapTypes[$this->type] == 3)
! {
! $this->type_code = 3;
! $this->addStruct($value);
! }
! else
! {
! //if($namespace == $GLOBALS['methodNamespace']){
! $this->type_code = 3;
! $this->addStruct($value);
! //}
! }
! }
!
! function addScalar($value, $type, $name="")
! {
! $this->debug("adding scalar '$name' of type '$type'");
!
! // if boolean, change value to 1 or 0
! if ($type == "boolean")
! {
! if((strcasecmp($value,"true") == 0) || ($value
== 1))
! {
! $value = 1;
! }
! else
! {
! $value = 0;
! }
! }
!
! $this->value = $value;
! return true;
! }
!
! function addArray($vals)
! {
! $this->debug("adding array '$this->name' with
".count($vals)." vals");
! $this->value = array();
! if(is_array($vals) && count($vals) >= 1)
! {
! @reset($vals);
! while(list($k,$v) = @each($vals))
! /* foreach($vals as $k => $v) */
! {
! $this->debug("checking value $k : $v");
! // if soapval, add..
! if(get_class($v) == 'soapval')
! {
! $this->value[] = $v;
! $this->debug($v->debug_str);
! // else make obj and serialize
! }
! else
! {
! if(is_array($v))
! {
!
if(ereg("[a-zA-Z\-]*",key($v)))
! {
! $type =
'struct';
! }
! else
! {
! $type = 'array';
! }
! }
! elseif(!ereg("^[0-9]*$",$k) &&
in_array($k,array_keys($this->soapTypes)))
! {
! $type = $k;
! }
! elseif(is_int($v))
! {
! $type = 'int';
! }
! elseif(is_float($v) || $v ==
'NaN' || $v == 'INF')
! {
! $type = 'float';
! }
! else
! {
! $type = gettype($v);
! }
! $new_val =
CreateObject('phpgwapi.soapval','item',$type,$v);
!
$this->debug($new_val->debug_str);
! $this->value[] = $new_val;
! }
! }
! }
! return true;
! }
!
! function addStruct($vals)
! {
! $this->debug("adding struct '$this->name' with
".count($vals).' vals');
! if(is_array($vals) && count($vals) >= 1)
! {
! @reset($vals);
! while(list($k,$v) = @each($vals))
! /* foreach($vals as $k => $v) */
! {
! // if serialize, if soapval
! if(get_class($v) == 'soapval')
! {
! $this->value[] = $v;
! $this->debug($v->debug_str);
! // else make obj and serialize
! }
! else
! {
! if(is_array($v))
! {
! @reset($v);
! while(list($a,$b) =
@each($v))
! /* foreach($v as $a =>
$b) */
! {
! if($a == "0")
! {
! $type =
'array';
! }
! else
! {
! $type =
'struct';
! }
! break;
! }
! }
! // elseif(is_array($k) &&
in_array($k,array_keys($this->soapTypes)))
!
elseif(is_array($k,in_array($k,array_keys($this->soapTypes))))
! {
! $this->debug("got type
'$type' for value '$v' from soapTypes array!");
! $type = $k;
! }
! elseif(is_int($v))
! {
! $type = 'int';
! }
! elseif(is_float($v) || $v ==
"NaN" || $v == "INF")
! {
! $type = 'float';
! }
! else
! {
! $type = gettype($v);
! $this->debug("got type
'$type' for value '$v' from php gettype()!");
! }
! $new_val =
CreateObject('phpgwapi.soapval',$k,$type,$v);
!
$this->debug($new_val->debug_str);
! $this->value[] = $new_val;
! }
! }
! }
! else
! {
! $this->value = array();
! }
! return true;
! }
!
! // turn soapvals into xml, woohoo!
! function serializeval($soapval=false)
! {
! if(!$soapval)
! {
! $soapval = $this;
! }
! $this->debug("serializing '$soapval->name' of type
'$soapval->type'");
! if($soapval->name == '')
! {
! $soapval->name = 'return';
! }
!
! switch($soapval->type_code)
! {
! case 3:
! // 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";
! }
! elseif($soapval->type_prefix)
! {
! $xml .= "<$soapval->name
xsi:type=\"$soapval->type_prefix:$soapval->type\">\n";
! }
! elseif($soapval->prefix)
! {
! $xml .=
"<$soapval->prefix:$soapval->name>\n";
! }
! else
! {
! $xml .= "<$soapval->name>\n";
! }
! if(is_array($soapval->value))
! {
! @reset($soapval->value);
! while(list($k,$v) =
@each($soapval->value))
! /* foreach($soapval->value as
$k => $v) */
! {
! $xml .=
$this->serializeval($v);
! }
! }
! if($soapval->prefix)
! {
! $xml .=
"</$soapval->prefix:$soapval->name>\n";
! }
! else
! {
! $xml .= "</$soapval->name>\n";
! }
! break;
! case 2:
! // array
! @reset($soapval->value);
! while(list($null,$array_val) =
@each($soapval->value))
! /* foreach($soapval->value as
$array_val) */
! {
! $array_types[$array_val->type]
= 1;
! $xml .=
$this->serializeval($array_val);
! }
! if(count($array_types) > 1)
! {
! $array_type = 'xsd:ur-type';
! }
! elseif(count($array_types) >= 1)
! {
! $array_type =
$array_val->type_prefix.":".$array_val->type;
! }
!
! $xml = "<$soapval->name
xsi:type=\"SOAP-ENC:Array\"
SOAP-ENC:arrayType=\"".$array_type."[".sizeof($soapval->value)."]\">\n".$xml."</$soapval->name>\n";
! break;
! case 1:
! $xml .= "<$soapval->name
xsi:type=\"$soapval->type_prefix:$soapval->type\">$soapval->value</$soapval->name>\n";
! break;
! default:
! break;
! }
! return $xml;
! }
!
! // serialize
! function serialize()
! {
! return $this->serializeval($this);
! }
!
! function decode($soapval=false)
! {
! if(!$soapval)
! {
! $soapval = $this;
! }
! // scalar decode
! if($soapval->type_code == 1)
! {
! return $soapval->value;
! // array decode
! }
! elseif($soapval->type_code == 2)
! {
! if(is_array($soapval->value))
! {
! @reset($soapval->value);
! while(list($null,$item) =
@each($soapval->value))
! /* foreach($soapval->value as $item) */
! {
! $return[] =
$this->decode($item);
! }
! return $return;
! }
! else
! {
! return array();
! }
! // struct decode
! }
! elseif($soapval->type_code == 3)
! {
! if(is_array($soapval->value))
! {
! @reset($soapval->value);
! while(list($null,$item) =
@each($soapval->value))
! /* foreach($soapval->value as $item) */
! {
! $return[$item->name] =
$this->decode($item);
! }
! return $return;
! }
! else
! {
! return array();
! }
! }
! }
!
! // verify type
! function verify_type($type)
! {
! if ($type)
! {
! // global
$GLOBALS['namespaces'],$GLOBALS['soapTypes'],$GLOBALS['typemap'];
! // global
$GLOBALS['namespaces'],$GLOBALS['typemap'];
!
! @reset($GLOBALS['typemap']);
! while(list($namespace,$types) =
@each($GLOBALS['typemap']))
! /* foreach($GLOBALS['typemap'] as $namespace =>
$types) */
! {
! if(in_array($type,$types))
! {
! return
$GLOBALS['namespaces'][$namespace];
! }
! }
! }
! return false;
! }
!
! // alias for verify_type() - pass it a type, and it returns
it's prefix
! function get_prefix($type)
! {
! if($prefix = $this->verify_type($type))
! {
! return $prefix;
! }
! return false;
! }
!
! function debug($string)
! {
! if($this->debug_flag)
! {
! $this->debug_str .= "$string\n";
! }
! }
! }
! ?>
--- 1,468 ----
! <?php
! /*
!
! SOAPx4
! by Dietrich Ayala (C) 2001 address@hidden
!
! This project began based on code from the 2 projects below,
! and still contains some original code. The licenses of both must be
respected.
!
! XML-RPC for PHP
! originally by Edd Dumbill (C) 1999-2000
!
! SOAP for PHP
! by Victor Zou (C) 2000-2001 <address@hidden>
!
! */
!
! /* changelog:
! 2001-07-04
! - abstract type system to support either 1999 or 2001 schema (arg,
typing still needs much
! solidification.)
! - implemented proxy support, based on sample code from miles lott
<address@hidden>
! - much general cleanup of code & cleaned out what was left of original
xml-rpc/gigaideas code
! - implemented a transport argument into send() that allows you to
specify different transports
! (assuming you have implemented the function, and added it to the
conditional statement in send()
! - abstracted the determination of charset in Content-type header
! 2001-07-5
! - fixed more weird type/namespace issues
! */
!
! // $path can be a complete endpoint url, with the other parameters left
blank:
! // $soap_client = new soap_client("http://path/to/soap/server");
!
! /* $Id$ */
!
! // soap value object
! class soapval
! {
! // function
soapval($name='',$type=False,$value=-1,$namespace=False,$type_namespace=False)
! function
soapval($name='',$type=False,$value=0,$namespace=False,$type_namespace=False)
! {
! // detect type if not passed
! if(!$type)
! {
! if(is_array($value) && count($value) >= 1)
! {
! if(ereg("[a-zA-Z0-9\-]*",key($v)))
! {
! $type = 'struct';
! }
! else
! {
! $type = 'array';
! }
! }
! elseif(is_int($v))
! {
! $type = 'int';
! }
! elseif(is_float($v) || $v == 'NaN' || $v ==
'INF')
! {
! $type = 'float';
! }
! else
! {
! $type = gettype($value);
! }
! }
! // php type name mangle
! if($type == 'integer')
! {
! $type = 'int';
! }
!
! $this->soapTypes = $GLOBALS['soapTypes'];
! $this->name = $name;
! $this->value = '';
! $this->type = $type;
! $this->type_code = 0;
! $this->type_prefix = false;
! $this->array_type = '';
! $this->debug_flag = False;
! $this->debug_str = '';
! $this->debug("Entering soapval - name: '$name' type:
'$type'");
!
! if($namespace)
! {
! $this->namespace = $namespace;
! if(!isset($GLOBALS['namespaces'][$namespace]))
! {
! $GLOBALS['namespaces'][$namespace] =
"ns".(count($GLOBALS['namespaces'])+1);
! }
! $this->prefix =
$GLOBALS['namespaces'][$namespace];
! }
!
! // get type prefix
! if(ereg(":",$type))
! {
! $this->type =
substr(strrchr($type,':'),1,strlen(strrchr($type,':')));
! $this->type_prefix =
substr($type,0,strpos($type,':'));
! }
! elseif($type_namespace)
! {
!
if(!isset($GLOBALS['namespaces'][$type_namespace]))
! {
! $GLOBALS['namespaces'][$type_namespace]
= 'ns'.(count($GLOBALS['namespaces'])+1);
! }
! $this->type_prefix =
$GLOBALS['namespaces'][$type_namespace];
! }
!
! // if type namespace was not explicitly passed, and
we're not in a method struct:
! elseif(!$this->type_prefix && !isset($this->namespace))
! {
! // try to get type prefix from typeMap
! if(!$this->type_prefix =
$this->verify_type($type))
! {
! // else default to method namespace
! $this->type_prefix =
$GLOBALS['namespaces'][$GLOBALS['methodNamespace']];
! }
! }
!
! // if scalar
! if($this->soapTypes[$this->type] == 1)
! {
! $this->type_code = 1;
! $this->addScalar($value,$this->type,$name);
! // if array
! }
! elseif($this->soapTypes[$this->type] == 2)
! {
! $this->type_code = 2;
! $this->addArray($value);
! // if struct
! }
! elseif($this->soapTypes[$this->type] == 3)
! {
! $this->type_code = 3;
! $this->addStruct($value);
! }
! else
! {
! //if($namespace == $GLOBALS['methodNamespace']){
! $this->type_code = 3;
! $this->addStruct($value);
! //}
! }
! }
!
! function addScalar($value, $type, $name="")
! {
! $this->debug("adding scalar '$name' of type '$type'");
!
! // if boolean, change value to 1 or 0
! if ($type == "boolean")
! {
! if((strcasecmp($value,"true") == 0) || ($value
== 1))
! {
! $value = 1;
! }
! else
! {
! $value = 0;
! }
! }
!
! $this->value = $value;
! return true;
! }
!
! function addArray($vals)
! {
! $this->debug("adding array '$this->name' with
".count($vals)." vals");
! $this->value = array();
! if(is_array($vals) && count($vals) >= 1)
! {
! @reset($vals);
! while(list($k,$v) = @each($vals))
! /* foreach($vals as $k => $v) */
! {
! $this->debug("checking value $k : $v");
! // if soapval, add..
! if(get_class($v) == 'soapval')
! {
! $this->value[] = $v;
! $this->debug($v->debug_str);
! // else make obj and serialize
! }
! else
! {
! if(is_array($v))
! {
!
if(ereg("[a-zA-Z\-]*",key($v)))
! {
! $type =
'struct';
! }
! else
! {
! $type = 'array';
! }
! }
! elseif(!ereg("^[0-9]*$",$k) &&
in_array($k,array_keys($this->soapTypes)))
! {
! $type = $k;
! }
! elseif(is_int($v))
! {
! $type = 'int';
! }
! elseif(is_float($v) || $v ==
'NaN' || $v == 'INF')
! {
! $type = 'float';
! }
! else
! {
! $type = gettype($v);
! }
! $new_val =
CreateObject('phpgwapi.soapval','item',$type,$v);
!
$this->debug($new_val->debug_str);
! $this->value[] = $new_val;
! }
! }
! }
! return true;
! }
!
! function addStruct($vals)
! {
! $this->debug("adding struct '$this->name' with
".count($vals).' vals');
! if(is_array($vals) && count($vals) >= 1)
! {
! @reset($vals);
! while(list($k,$v) = @each($vals))
! /* foreach($vals as $k => $v) */
! {
! // if serialize, if soapval
! if(get_class($v) == 'soapval')
! {
! $this->value[] = $v;
! $this->debug($v->debug_str);
! // else make obj and serialize
! }
! else
! {
! if(is_array($v))
! {
! @reset($v);
! while(list($a,$b) =
@each($v))
! /* foreach($v as $a =>
$b) */
! {
! if($a == "0")
! {
! $type =
'array';
! }
! else
! {
! $type =
'struct';
! }
! break;
! }
! }
! // elseif(is_array($k) &&
in_array($k,array_keys($this->soapTypes)))
!
elseif(is_array($k,in_array($k,array_keys($this->soapTypes))))
! {
! $this->debug("got type
'$type' for value '$v' from soapTypes array!");
! $type = $k;
! }
! elseif(is_int($v))
! {
! $type = 'int';
! }
! elseif(is_float($v) || $v ==
"NaN" || $v == "INF")
! {
! $type = 'float';
! }
! else
! {
! $type = gettype($v);
! $this->debug("got type
'$type' for value '$v' from php gettype()!");
! }
! $new_val =
CreateObject('phpgwapi.soapval',$k,$type,$v);
!
$this->debug($new_val->debug_str);
! $this->value[] = $new_val;
! }
! }
! }
! else
! {
! $this->value = array();
! }
! return true;
! }
!
! // turn soapvals into xml, woohoo!
! function serializeval($soapval=false)
! {
! if(!$soapval)
! {
! $soapval = $this;
! }
! $this->debug("serializing '$soapval->name' of type
'$soapval->type'");
! if($soapval->name == '')
! {
! $soapval->name = 'return';
! }
!
! switch($soapval->type_code)
! {
! case 3:
! // 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";
! }
! elseif($soapval->type_prefix)
! {
! $xml .= "<$soapval->name
xsi:type=\"$soapval->type_prefix:$soapval->type\">\n";
! }
! elseif($soapval->prefix)
! {
! $xml .=
"<$soapval->prefix:$soapval->name>\n";
! }
! else
! {
! $xml .= "<$soapval->name>\n";
! }
! if(is_array($soapval->value))
! {
! @reset($soapval->value);
! while(list($k,$v) =
@each($soapval->value))
! /* foreach($soapval->value as
$k => $v) */
! {
! $xml .=
$this->serializeval($v);
! }
! }
! if($soapval->prefix)
! {
! $xml .=
"</$soapval->prefix:$soapval->name>\n";
! }
! else
! {
! $xml .= "</$soapval->name>\n";
! }
! break;
! case 2:
! // array
! @reset($soapval->value);
! while(list($null,$array_val) =
@each($soapval->value))
! /* foreach($soapval->value as
$array_val) */
! {
! $array_types[$array_val->type]
= 1;
! $xml .=
$this->serializeval($array_val);
! }
! if(count($array_types) > 1)
! {
! $array_type = 'xsd:ur-type';
! }
! elseif(count($array_types) >= 1)
! {
! $array_type =
$array_val->type_prefix.":".$array_val->type;
! }
!
! $xml = "<$soapval->name
xsi:type=\"SOAP-ENC:Array\"
SOAP-ENC:arrayType=\"".$array_type."[".sizeof($soapval->value)."]\">\n".$xml."</$soapval->name>\n";
! break;
! case 1:
! $xml .= "<$soapval->name
xsi:type=\"$soapval->type_prefix:$soapval->type\">$soapval->value</$soapval->name>\n";
! break;
! default:
! break;
! }
! return $xml;
! }
!
! // serialize
! function serialize()
! {
! return $this->serializeval($this);
! }
!
! function decode($soapval=false)
! {
! if(!$soapval)
! {
! $soapval = $this;
! }
! // scalar decode
! if($soapval->type_code == 1)
! {
! return $soapval->value;
! // array decode
! }
! elseif($soapval->type_code == 2)
! {
! if(is_array($soapval->value))
! {
! @reset($soapval->value);
! while(list($null,$item) =
@each($soapval->value))
! /* foreach($soapval->value as $item) */
! {
! $return[] =
$this->decode($item);
! }
! return $return;
! }
! else
! {
! return array();
! }
! // struct decode
! }
! elseif($soapval->type_code == 3)
! {
! if(is_array($soapval->value))
! {
! @reset($soapval->value);
! while(list($null,$item) =
@each($soapval->value))
! /* foreach($soapval->value as $item) */
! {
! $return[$item->name] =
$this->decode($item);
! }
! return $return;
! }
! else
! {
! return array();
! }
! }
! }
!
! // verify type
! function verify_type($type)
! {
! if ($type)
! {
! // global
$GLOBALS['namespaces'],$GLOBALS['soapTypes'],$GLOBALS['typemap'];
! // global
$GLOBALS['namespaces'],$GLOBALS['typemap'];
!
! @reset($GLOBALS['typemap']);
! while(list($namespace,$types) =
@each($GLOBALS['typemap']))
! /* foreach($GLOBALS['typemap'] as $namespace =>
$types) */
! {
! if(in_array($type,$types))
! {
! return
$GLOBALS['namespaces'][$namespace];
! }
! }
! }
! return false;
! }
!
! // alias for verify_type() - pass it a type, and it returns
it's prefix
! function get_prefix($type)
! {
! if($prefix = $this->verify_type($type))
! {
! return $prefix;
! }
! return false;
! }
!
! function debug($string)
! {
! if($this->debug_flag)
! {
! $this->debug_str .= "$string\n";
! }
! }
! }
! ?>
Index: class.wsdl.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/class.wsdl.inc.php,v
retrieving revision 1.3
retrieving revision 1.3.4.1
diff -C2 -r1.3 -r1.3.4.1
*** class.wsdl.inc.php 17 Oct 2001 22:08:38 -0000 1.3
--- class.wsdl.inc.php 30 May 2003 02:34:26 -0000 1.3.4.1
***************
*** 1,293 ****
! <?php
! /*
!
! SOAPx4
! by Dietrich Ayala (C) 2001 address@hidden
!
! This project began based on code from the 2 projects below,
! and still contains some original code. The licenses of both must be
respected.
!
! XML-RPC for PHP
! originally by Edd Dumbill (C) 1999-2000
!
! SOAP for PHP
! by Victor Zou (C) 2000-2001 <address@hidden>
!
! this is a class that loads a wsdl file and makes it's data available to
an application
! it should provide methods that allow both client and server usage of it
!
! also should have methods for creating a wsdl file from scratch and
! serializing wsdl into valid markup
! */
! /* $Id$ */
!
! class wsdl
! {
! // constructor
! function wsdl($wsdl=False)
! {
! // define internal arrays of bindings, ports,
operations, messages, etc.
! $this->complexTypes = array();
! $this->messages = array();
! $this->currentMessage;
! $this->portOperations = array();
! $this->currentOperation;
! $this->portTypes = array();
! $this->currentPortType;
! $this->bindings = array();
! $this->currentBinding;
! // debug switch
! $this->debug_flag = False;
! // parser vars
! $this->parser;
! $this->position;
! $this->depth;
! $this->depth_array = array();
!
! if($wsdl == "-1")
! {
! $wsdl=False;
! }
! // Check whether content has been read.
! if($wsdl)
! {
! $wsdl_string = join("",file($wsdl));
! // Create an XML parser.
! $this->parser = xml_parser_create();
! // Set the options for parsing the XML data.
! //xml_parser_set_option($parser,
XML_OPTION_SKIP_WHITE, 1);
! xml_parser_set_option($this->parser,
XML_OPTION_CASE_FOLDING, 0);
! // 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');
!
! // Parse the XML file.
! if(!xml_parse($this->parser,$wsdl_string,True))
! {
! // Display an error message.
! $this->debug(sprintf('XML error on line
%d: %s',
!
xml_get_current_line_number($this->parser),
!
xml_error_string(xml_get_error_code($this->parser))));
! $this->fault = True;
! }
! xml_parser_free($this->parser);
! }
! }
!
! // start-element handler
! function start_element($parser, $name, $attrs)
! {
! // position in the total number of elements, starting
from 0
! $pos = $this->position++;
! $depth = $this->depth++;
! // set self as current value for this depth
! $this->depth_array[$depth] = $pos;
!
! // find status, register data
! switch($this->status)
! {
! case 'types':
! switch($name)
! {
! case 'schema':
! $this->schema = True;
! break;
! case 'complexType':
! $this->currentElement =
$attrs['name'];
! $this->schemaStatus =
'complexType';
! break;
! case 'element':
!
$this->complexTypes[$this->currentElement]['elements'][$attrs['name']] = $attrs;
! break;
! case 'complexContent':
! break;
! case 'restriction':
!
$this->complexTypes[$this->currentElement]['restrictionBase'] = $attrs['base'];
! break;
! case 'sequence':
!
$this->complexTypes[$this->currentElement]['order'] = 'sequence';
! break;
! case "all":
!
$this->complexTypes[$this->currentElement]['order'] = 'all';
! break;
! case 'attribute':
! if($attrs['ref'])
! {
!
$this->complexTypes[$this->currentElement]['attrs'][$attrs['ref']] = $attrs;
! }
! elseif($attrs['name'])
! {
!
$this->complexTypes[$this->currentElement]['attrs'][$attrs['name']] = $attrs;
! }
! break;
! }
! break;
! case 'message':
! if($name == 'part')
! {
!
$this->messages[$this->currentMessage][$attrs['name']] = $attrs['type'];
! }
! break;
! case 'portType':
! switch($name)
! {
! case 'operation':
! $this->currentOperation
= $attrs['name'];
!
$this->portTypes[$this->currentPortType][$attrs['name']] =
$attrs['parameterOrder'];
! break;
! default:
!
$this->portOperations[$this->currentOperation][$name]= $attrs;
! break;
! }
! break;
! case 'binding':
! switch($name)
! {
! case 'soap:binding':
!
$this->bindings[$this->currentBinding] =
array_merge($this->bindings[$this->currentBinding],$attrs);
! break;
! case 'operation':
! $this->currentOperation
= $attrs['name'];
!
$this->bindings[$this->currentBinding]['operations'][$attrs['name']] = array();
! break;
! case 'soap:operation':
!
$this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['soapAction']
= $attrs['soapAction'];
! break;
! case 'input':
! $this->opStatus =
'input';
! case 'soap:body':
!
$this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus]
= $attrs;
! break;
! case 'output':
! $this->opStatus =
'output';
! break;
! }
! break;
! case 'service':
! switch($name)
! {
! case 'port':
! $this->currentPort =
$attrs['name'];
!
$this->ports[$attrs['name']] = $attrs;
! break;
! case 'soap:address':
!
$this->ports[$this->currentPort]['location'] = $attrs['location'];
! break;
! }
! break;
! }
! // set status
! switch($name)
! {
! case 'types':
! $this->status = 'types';
! break;
! case 'message':
! $this->status = 'message';
! $this->messages[$attrs['name']] =
array();
! $this->currentMessage = $attrs['name'];
! break;
! case 'portType':
! $this->status = 'portType';
! $this->portTypes[$attrs['name']] =
array();
! $this->currentPortType = $attrs['name'];
! break;
! case 'binding':
! $this->status = 'binding';
! $this->currentBinding = $attrs['name'];
! $this->bindings[$attrs['name']]['type']
= $attrs['type'];
! break;
! case 'service':
! $this->status = 'service';
! break;
! }
! // get element prefix
! if(ereg(":",$name))
! {
! $prefix = substr($name,0,strpos($name,':'));
! }
! }
!
! function getEndpoint($portName)
! {
! if($endpoint = $this->ports[$portName]['location'])
! {
! return $endpoint;
! }
! return False;
! }
!
! function getPortName($operation)
! {
! @reset($this->ports);
! while(list($port,$portAttrs) = @each($this->ports));
! /* foreach($this->ports as $port => $portAttrs) */
! {
! $binding = substr($portAttrs['binding'],4);
! @reset($this->bindings[$binding]['operations']);
! while(list($op,$opAttrs) =
@each($this->bindings[$binding]['operations']))
! /*
foreach($this->bindings[$binding]["operations"] as $op => $opAttrs) */
! {
! if($op == $operation)
! {
! return $port;
! }
! }
! }
! }
!
! function getSoapAction($portName,$operation)
! {
! if($binding =
substr($this->ports[$portName]['binding'],4))
! {
! if($soapAction =
$this->bindings[$binding]['operations'][$operation]['soapAction'])
! {
! return $soapAction;
! }
! return False;
! }
! return False;
! }
!
! function getNamespace($portName,$operation)
! {
! if($binding =
substr($this->ports[$portName]['binding'],4))
! {
! //$this->debug("looking for namespace using
binding '$binding', port '$portName', operation '$operation'");
! if($namespace =
$this->bindings[$binding]['operations'][$operation]['input']['namespace'])
! {
! return $namespace;
! }
! return False;
! }
! return False;
! }
!
! // end-element handler
! function end_element($parser, $name)
! {
! // position of current element is equal to the last
value left in depth_array for my depth
! $pos = $this->depth_array[$this->depth];
! // bring depth down a notch
! $this->depth--;
! }
!
! // element content handler
! function character_data($parser, $data)
! {
! $pos = $this->depth_array[$this->depth];
! $this->message[$pos]['cdata'] .= $data;
! }
!
! function debug($string)
! {
! if($this->debug_flag)
! {
! $this->debug_str .= "$string\n";
! }
! }
! }
! ?>
--- 1,293 ----
! <?php
! /*
!
! SOAPx4
! by Dietrich Ayala (C) 2001 address@hidden
!
! This project began based on code from the 2 projects below,
! and still contains some original code. The licenses of both must be
respected.
!
! XML-RPC for PHP
! originally by Edd Dumbill (C) 1999-2000
!
! SOAP for PHP
! by Victor Zou (C) 2000-2001 <address@hidden>
!
! this is a class that loads a wsdl file and makes it's data available to
an application
! it should provide methods that allow both client and server usage of it
!
! also should have methods for creating a wsdl file from scratch and
! serializing wsdl into valid markup
! */
! /* $Id$ */
!
! class wsdl
! {
! // constructor
! function wsdl($wsdl=False)
! {
! // define internal arrays of bindings, ports,
operations, messages, etc.
! $this->complexTypes = array();
! $this->messages = array();
! $this->currentMessage;
! $this->portOperations = array();
! $this->currentOperation;
! $this->portTypes = array();
! $this->currentPortType;
! $this->bindings = array();
! $this->currentBinding;
! // debug switch
! $this->debug_flag = False;
! // parser vars
! $this->parser;
! $this->position;
! $this->depth;
! $this->depth_array = array();
!
! if($wsdl == "-1")
! {
! $wsdl=False;
! }
! // Check whether content has been read.
! if($wsdl)
! {
! $wsdl_string = join("",file($wsdl));
! // Create an XML parser.
! $this->parser = xml_parser_create();
! // Set the options for parsing the XML data.
! //xml_parser_set_option($parser,
XML_OPTION_SKIP_WHITE, 1);
! xml_parser_set_option($this->parser,
XML_OPTION_CASE_FOLDING, 0);
! // 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');
!
! // Parse the XML file.
! if(!xml_parse($this->parser,$wsdl_string,True))
! {
! // Display an error message.
! $this->debug(sprintf('XML error on line
%d: %s',
!
xml_get_current_line_number($this->parser),
!
xml_error_string(xml_get_error_code($this->parser))));
! $this->fault = True;
! }
! xml_parser_free($this->parser);
! }
! }
!
! // start-element handler
! function start_element($parser, $name, $attrs)
! {
! // position in the total number of elements, starting
from 0
! $pos = $this->position++;
! $depth = $this->depth++;
! // set self as current value for this depth
! $this->depth_array[$depth] = $pos;
!
! // find status, register data
! switch($this->status)
! {
! case 'types':
! switch($name)
! {
! case 'schema':
! $this->schema = True;
! break;
! case 'complexType':
! $this->currentElement =
$attrs['name'];
! $this->schemaStatus =
'complexType';
! break;
! case 'element':
!
$this->complexTypes[$this->currentElement]['elements'][$attrs['name']] = $attrs;
! break;
! case 'complexContent':
! break;
! case 'restriction':
!
$this->complexTypes[$this->currentElement]['restrictionBase'] = $attrs['base'];
! break;
! case 'sequence':
!
$this->complexTypes[$this->currentElement]['order'] = 'sequence';
! break;
! case "all":
!
$this->complexTypes[$this->currentElement]['order'] = 'all';
! break;
! case 'attribute':
! if($attrs['ref'])
! {
!
$this->complexTypes[$this->currentElement]['attrs'][$attrs['ref']] = $attrs;
! }
! elseif($attrs['name'])
! {
!
$this->complexTypes[$this->currentElement]['attrs'][$attrs['name']] = $attrs;
! }
! break;
! }
! break;
! case 'message':
! if($name == 'part')
! {
!
$this->messages[$this->currentMessage][$attrs['name']] = $attrs['type'];
! }
! break;
! case 'portType':
! switch($name)
! {
! case 'operation':
! $this->currentOperation
= $attrs['name'];
!
$this->portTypes[$this->currentPortType][$attrs['name']] =
$attrs['parameterOrder'];
! break;
! default:
!
$this->portOperations[$this->currentOperation][$name]= $attrs;
! break;
! }
! break;
! case 'binding':
! switch($name)
! {
! case 'soap:binding':
!
$this->bindings[$this->currentBinding] =
array_merge($this->bindings[$this->currentBinding],$attrs);
! break;
! case 'operation':
! $this->currentOperation
= $attrs['name'];
!
$this->bindings[$this->currentBinding]['operations'][$attrs['name']] = array();
! break;
! case 'soap:operation':
!
$this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['soapAction']
= $attrs['soapAction'];
! break;
! case 'input':
! $this->opStatus =
'input';
! case 'soap:body':
!
$this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus]
= $attrs;
! break;
! case 'output':
! $this->opStatus =
'output';
! break;
! }
! break;
! case 'service':
! switch($name)
! {
! case 'port':
! $this->currentPort =
$attrs['name'];
!
$this->ports[$attrs['name']] = $attrs;
! break;
! case 'soap:address':
!
$this->ports[$this->currentPort]['location'] = $attrs['location'];
! break;
! }
! break;
! }
! // set status
! switch($name)
! {
! case 'types':
! $this->status = 'types';
! break;
! case 'message':
! $this->status = 'message';
! $this->messages[$attrs['name']] =
array();
! $this->currentMessage = $attrs['name'];
! break;
! case 'portType':
! $this->status = 'portType';
! $this->portTypes[$attrs['name']] =
array();
! $this->currentPortType = $attrs['name'];
! break;
! case 'binding':
! $this->status = 'binding';
! $this->currentBinding = $attrs['name'];
! $this->bindings[$attrs['name']]['type']
= $attrs['type'];
! break;
! case 'service':
! $this->status = 'service';
! break;
! }
! // get element prefix
! if(ereg(":",$name))
! {
! $prefix = substr($name,0,strpos($name,':'));
! }
! }
!
! function getEndpoint($portName)
! {
! if($endpoint = $this->ports[$portName]['location'])
! {
! return $endpoint;
! }
! return False;
! }
!
! function getPortName($operation)
! {
! @reset($this->ports);
! while(list($port,$portAttrs) = @each($this->ports));
! /* foreach($this->ports as $port => $portAttrs) */
! {
! $binding = substr($portAttrs['binding'],4);
! @reset($this->bindings[$binding]['operations']);
! while(list($op,$opAttrs) =
@each($this->bindings[$binding]['operations']))
! /*
foreach($this->bindings[$binding]["operations"] as $op => $opAttrs) */
! {
! if($op == $operation)
! {
! return $port;
! }
! }
! }
! }
!
! function getSoapAction($portName,$operation)
! {
! if($binding =
substr($this->ports[$portName]['binding'],4))
! {
! if($soapAction =
$this->bindings[$binding]['operations'][$operation]['soapAction'])
! {
! return $soapAction;
! }
! return False;
! }
! return False;
! }
!
! function getNamespace($portName,$operation)
! {
! if($binding =
substr($this->ports[$portName]['binding'],4))
! {
! //$this->debug("looking for namespace using
binding '$binding', port '$portName', operation '$operation'");
! if($namespace =
$this->bindings[$binding]['operations'][$operation]['input']['namespace'])
! {
! return $namespace;
! }
! return False;
! }
! return False;
! }
!
! // end-element handler
! function end_element($parser, $name)
! {
! // position of current element is equal to the last
value left in depth_array for my depth
! $pos = $this->depth_array[$this->depth];
! // bring depth down a notch
! $this->depth--;
! }
!
! // element content handler
! function character_data($parser, $data)
! {
! $pos = $this->depth_array[$this->depth];
! $this->message[$pos]['cdata'] .= $data;
! }
!
! function debug($string)
! {
! if($this->debug_flag)
! {
! $this->debug_str .= "$string\n";
! }
! }
! }
! ?>
Index: soaplib.soapinterop.php
===================================================================
RCS file: /cvsroot/phpgroupware/phpgwapi/inc/soaplib.soapinterop.php,v
retrieving revision 1.4
retrieving revision 1.4.4.1
diff -C2 -r1.4 -r1.4.4.1
*** soaplib.soapinterop.php 10 Dec 2001 02:09:17 -0000 1.4
--- soaplib.soapinterop.php 30 May 2003 02:34:26 -0000 1.4.4.1
***************
*** 1,152 ****
! <?php
!
/**************************************************************************\
! * phpGroupWare API - SOAP functions
*
! * This file written by address@hidden *
! * shared functions and vars for use with soap client/server
*
! *
-------------------------------------------------------------------------*
! * This library is free software; you can redistribute it and/or modify
it *
! * under the terms of the GNU Lesser General Public License as published
by *
! * the Free Software Foundation; either version 2.1 of the License,
*
! * or any later version.
*
! * This library is distributed in the hope that it will be useful, but
*
! * WITHOUT ANY WARRANTY; without even the implied warranty of
*
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
! * See the GNU Lesser General Public License for more details.
*
! * You should have received a copy of the GNU Lesser General Public
License *
! * along with this library; if not, write to the Free Software
Foundation, *
! * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
!
\**************************************************************************/
!
! /* $Id$ */
!
! $GLOBALS['server']->add_to_map(
! 'hello',
! array('string'),
! array('string')
! );
! function hello($serverid)
! {
! return
CreateObject('soap.soapval','return','string',$GLOBALS['phpgw_info']['server']['site_title']);
! }
!
! $GLOBALS['server']->add_to_map(
! 'echoString',
! array('string'),
! array('string')
! );
! function echoString($inputString)
! {
! return
CreateObject('soap.soapval','return','string',$inputString);
! }
!
! $GLOBALS['server']->add_to_map(
! 'echoStringArray',
! array('array'),
! array('array')
! );
! function echoStringArray($inputStringArray)
! {
! return $inputStringArray;
! }
!
! $GLOBALS['server']->add_to_map(
! 'echoInteger',
! array('int'),
! array('int')
! );
! function echoInteger($inputInteger)
! {
! return $inputInteger;
! }
!
! $GLOBALS['server']->add_to_map(
! 'echoIntegerArray',
! array('array'),
! array('array')
! );
! function echoIntegerArray($inputIntegerArray)
! {
! return $inputIntegerArray;
! }
!
! $GLOBALS['server']->add_to_map(
! 'echoFloat',
! array('float'),
! array('float')
! );
! function echoFloat($inputFloat)
! {
! return $inputFloat;
! }
!
! $GLOBALS['server']->add_to_map(
! 'echoFloatArray',
! array('array'),
! array('array')
! );
! function echoFloatArray($inputFloatArray)
! {
! return $inputFloatArray;
! }
!
! $GLOBALS['server']->add_to_map(
! 'echoStruct',
! array('SOAPStruct'),
! array('SOAPStruct')
! );
! function echoStruct($inputStruct)
! {
! return $inputStruct;
! }
!
! $GLOBALS['server']->add_to_map(
! 'echoStructArray',
! array('array'),
! array('array')
! );
! function echoStructArray($inputStructArray)
! {
! return $inputStructArray;
! }
!
! $GLOBALS['server']->add_to_map(
! 'echoVoid',
! array(),
! array()
! );
! function echoVoid()
! {
! }
!
! $GLOBALS['server']->add_to_map(
! 'echoBase64',
! array('base64'),
! array('base64')
! );
! function echoBase64($b_encoded)
! {
! return base64_encode(base64_decode($b_encoded));
! }
!
! $GLOBALS['server']->add_to_map(
! 'echoDate',
! array('timeInstant'),
! array('timeInstant')
! );
! function echoDate($timeInstant)
! {
! return $timeInstant;
! }
!
! $GLOBALS['server']->add_to_map(
! 'system_auth',
! array('string','string','string'),
! array('array')
! );
!
! $GLOBALS['server']->add_to_map(
! 'system_auth_verify',
! array('string','string','string'),
! array('array')
! );
! ?>
--- 1,152 ----
! <?php
!
/**************************************************************************\
! * phpGroupWare API - SOAP functions
*
! * This file written by address@hidden *
! * shared functions and vars for use with soap client/server
*
! *
-------------------------------------------------------------------------*
! * This library is free software; you can redistribute it and/or modify
it *
! * under the terms of the GNU Lesser General Public License as published
by *
! * the Free Software Foundation; either version 2.1 of the License,
*
! * or any later version.
*
! * This library is distributed in the hope that it will be useful, but
*
! * WITHOUT ANY WARRANTY; without even the implied warranty of
*
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
! * See the GNU Lesser General Public License for more details.
*
! * You should have received a copy of the GNU Lesser General Public
License *
! * along with this library; if not, write to the Free Software
Foundation, *
! * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
!
\**************************************************************************/
!
! /* $Id$ */
!
! $GLOBALS['server']->add_to_map(
! 'hello',
! array('string'),
! array('string')
! );
! function hello($serverid)
! {
! return
CreateObject('soap.soapval','return','string',$GLOBALS['phpgw_info']['server']['site_title']);
! }
!
! $GLOBALS['server']->add_to_map(
! 'echoString',
! array('string'),
! array('string')
! );
! function echoString($inputString)
! {
! return
CreateObject('soap.soapval','return','string',$inputString);
! }
!
! $GLOBALS['server']->add_to_map(
! 'echoStringArray',
! array('array'),
! array('array')
! );
! function echoStringArray($inputStringArray)
! {
! return $inputStringArray;
! }
!
! $GLOBALS['server']->add_to_map(
! 'echoInteger',
! array('int'),
! array('int')
! );
! function echoInteger($inputInteger)
! {
! return $inputInteger;
! }
!
! $GLOBALS['server']->add_to_map(
! 'echoIntegerArray',
! array('array'),
! array('array')
! );
! function echoIntegerArray($inputIntegerArray)
! {
! return $inputIntegerArray;
! }
!
! $GLOBALS['server']->add_to_map(
! 'echoFloat',
! array('float'),
! array('float')
! );
! function echoFloat($inputFloat)
! {
! return $inputFloat;
! }
!
! $GLOBALS['server']->add_to_map(
! 'echoFloatArray',
! array('array'),
! array('array')
! );
! function echoFloatArray($inputFloatArray)
! {
! return $inputFloatArray;
! }
!
! $GLOBALS['server']->add_to_map(
! 'echoStruct',
! array('SOAPStruct'),
! array('SOAPStruct')
! );
! function echoStruct($inputStruct)
! {
! return $inputStruct;
! }
!
! $GLOBALS['server']->add_to_map(
! 'echoStructArray',
! array('array'),
! array('array')
! );
! function echoStructArray($inputStructArray)
! {
! return $inputStructArray;
! }
!
! $GLOBALS['server']->add_to_map(
! 'echoVoid',
! array(),
! array()
! );
! function echoVoid()
! {
! }
!
! $GLOBALS['server']->add_to_map(
! 'echoBase64',
! array('base64'),
! array('base64')
! );
! function echoBase64($b_encoded)
! {
! return base64_encode(base64_decode($b_encoded));
! }
!
! $GLOBALS['server']->add_to_map(
! 'echoDate',
! array('timeInstant'),
! array('timeInstant')
! );
! function echoDate($timeInstant)
! {
! return $timeInstant;
! }
!
! $GLOBALS['server']->add_to_map(
! 'system_auth',
! array('string','string','string'),
! array('array')
! );
!
! $GLOBALS['server']->add_to_map(
! 'system_auth_verify',
! array('string','string','string'),
! array('array')
! );
! ?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] CVS: phpgwapi/inc class.common.inc.php,1.123.2.9.2.8,1.123.2.9.2.9 class.soap_client.inc.php,1.6,1.6.4.1class.soap_parser.inc.php,1.5,1.5.4.1 class.soap_server.inc.php,1.10,1.10.4.1 class.soapclient.inc.php,1.7,1.7.4.1 class.soapmsg.inc.php,1.8,1.8.4.1 class.soapval.inc.php,1.8,1.8.4.1 class.wsdl.inc.php,1.3,1.3.4.1 soaplib.soapinterop.php,1.4,1.4.4.1,
Dave Hall <address@hidden> <=
- Prev by Date:
[Phpgroupware-cvs] CVS: phpgwapi/templates/idots head.inc.php,1.1.2.6,1.1.2.7 head.tpl,1.1.2.1,1.1.2.2 login.tpl,1.1.2.1,1.1.2.2
- Next by Date:
[Phpgroupware-cvs] CVS: phpgwapi/templates/justweb about_unknown.tpl,1.2,1.2.8.1 head.inc.php,1.13.2.2.2.4,1.13.2.2.2.5 head.tpl,1.9.2.1.2.1,1.9.2.1.2.2 login_denylogin.tpl,1.1,1.1.10.1 navbar_app.tpl,1.1,1.1.10.1 navcond.js,1.1,1.1.10.1 portal_linkbox.tpl,1.1,1.1.10.1portal_linkbox_footer.tpl,1.1,1.1.10.1 portal_linkbox_header.tpl,1.1,1.1.10.1 portal_main.tpl,1.1,1.1.10.1
- Previous by thread:
[Phpgroupware-cvs] CVS: phpgwapi/templates/idots head.inc.php,1.1.2.6,1.1.2.7 head.tpl,1.1.2.1,1.1.2.2 login.tpl,1.1.2.1,1.1.2.2
- Next by thread:
[Phpgroupware-cvs] CVS: phpgwapi/templates/justweb about_unknown.tpl,1.2,1.2.8.1 head.inc.php,1.13.2.2.2.4,1.13.2.2.2.5 head.tpl,1.9.2.1.2.1,1.9.2.1.2.2 login_denylogin.tpl,1.1,1.1.10.1 navbar_app.tpl,1.1,1.1.10.1 navcond.js,1.1,1.1.10.1 portal_linkbox.tpl,1.1,1.1.10.1portal_linkbox_footer.tpl,1.1,1.1.10.1 portal_linkbox_header.tpl,1.1,1.1.10.1 portal_main.tpl,1.1,1.1.10.1
- Index(es):