cvs: pear /SOAP Client.php Message.php Parser.php Server.php Transport.php Value.php WSDL.php globals.php package.xml /SOAP/Transport HTTP.php
SMTP.php /SOAP/Type dateTime.php /SOAP/interop client_params.php client_round2_base.php interop.php server_soapinterop_groupB.php

From: Date: Mon, 25 Feb 2002 05:06:38 +0000
Subject: cvs: pear /SOAP Client.php Message.php Parser.php Server.php Transport.php Value.php WSDL.php globals.php package.xml /SOAP/Transport HTTP.php
SMTP.php /SOAP/Type dateTime.php /SOAP/interop client_params.php client_round2_base.php interop.php server_soapinterop_groupB.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-2606@lists.php.net to get a copy of this message
shane Mon Feb 25 00:06:38 2002 EDT Added files: /pear/SOAP/interop server_soapinterop_groupB.php Modified files: /pear/SOAP Client.php Message.php Parser.php Server.php Transport.php Value.php WSDL.php globals.php package.xml /pear/SOAP/Transport HTTP.php SMTP.php /pear/SOAP/Type dateTime.php /pear/SOAP/interop client_params.php client_round2_base.php interop.php Log: add multi-dimensional array support sparse arrays not yet supported offsets need testing add multi-reference support add test directory with test cases for soap protocol add server support for GroupB interop tests generaly improve interop

Index: pear/SOAP/Client.php diff -u pear/SOAP/Client.php:1.4 pear/SOAP/Client.php:1.5 --- pear/SOAP/Client.php:1.4 Tue Feb 19 20:20:54 2002 +++ pear/SOAP/Client.php Mon Feb 25 00:06:35 2002 @@ -17,7 +17,7 @@ // | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author | // +----------------------------------------------------------------------+ // -// $Id: Client.php,v 1.4 2002/02/20 01:20:54 ssb Exp $ +// $Id: Client.php,v 1.5 2002/02/25 05:06:35 shane Exp $ // require_once "PEAR.php"; require_once "SOAP/Transport.php"; @@ -36,7 +36,7 @@ * originaly based on SOAPx4 by Dietrich Ayala http://dietrich.ganx4.com/soapx4 * * @access public -* @version $Id: Client.php,v 1.4 2002/02/20 01:20:54 ssb Exp $ +* @version $Id: Client.php,v 1.5 2002/02/25 05:06:35 shane Exp $ * @package SOAP::Client * @author Shane Caraveo <shane@php.net> Conversion to PEAR and updates * @author Stig Bakken <ssb@fast.no> Conversion to PEAR @@ -161,10 +161,10 @@ $dbg = "sending msg w/ soapaction '$soapAction'..."; $soap_data = $soapmsg->serialize(); - if ($soap_transport->send($this->response,$soap_data,$soapAction)) { + $result = $soap_transport->send($this->response,$soap_data,$soapAction); + if ($result && !PEAR::isError($result)) { // parse the response $return = $soapmsg->parseResponse($this->response); - $this->debug($soap_transport->debug_str); $this->debug($dbg."sent message successfully and got a(n) ".gettype($return)." back"); // check for valid response @@ -173,14 +173,14 @@ $returnArray = $return->decode(); // fault? if (is_array($returnArray)) { - if (isset($returnArray['faultcode'])) { + if (isset($returnArray['faultcode']) || isset($returnArray['SOAP-ENV:faultcode'])) { $this->debug('got fault'); $this->fault = true; foreach ($returnArray as $k => $v) { //print "$k = $v<br>"; - if ($k == 'faultcode') $this->faultcode = $v; - if ($k == 'faultstring') $this->faultstring = $v; - if ($k == 'faultdetail') $this->faultdetail = $v; + if (stristr($k,'faultcode')) $this->faultcode = $v; + if (stristr($k,'faultstring')) $this->faultstring = $v; + if (stristr($k,'faultdetail')) $this->faultdetail = $v; $this->debug("$k = $v<br>"); } return false; Index: pear/SOAP/Message.php diff -u pear/SOAP/Message.php:1.4 pear/SOAP/Message.php:1.5 --- pear/SOAP/Message.php:1.4 Tue Feb 19 20:45:42 2002 +++ pear/SOAP/Message.php Mon Feb 25 00:06:36 2002 @@ -17,7 +17,7 @@ // | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author | // +----------------------------------------------------------------------+ // -// $Id: Message.php,v 1.4 2002/02/20 01:45:42 ssb Exp $ +// $Id: Message.php,v 1.5 2002/02/25 05:06:36 shane Exp $ // require_once("SOAP/globals.php"); require_once("SOAP/Parser.php"); @@ -30,7 +30,7 @@ * originaly based on SOAPx4 by Dietrich Ayala http://dietrich.ganx4.com/soapx4 * * @access public -* @version $Id: Message.php,v 1.4 2002/02/20 01:45:42 ssb Exp $ +* @version $Id: Message.php,v 1.5 2002/02/25 05:06:36 shane Exp $ * @package SOAP::Message * @author Shane Caraveo <shane@php.net> Conversion to PEAR and updates * @author Dietrich Ayala <dietrich@ganx4.com> Original Author @@ -79,13 +79,12 @@ */ function _makeEnvelope($payload) { - global $SOAP_SchemaEncoding; global $SOAP_namespaces; $ns_string = ""; foreach ($SOAP_namespaces as $k => $v) { - $ns_string .= "xmlns:$v=\"$k\" "; + $ns_string .= "xmlns:$v=\"$k\"\n "; } - return "<SOAP-ENV:Envelope $ns_string SOAP-ENV:encodingStyle=\"$SOAP_SchemaEncoding\">\n". + return "<SOAP-ENV:Envelope $ns_string SOAP-ENV:encodingStyle=\"".SOAP_SCHEMA_ENCODING."\">\n". $payload. "</SOAP-ENV:Envelope>\n"; } @@ -113,7 +112,7 @@ $value = $this->value; $payload = $this->_makeEnvelope($this->_makeBody($value->serialize())); $this->debug($value->debug_str); - $payload = "<?xml version=\"1.0\"?>\n".$payload; + $payload = "<?xml version=\"1.0\"?>\n\n".$payload; if ($this->debug_flag) { $payload .= $this->serializeDebug(); } Index: pear/SOAP/Parser.php diff -u pear/SOAP/Parser.php:1.3 pear/SOAP/Parser.php:1.4 --- pear/SOAP/Parser.php:1.3 Tue Feb 19 20:45:42 2002 +++ pear/SOAP/Parser.php Mon Feb 25 00:06:36 2002 @@ -17,7 +17,7 @@ // | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author | // +----------------------------------------------------------------------+ // -// $Id: Parser.php,v 1.3 2002/02/20 01:45:42 ssb Exp $ +// $Id: Parser.php,v 1.4 2002/02/25 05:06:36 shane Exp $ // require_once("SOAP/globals.php"); require_once("SOAP/Value.php"); @@ -29,7 +29,7 @@ * originaly based on SOAPx4 by Dietrich Ayala http://dietrich.ganx4.com/soapx4 * * @access public -* @version $Id: Parser.php,v 1.3 2002/02/20 01:45:42 ssb Exp $ +* @version $Id: Parser.php,v 1.4 2002/02/25 05:06:36 shane Exp $ * @package SOAP::Parser * @author Shane Caraveo <shane@php.net> Conversion to PEAR and updates * @author Dietrich Ayala <dietrich@ganx4.com> Original Author @@ -59,9 +59,13 @@ var $xml = ""; var $xml_encoding = ""; var $root_struct = ""; - + var $references = array(); + var $need_references = array(); + var $XMLSchemaVersion; + function SOAP_Parser($xml,$encoding="UTF-8") { + $this->setSchemaVersion(SOAP_XML_SCHEMA_VERSION); //global $soapTypes; //$this->soapTypes = $soapTypes; $this->xml = $xml; @@ -101,6 +105,16 @@ } } + function setSchemaVersion($schemaVersion) + { + global $SOAP_namespaces; + $this->XMLSchemaVersion = $schemaVersion; + $tmpNS = array_flip($SOAP_namespaces); + $tmpNS["xsd"] = $this->XMLSchemaVersion; + $tmpNS["xsi"] = $this->XMLSchemaVersion."-instance"; + $SOAP_namespaces = array_flip($tmpNS); + } + // loop through msg, building response structures function buildResponse($pos) { @@ -116,6 +130,39 @@ $response[] = $this->buildResponse($child_pos); } } + if (array_key_exists('arraySize',$this->message[$pos])) { + $ardepth = count($this->message[$pos]['arraySize']); + if ($ardepth > 1) { + $ar = array_pad(array(), $ardepth, 0); + if (array_key_exists('arrayOffset',$this->message[$pos])) { + for ($i = 0; $i < $ardepth; $i++) { + $ar[$i] += $this->message[$pos]['arrayOffset'][$i]; + } + } + $elc = count($response); + for ($i = 0; $i < $elc; $i++) { + $al = "\$newresp"; + for ($ad = 0; $ad < $ardepth; $ad++) { + $al .= "[".($ar[$ad])."]"; + } + eval("$al = \$response[".$i."];"); + + # increment our array pointers + $ad = $ardepth - 1; + $ar[$ad]++; + while ($ad > 0 && $ar[$ad] >= $this->message[$pos]['arraySize'][$ad]) { + $ar[$ad] = 0; + $ad--; + $ar[$ad]++; + } + } + $response = $newresp; + } else if ($this->message[$pos]['arrayOffset'][0] > 0) { + # check for padding + $pad = $this->message[$pos]['arrayOffset'][0]+count($response)*-1; + $response = array_pad($response,$pad,NULL); + } + } } // add current node's value if ($response) { @@ -155,22 +202,32 @@ $this->parent = $pos; // set status - if (preg_match("/:Envelope$/",$name)) { + if (preg_match("/:Envelope$/i",$name)) { $this->status = "envelope"; - } elseif (preg_match("/:Header$/",$name)) { + } elseif (preg_match("/:Header$/i",$name)) { $this->status = "header"; - } elseif (preg_match("/:Body$/",$name)) { + } elseif (preg_match("/:Body$/i",$name)) { $this->status = "body"; // set method } elseif ($this->status == "body") { + // is this element allowed to be a root? + // XXX this needs to be optimized, we loop through attrs twice now + $can_root = TRUE; + foreach ($attrs as $key => $value) { + if (preg_match('/:root$/i', $key) && !$value) { + $can_root = FALSE; + } + } $this->status = "method"; - if (strpos($name,":") !== false) { - $this->root_struct_name = substr(strrchr($name,":"),1); - } else { - $this->root_struct_name = $name; + if ($can_root) { + if (strpos($name,":") !== false) { + $this->root_struct_name = substr(strrchr($name,":"),1); + } else { + $this->root_struct_name = $name; + } + $this->root_struct = $pos; + $this->message[$pos]["type"] = "struct"; } - $this->root_struct = $pos; - $this->message[$pos]["type"] = "struct"; } // set my status $this->message[$pos]["status"] = $this->status; @@ -190,15 +247,10 @@ // loop through atts, logging ns and type declarations foreach ($attrs as $key => $value) { // if ns declarations, add to class level array of valid namespaces - if (strstr($key,"xmlns:")) { + if (preg_match('/^xmlns:/i',$key)) { $prefix = substr(strrchr($key,":"),1); if ($prefix == "xsd") { - global $SOAP_XMLSchemaVersion,$SOAP_namespaces; - $SOAP_XMLSchemaVersion = $value; - $tmpNS = array_flip($SOAP_namespaces); - $tmpNS["xsd"] = $SOAP_XMLSchemaVersion; - $tmpNS["xsi"] = $SOAP_XMLSchemaVersion."-instance"; - $SOAP_namespaces = array_flip($tmpNS); + $this->setSchemaVersion($value); } $this->namespaces[substr(strrchr($key,":"),1)] = $value; // set method namespace @@ -206,14 +258,40 @@ $this->methodNamespace = $value; } // if it's a type declaration, set type - } elseif ($key == "xsi:type") { + } elseif (preg_match('/:type$/i',$key)) { $type = substr(strrchr($value,":"),1); if (!$type) $type = $value; $this->message[$pos]["type"] = $type; #print "set type for {$this->message[$pos]['name']} to {$this->message[$pos]['type']}\n"; // should do something here with the namespace of specified type? - } elseif ($key == "SOAP-ENC:arrayType") { + } elseif (preg_match('/:arrayType$/i',$key)) { $this->message[$pos]['type'] = 'array'; + $type = substr(strrchr($value,':'),1); + if (!$type) $type = $value; + $sa = strpos($type,'['); + if ($sa > 0) { + $this->message[$pos]['arraySize'] = split(',',substr($type,$sa+1, strlen($type)-$sa-2)); + $type = substr($type, 0, $sa); + } + $this->message[$pos]['arrayType'] = $type; + } elseif (preg_match('/:offset$/i',$key)) { + $this->message[$pos]['arrayOffset'] = split(',',substr($value, 1, strlen($value)-2)); + } elseif ($key == 'id') { + # save id to reference array + $this->references[$value] = $pos; + $this->message[$pos]['id'] = $value; + } elseif ($key == 'href' && $value[0] == '#') { + $ref = substr($value, 1); + if (array_key_exists($ref,$this->references)) { + # cdata, type, inval + $ref_pos = $this->references[$ref]; + $this->message[$pos]['cdata'] = &$this->message[$ref_pos]['cdata']; + $this->message[$pos]['type'] = &$this->message[$ref_pos]['type']; + $this->message[$pos]['inval'] = &$this->message[$ref_pos]['inval']; + } else { + # reverse reference, store in 'need reference' + $this->need_references[$ref][] = $pos; + } } } } @@ -227,12 +305,18 @@ $this->depth--; // get type if not explicitly declared in an xsi:type attribute - // man is this fucked up. can't do wsdl like dis! - if ($this->message[$pos]["type"] == "") { - if ($this->message[$pos]["children"] != "") { - $this->message[$pos]["type"] = "struct"; + // XXX check on integrating wsdl validation here + if ($this->message[$pos]['type'] == "") { + if ($this->message[$pos]['children'] != "") { + $this->message[$pos]['type'] = 'struct'; } else { - $this->message[$pos]["type"] = "string"; + $parent = $this->message[$pos]['parent']; + if ($this->message[$parent]['type'] == 'array' && + array_key_exists('arrayType', $this->message[$parent])) { + $this->message[$pos]['type'] = $this->message[$parent]['arrayType']; + } else { + $this->message[$pos]['type'] = 'string'; + } } } @@ -257,6 +341,20 @@ $this->parent = $this->message[$pos]["parent"]; $this->debug("parsed $name end, type '".$this->message[$pos]["type"]."' children = ".$this->message[$pos]["children"]); #print ("parsed $name end, type '".$this->message[$pos]["type"]."' children = ".$this->message[$pos]["children"]."\n"); + + # handle any reverse references now + $idref = $this->message[$pos]['id']; + if ($idref != "" && array_key_exists($idref,$this->need_references)) { + foreach ($this->need_references[$idref] as $ref_pos) { + #XXX is this stuff there already? + $this->message[$ref_pos]['children'] = &$this->message[$pos]['children']; + $this->message[$ref_pos]['cdata'] = &$this->message[$pos]['cdata']; + $this->message[$ref_pos]['type'] = &$this->message[$pos]['type']; + $this->message[$ref_pos]['inval'] = &$this->message[$pos]['inval']; + } + # wipe out our waiting list + $this->need_references[$idref] = array(); + } } // element content handler Index: pear/SOAP/Server.php diff -u pear/SOAP/Server.php:1.3 pear/SOAP/Server.php:1.4 --- pear/SOAP/Server.php:1.3 Tue Feb 19 20:45:42 2002 +++ pear/SOAP/Server.php Mon Feb 25 00:06:36 2002 @@ -17,7 +17,7 @@ // | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author | // +----------------------------------------------------------------------+ // -// $Id: Server.php,v 1.3 2002/02/20 01:45:42 ssb Exp $ +// $Id: Server.php,v 1.4 2002/02/25 05:06:36 shane Exp $ // require_once("SOAP/globals.php"); require_once("SOAP/Parser.php"); @@ -34,7 +34,7 @@ * originaly based on SOAPx4 by Dietrich Ayala http://dietrich.ganx4.com/soapx4 * * @access public -* @version $Id: Server.php,v 1.3 2002/02/20 01:45:42 ssb Exp $ +* @version $Id: Server.php,v 1.4 2002/02/25 05:06:36 shane Exp $ * @package SOAP::Client * @author Shane Caraveo <shane@php.net> Conversion to PEAR and updates * @author Dietrich Ayala <dietrich@ganx4.com> Original Author @@ -60,7 +60,6 @@ // parses request and posts response function service($data) { - global $SOAP_LibraryName; // $response is a soap_msg object $response = $this->parseRequest($data); $this->debug("parsed request and got an object of this class '".get_class($response)."'"); @@ -78,7 +77,7 @@ //$header[] = "HTTP/1.0 200 OK\r\n"; $header[] = "Status: 200 OK\r\n"; } - $header[] = "Server: $SOAP_LibraryName\r\n"; + $header[] = "Server: ".SOAP_LIBRARY_NAME."\r\n"; $header[] = "Connection: Close\r\n"; $header[] = "Content-Type: text/xml; charset=$this->xml_encoding\r\n"; $header[] = "Content-Length: ".strlen($payload)."\r\n\r\n"; @@ -151,11 +150,11 @@ /* set namespaces if ($parser->namespaces["xsd"] != "") { //print "got ".$parser->namespaces["xsd"]; - global $SOAP_XMLSchemaVersion,$SOAP_namespaces; - $SOAP_XMLSchemaVersion = $parser->namespaces["xsd"]; + global $SOAP_namespaces; + $this->XMLSchemaVersion = $parser->namespaces["xsd"]; $tmpNS = array_flip($SOAP_namespaces); - $tmpNS["xsd"] = $SOAP_XMLSchemaVersion; - $tmpNS["xsi"] = $SOAP_XMLSchemaVersion."-instance"; + $tmpNS["xsd"] = $this->XMLSchemaVersion; + $tmpNS["xsi"] = $this->XMLSchemaVersion."-instance"; $SOAP_namespaces = array_flip($tmpNS); }*/ if (strcasecmp(get_class($request_val),"SOAP_Value")==0) { @@ -190,18 +189,33 @@ } else { // if return val is SOAP_Value object if (strcasecmp(get_class($method_response),"SOAP_Value")==0) { - $return_val = $method_response; + $return_val = array($method_response); // create soap_val object w/ return values from method, use method signature to determine type } else { $this->debug("creating new SOAP_Value to return, of type $this->return_type"); - $return_val = new SOAP_Value($this->methodname,$this->return_type,$method_response); + if (is_array($this->return_type) && is_array($method_response)) { + $i = 0; + foreach ($this->return_type as $key => $type) { + if (is_numeric($key)) $key = "item"; + $return_val[] = new SOAP_Value($key,$type,$method_response[$i++]); + } + } else { + $return_name = 'return'; + if (is_array($this->return_type)) { + $keys = array_keys($this->return_type); + if (!is_numeric($keys[0])) $return_name = $keys[0]; + $values = array_values($this->return_type); + $this->return_type = $values[0]; + } + $return_val = array(new SOAP_Value($return_name,$this->return_type,$method_response)); + } } if ($this->debug_flag) { $this->debug($return_val->debug_str); } $this->debug("creating return soap_msg object: ".$this->methodname."Response"); // response object is a soap_msg object - $return_msg = new SOAP_Message($this->methodname."Response",array($return_val),"$this->service"); + $return_msg = new SOAP_Message($this->methodname."Response",$return_val,"$this->service"); } if ($this->debug_flag) { $return_msg->debug_flag = true; @@ -228,7 +242,7 @@ function verifyMethod($request) { - global $SOAP_typemap, $SOAP_XMLSchemaVersion; + global $SOAP_typemap; //return true; $this->debug("entered verifyMethod() w/ request name: ".$request->name); $params = $request->value; @@ -250,21 +264,22 @@ foreach ($params as $param) { $p[] = strtolower($param->type); } + $sig_t = array_values($sig); // validate each param's type for($i=0; $i < count($p); $i++) { // type not match // if soap types do not match, we ok it if the mapped php types match // this allows using plain php variables to work (ie. stuff like Decimal would fail otherwise) // XXX we should do further validation of the value of the type - if (strtolower($sig[$i]) != strtolower($p[$i]) && - !(isset($SOAP_typemap[$SOAP_XMLSchemaVersion][$sig[$i]]) && - strtolower($SOAP_typemap[$SOAP_XMLSchemaVersion][$sig[$i]]) == strtolower($SOAP_typemap[$SOAP_XMLSchemaVersion][$p[$i]]))) { + if (strcasecmp($sig_t[$i],$p[$i])!=0 && + !(isset($SOAP_typemap[SOAP_XML_SCHEMA_VERSION][$sig_t[$i]]) && + strcasecmp($SOAP_typemap[SOAP_XML_SCHEMA_VERSION][$sig_t[$i]],$SOAP_typemap[SOAP_XML_SCHEMA_VERSION][$p[$i]])==0)) { $param = $params[$i]; - $this->debug("mismatched parameter types: $sig[$i] != $p[$i]"); - $this->makeFault("Client","soap request contained mismatching parameters of name $param->name had type $p[$i], which did not match signature's type: $sig[$i]"); + $this->debug("mismatched parameter types: [{$sig_t[$i]}] != [{$p[$i]}]"); + $this->makeFault("Client","soap request contained mismatching parameters of name $param->name had type [{$p[$i]}], which did not match signature's type: [{$sig_t[$i]}], matched? ".(strcasecmp($sig_t[$i],$p[$i]))); return false; } - $this->debug("parameter type match: $sig[$i] = $p[$i]"); + $this->debug("parameter type match: $sig_t[$i] = $p[$i]"); } return true; // oops, wrong number of paramss @@ -291,8 +306,12 @@ // get string return type from dispatch map function getReturnType() { - if (count($this->dispatch_map[$this->methodname]["out"]) >= 1) { - $type = array_shift($this->dispatch_map[$this->methodname]["out"]); + if (is_array($this->dispatch_map[$this->methodname]['out'])) { + if (count($this->dispatch_map[$this->methodname]['out']) > 1) { + $this->debug("got multiple return types from dispatch map: '$type'"); + return $this->dispatch_map[$this->methodname]['out']; + } + $type = array_shift($this->dispatch_map[$this->methodname]['out']); $this->debug("got return type from dispatch map: '$type'"); return $type; } Index: pear/SOAP/Transport.php diff -u pear/SOAP/Transport.php:1.3 pear/SOAP/Transport.php:1.4 --- pear/SOAP/Transport.php:1.3 Sat Feb 23 14:57:25 2002 +++ pear/SOAP/Transport.php Mon Feb 25 00:06:36 2002 @@ -17,9 +17,9 @@ // | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author | // +----------------------------------------------------------------------+ // -// $Id: Transport.php,v 1.3 2002/02/23 19:57:25 shane Exp $ +// $Id: Transport.php,v 1.4 2002/02/25 05:06:36 shane Exp $ // - +require_once("PEAR.php"); /** * SOAP Transport Layer * This layer can use different protocols dependant on the endpoint url provided @@ -27,11 +27,11 @@ * no knowlege of the transport protocols is available at this level * * @access public -* @version $Id: Transport.php,v 1.3 2002/02/23 19:57:25 shane Exp $ +* @version $Id: Transport.php,v 1.4 2002/02/25 05:06:36 shane Exp $ * @package SOAP::Transport * @author Shane Caraveo <shane@php.net> */ -class SOAP_Transport +class SOAP_Transport extends PEAR { var $transport = NULL; var $outgoing_payload = ""; @@ -75,16 +75,16 @@ */ function send(&$response, &$soap_data, $action = "", $timeout=0) { - if (!$this->transport) return FALSE; + if (!$this->transport) return $this->raiseError($this->errmsg, -1); if (!$this->transport->send($soap_data, $response, $action, $timeout)) { $this->errmsg = $this->transport->errmsg; - return FALSE; + return $this->raiseError($this->transport->errmsg, -1); } $this->outgoing_payload = $this->transport->outgoing_payload; - #echo "\n OUTGOING: ".$this->transport->outgoing_payload."\n\n"; + echo "\n OUTGOING: ".$this->transport->outgoing_payload."\n\n"; #echo "\n INCOMING: ".$this->transport->incoming_payload."\n\n"; - #echo "\n INCOMING: ".preg_replace("/>/","/>\n/",$this->transport->incoming_payload)."\n\n"; + echo "\n INCOMING: ".preg_replace("/>/",">\n",$this->transport->incoming_payload)."\n\n"; return TRUE; } Index: pear/SOAP/Value.php diff -u pear/SOAP/Value.php:1.7 pear/SOAP/Value.php:1.8 --- pear/SOAP/Value.php:1.7 Wed Feb 20 03:16:32 2002 +++ pear/SOAP/Value.php Mon Feb 25 00:06:36 2002 @@ -17,7 +17,7 @@ // | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author | // +----------------------------------------------------------------------+ // -// $Id: Value.php,v 1.7 2002/02/20 08:16:32 shane Exp $ +// $Id: Value.php,v 1.8 2002/02/25 05:06:36 shane Exp $ // require_once('SOAP/globals.php'); require_once('SOAP/Type/dateTime.php'); @@ -29,7 +29,7 @@ * originaly based on SOAPx4 by Dietrich Ayala http://dietrich.ganx4.com/soapx4 * * @access public -* @version $Id: Value.php,v 1.7 2002/02/20 08:16:32 shane Exp $ +* @version $Id: Value.php,v 1.8 2002/02/25 05:06:36 shane Exp $ * @package SOAP::Client * @author Shane Caraveo <shane@php.net> Conversion to PEAR and updates * @author Dietrich Ayala <dietrich@ganx4.com> Original Author @@ -52,7 +52,7 @@ function SOAP_Value($name="",$type=false,$value=-1,$namespace=false,$type_namespace=false) { - global $soapTypes, $SOAP_typemap, $SOAP_namespaces, $methodNamespace, $SOAP_XMLSchemaVersion; + global $soapTypes, $SOAP_typemap, $SOAP_namespaces, $methodNamespace; // detect type if not passed #print("Entering SOAP_Value - name: '$name' type: '$type' value: $value\n"); @@ -91,23 +91,23 @@ } // if scalar - if (in_array($this->type,$SOAP_typemap[$SOAP_XMLSchemaVersion])) { - $this->type_code = 1; + if (in_array($this->type,$SOAP_typemap[SOAP_XML_SCHEMA_VERSION])) { + $this->type_code = VALUE_SCALAR; $this->addScalar($value,$this->type,$name); // if array } elseif (strcasecmp("array",$this->type) == 0 || strcasecmp("ur-type",$this->type) == 0) { - $this->type_code = 2; + $this->type_code = VALUE_ARRAY; $this->addArray($value); // if struct } elseif (stristr($this->type,"struct")) { - $this->type_code = 3; + $this->type_code = VALUE_STRUCT; $this->addStruct($value); } elseif (is_array($value)) { - $this->type_code = 3; + $this->type_code = VALUE_STRUCT; $this->addStruct($value); } else { - $this->type_code = 1; + $this->type_code = VALUE_SCALAR; $this->addScalar($value,"string",$name); } } @@ -168,6 +168,42 @@ return true; } + function _getArrayType(&$value, &$type, &$size, &$xml) + { + foreach ($value as $array_val) { + $array_types[$array_val->type] = 1; + #$xml .= $this->serializeval($array_val); + } + if ($array_val->type_prefix) { + $type = $array_val->type_prefix.":".$array_val->type; + } else { + $type = $array_val->type; + } + $sz = count($value); + if (count($array_types) == 1) { + if (array_key_exists("array",$array_types)) { + // seems we have a multi dimensional array, figure it out if we do + foreach ($value as $array_val) { + $numtypes = $this->_getArrayType($array_val->value, $type, $size, $xml); + if ($numtypes > 1) return $numtypes; + } + if ($sz) { + $size = $sz.",".$size; + } else { + $size = $sz; + } + return 1; + } else { + foreach ($value as $array_val) { + #$array_types[$array_val->type] = 1; + $xml .= $this->serializeval($array_val); + } + } + } + $size = $sz; + return count($array_types); + } + // turn SOAP_Value's into xml, woohoo! function serializeval($soapval=false) { @@ -206,21 +242,32 @@ break; case 2: // array - 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) { - if ($array_val->type_prefix != "") { - $array_type = $array_val->type_prefix.":".$array_val->type; - } else { - $array_type = $array_val->type; + $offset =""; + // XXX this will be slow on larger array's. We can probably move this + // out to an external helper function. Basicly, it flattens array's to allow us + // to serialize multi-dimensional array's + $numtypes = $this->_getArrayType($soapval->value, $array_type, $ar_size, $xml); + #$numtypes = 0; + if ($numtypes != 1) { + $xml =""; + foreach ($soapval->value as $array_val) { + $array_types[$array_val->type] = 1; + $xml .= $this->serializeval($array_val); + } + $ar_size = count($soapval->value); + if (count($array_types) > 1) { + $array_type = "xsd:ur-type"; + } elseif (count($array_types) == 1) { + if ($array_val->type_prefix != "") { + $array_type = $array_val->type_prefix.":".$array_val->type; + } else { + $array_type = $array_val->type; + } } + $offset = " SOAP-ENC:offset=\"[0]\""; } - $xml = "<$soapval->name xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"".$array_type."[".sizeof($soapval->value)."]\">\n".$xml."</$soapval->name>\n"; + $xml = "<$soapval->name xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"".$array_type."[$ar_size]\"$offset>\n".$xml."</$soapval->name>\n"; break; case 1: if ($soapval->prefix && $soapval->type_prefix) { @@ -249,13 +296,13 @@ function decode($soapval=false) { - global $SOAP_XMLSchemaVersion, $SOAP_typemap; + global $SOAP_typemap; if (!$soapval) { $soapval = $this; } $this->debug("inside SOAP_Value->decode for $soapval->name of type $soapval->type and value: $soapval->value"); // scalar decode - if ($soapval->type_code == 1) { + if ($soapval->type_code == VALUE_SCALAR) { if ($soapval->type == "boolean") { #echo strcasecmp($soapval->value,"false"); if ($soapval->value != "0" && @@ -270,14 +317,14 @@ # # THOUGHT: we could return a class instead. # $dt = new SOAP_Type_dateTime($soapval->value); # $soapval->value = $dt->toUnixtime(); - } else if (in_array($soapval->type, $SOAP_typemap[$SOAP_XMLSchemaVersion], TRUE)) { + } else if (in_array($soapval->type, $SOAP_typemap[SOAP_XML_SCHEMA_VERSION], TRUE)) { # if we can, lets set php's variable type - settype($soapval->value,$SOAP_typemap[$SOAP_XMLSchemaVersion][$soapval->type]); + settype($soapval->value,$SOAP_typemap[SOAP_XML_SCHEMA_VERSION][$soapval->type]); } - #print "value: $soapval->value type: $soapval->type phptype: {$SOAP_typemap[$SOAP_XMLSchemaVersion][$soapval->type]}\n"; + #print "value: $soapval->value type: $soapval->type phptype: {$SOAP_typemap[SOAP_XML_SCHEMA_VERSION][$soapval->type]}\n"; return $soapval->value; // array decode - } elseif ($soapval->type_code == 2) { + } elseif ($soapval->type_code == VALUE_ARRAY) { if (is_array($soapval->value)) { foreach ($soapval->value as $item) { $return[] = $this->decode($item); @@ -286,12 +333,17 @@ } return $soapval->value; // struct decode - } elseif ($soapval->type_code == 3) { + } elseif ($soapval->type_code == VALUE_STRUCT) { if (is_array($soapval->value)) { $counter = 1; foreach ($soapval->value as $item) { if (isset($return[$item->name])) { - $return[$item->name.($counter++)] = $this->decode($item); + if (!is_array($return[$item->name])) { + $val = $return[$item->name]; + $return[$item->name] = array(); + $return[$item->name][] = $val; + } + $return[$item->name][] = $this->decode($item); } else { $return[$item->name] = $this->decode($item); } @@ -311,7 +363,7 @@ // pass it a type, and it attempts to return a namespace uri function verifyType($type) { - global $SOAP_typemap,$SOAP_namespaces,$SOAP_XMLSchemaVersion; + global $SOAP_typemap,$SOAP_namespaces; /*foreach ($SOAP_typemap as $namespace => $types) { if (is_array($types) && in_array($type,$types)) { return $namespace; Index: pear/SOAP/WSDL.php diff -u pear/SOAP/WSDL.php:1.4 pear/SOAP/WSDL.php:1.5 --- pear/SOAP/WSDL.php:1.4 Tue Feb 19 20:45:42 2002 +++ pear/SOAP/WSDL.php Mon Feb 25 00:06:36 2002 @@ -17,7 +17,7 @@ // | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author | // +----------------------------------------------------------------------+ // -// $Id: WSDL.php,v 1.4 2002/02/20 01:45:42 ssb Exp $ +// $Id: WSDL.php,v 1.5 2002/02/25 05:06:36 shane Exp $ // require_once("SOAP/globals.php"); @@ -33,7 +33,7 @@ * implement IDL type syntax declaration so we can generate WSDL * * @access public -* @version $Id: WSDL.php,v 1.4 2002/02/20 01:45:42 ssb Exp $ +* @version $Id: WSDL.php,v 1.5 2002/02/25 05:06:36 shane Exp $ * @package SOAP::Client * @author Shane Caraveo <shane@php.net> Conversion to PEAR and updates * @author Dietrich Ayala <dietrich@ganx4.com> Original Author @@ -95,7 +95,6 @@ // start-element handler function startElement($parser, $name, $attrs) { - global $SOAP_Schema; // position in the total number of elements, starting from 0 $pos = $this->position++; @@ -243,7 +242,7 @@ case "definitions": $this->wsdl_info = $attrs; foreach ($attrs as $name=>$value) { - if (strcasecmp($value,$SOAP_Schema)==0) { + if (strcasecmp($value,SOAP_SCHEMA)==0) { $s = split(":",$name); $this->soapns = $s[1]; break; Index: pear/SOAP/globals.php diff -u pear/SOAP/globals.php:1.2 pear/SOAP/globals.php:1.3 --- pear/SOAP/globals.php:1.2 Tue Feb 19 20:29:27 2002 +++ pear/SOAP/globals.php Mon Feb 25 00:06:36 2002 @@ -17,7 +17,7 @@ // | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author | // +----------------------------------------------------------------------+ // -// $Id: globals.php,v 1.2 2002/02/20 01:29:27 ssb Exp $ +// $Id: globals.php,v 1.3 2002/02/25 05:06:36 shane Exp $ // // make errors handle properly in windows (thx, thong@xmethods.com) error_reporting(2039); @@ -38,13 +38,19 @@ define("INF", 1.8e307); define("NAN", 0.0); -$SOAP_LibraryName = "PEAR-SOAPx4 0.6"; +# define types for value +define("VALUE_SCALAR",1); +define("VALUE_ARRAY",2); +define("VALUE_STRUCT",3); +define("SOAP_LIBRARY_NAME","PEAR-SOAPx4 0.6"); // set schema version -$SOAP_XMLSchemaVersion = "http://www.w3.org/2001/XMLSchema"; -$SOAP_Schema = "http://schemas.xmlsoap.org/wsdl/soap/"; -$SOAP_SchemaEncoding = "http://schemas.xmlsoap.org/soap/encoding/"; -$SOAP_InteropOrg = "http://soapinterop.org/xsd"; +define("SOAP_XML_SCHEMA_VERSION","http://www.w3.org/2001/XMLSchema"); +define("SOAP_XML_SCHEMA_1999","http://www.w3.org/1999/XMLSchema"); +define("SOAP_SCHEMA","http://schemas.xmlsoap.org/wsdl/soap/"); +define("SOAP_SCHEMA_ENCODING","http://schemas.xmlsoap.org/soap/encoding/"); +define("SOAP_ENVELOP","http://schemas.xmlsoap.org/soap/envelope/"); +define("SOAP_INTEROPORG","http://soapinterop.org/xsd"); // load types into typemap array /* @@ -59,10 +65,10 @@ $SOAP_typemap["http://www.w3.org/1999/XMLSchema"] = array( "i4","int","boolean","string","double","float","dateTime", "timeInstant","base64Binary","base64","ur-type"); -$SOAP_typemap[$SOAP_InteropOrg] = array("SOAPStruct"); -$SOAP_typemap[$SOAP_SchemaEncoding] = array("base64","array","Array"); +$SOAP_typemap[SOAP_INTEROPORG] = array("SOAPStruct"); +$SOAP_typemap[SOAP_SCHEMA_ENCODING] = array("base64","array","Array"); */ -$SOAP_typemap["http://www.w3.org/2001/XMLSchema"] = array( +$SOAP_typemap[SOAP_XML_SCHEMA_VERSION] = array( "string" => "string", "boolean" => "boolean", "float" => FLOAT, @@ -106,7 +112,7 @@ "unsignedByte" => "integer", "positiveInteger" => "integer" ); -$SOAP_typemap["http://www.w3.org/1999/XMLSchema"] = array( +$SOAP_typemap[SOAP_XML_SCHEMA_1999] = array( "i4" => "integer", "int" => "integer", "boolean" => "boolean", @@ -119,16 +125,16 @@ "base64" => "string", "ur-type" => "string" ); -$SOAP_typemap[$SOAP_InteropOrg] = array("SOAPStruct" => "array"); -$SOAP_typemap[$SOAP_SchemaEncoding] = array("base64" => "string","array" => "array","Array" => "array"); +$SOAP_typemap[SOAP_INTEROPORG] = array("SOAPStruct" => "array"); +$SOAP_typemap[SOAP_SCHEMA_ENCODING] = array("base64" => "string","array" => "array","Array" => "array"); // load namespace uris into an array of uri => prefix $SOAP_namespaces = array( - "http://schemas.xmlsoap.org/soap/envelope/" => "SOAP-ENV", - $SOAP_XMLSchemaVersion => "xsd", - $SOAP_XMLSchemaVersion."-instance" => "xsi", - $SOAP_SchemaEncoding => "SOAP-ENC", - $SOAP_InteropOrg=>"si"); + SOAP_ENVELOP => "SOAP-ENV", + SOAP_XML_SCHEMA_VERSION => "xsd", + SOAP_XML_SCHEMA_VERSION."-instance" => "xsi", + SOAP_SCHEMA_ENCODING => "SOAP-ENC", + SOAP_INTEROPORG=>"si"); $SOAP_xmlEntities = array("quot" => '"',"amp" => "&", "lt" => "<","gt" => ">","apos" => "'"); Index: pear/SOAP/package.xml diff -u pear/SOAP/package.xml:1.3 pear/SOAP/package.xml:1.4 --- pear/SOAP/package.xml:1.3 Tue Feb 19 19:47:30 2002 +++ pear/SOAP/package.xml Mon Feb 25 00:06:36 2002 @@ -37,6 +37,7 @@ </dir> <dir name="Transport"> <file role="php">HTTP.php</file> + <file role="php">SMTP.php</file> </dir> <dir name="Type"> <file role="php">dateTime.php</file> @@ -47,6 +48,14 @@ <file role="test">client_round2_base.php</file> <file role="test">interop.php</file> <file role="test">server_soapinterop_base.php</file> + <file role="test">server_soapinterop_groupB.php</file> + </dir> + <dir name="test" role="test"> + <file role="test">5.2.simpletypes.php</file> + <file role="test">5.2.1.simpletypes.string.php</file> + <file role="test">5.2.1.simpletypes.multiref.php</file> + <file role="test">all.php</file> + <file role="test">test.utility.php</file> </dir> </dir> </filelist> Index: pear/SOAP/Transport/HTTP.php diff -u pear/SOAP/Transport/HTTP.php:1.4 pear/SOAP/Transport/HTTP.php:1.5 --- pear/SOAP/Transport/HTTP.php:1.4 Wed Feb 20 03:16:32 2002 +++ pear/SOAP/Transport/HTTP.php Mon Feb 25 00:06:37 2002 @@ -16,14 +16,14 @@ // | Authors: Shane Caraveo <Shane@Caraveo.com> | // +----------------------------------------------------------------------+ // -// $Id: HTTP.php,v 1.4 2002/02/20 08:16:32 shane Exp $ +// $Id: HTTP.php,v 1.5 2002/02/25 05:06:37 shane Exp $ // require_once("SOAP/globals.php"); /** * HTTP Transport for SOAP * * @access public -* @version $Id: HTTP.php,v 1.4 2002/02/20 08:16:32 shane Exp $ +* @version $Id: HTTP.php,v 1.5 2002/02/25 05:06:37 shane Exp $ * @package SOAP::Transport::HTTP * @author Shane Caraveo <shane@php.net> */ @@ -46,10 +46,9 @@ */ function SOAP_Transport_HTTP($URL) { - global $SOAP_LibraryName; $this->urlparts = @parse_url($URL); $this->url = $URL; - $this->_userAgent = $SOAP_LibraryName; + $this->_userAgent = SOAP_LIBRARY_NAME; } /** @@ -129,7 +128,8 @@ { if (preg_match("/^(.*?)\r?\n\r?\n(.*)/s",$this->incoming_payload,$match)) { $this->response = preg_replace("/[\r|\n]/","",$match[2]); - return TRUE; + // if no content, return false + return strlen($this->response) > 0; } return FALSE; } Index: pear/SOAP/Transport/SMTP.php diff -u pear/SOAP/Transport/SMTP.php:1.1 pear/SOAP/Transport/SMTP.php:1.2 --- pear/SOAP/Transport/SMTP.php:1.1 Sat Feb 23 14:57:26 2002 +++ pear/SOAP/Transport/SMTP.php Mon Feb 25 00:06:37 2002 @@ -16,7 +16,7 @@ // | Authors: Shane Caraveo <Shane@Caraveo.com> | // +----------------------------------------------------------------------+ // -// $Id: SMTP.php,v 1.1 2002/02/23 19:57:26 shane Exp $ +// $Id: SMTP.php,v 1.2 2002/02/25 05:06:37 shane Exp $ // // Status: rough draft, untested // @@ -35,7 +35,7 @@ * SMTP Transport for SOAP * * @access public -* @version $Id: SMTP.php,v 1.1 2002/02/23 19:57:26 shane Exp $ +* @version $Id: SMTP.php,v 1.2 2002/02/25 05:06:37 shane Exp $ * @package SOAP::Transport::SMTP * @author Shane Caraveo <shane@php.net> */ @@ -58,10 +58,9 @@ */ function SOAP_Transport_SMTP($URL) { - global $SOAP_LibraryName; $this->urlparts = @parse_url($URL); $this->url = $URL; - $this->_userAgent = $SOAP_LibraryName; + $this->_userAgent = SOAP_LIBRARY_NAME; } /** Index: pear/SOAP/Type/dateTime.php diff -u pear/SOAP/Type/dateTime.php:1.2 pear/SOAP/Type/dateTime.php:1.3 --- pear/SOAP/Type/dateTime.php:1.2 Tue Feb 19 20:45:42 2002 +++ pear/SOAP/Type/dateTime.php Mon Feb 25 00:06:37 2002 @@ -17,7 +17,7 @@ // | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author | // +----------------------------------------------------------------------+ // -// $Id: dateTime.php,v 1.2 2002/02/20 01:45:42 ssb Exp $ +// $Id: dateTime.php,v 1.3 2002/02/25 05:06:37 shane Exp $ // class SOAP_Type_dateTime { @@ -116,7 +116,8 @@ $date1 = $this->toUnixtime($date1); if (!is_numeric($date2)) $date2 = $this->toUnixtime($date2); - return $date1 - $date2; + if ($date1 != -1 && $date2 != -1) return $date1 - $date2; + return -1; } function _test($orig = "2001-04-25T09:31:41-0700") Index: pear/SOAP/interop/client_params.php diff -u pear/SOAP/interop/client_params.php:1.1 pear/SOAP/interop/client_params.php:1.2 --- pear/SOAP/interop/client_params.php:1.1 Mon Feb 18 03:48:58 2002 +++ pear/SOAP/interop/client_params.php Mon Feb 25 00:06:37 2002 @@ -17,7 +17,7 @@ // | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author | // +----------------------------------------------------------------------+ // -// $Id: client_params.php,v 1.1 2002/02/18 08:48:58 shane Exp $ +// $Id: client_params.php,v 1.2 2002/02/25 05:06:37 shane Exp $ // require_once("SOAP/Value.php"); @@ -148,24 +148,30 @@ ); # XXX I know this isn't quite right, need to deal with this better -$method_params["GroupB"]['php']["echo2DStringArray"]['input2DStringArray'] = - array( - "row0col0", - "row0col1", - "row0col2", - "row1col0", - "row2col1", - "row3col2" - ); +function make_2d($x, $y) +{ + for ($_x = 0; $_x < $x; $_x++) { + for ($_y = 0; $_y < $y; $_y++) { + $a[$_x][$_y] = "x{$_x}y{$_y}"; + } + } + return $a; +} + +$method_params["GroupB"]['php']["echo2DStringArray"]['input2DStringArray'] = make_2d(3,3); $method_params["GroupB"]['soapval']["echo2DStringArray"]['input2DStringArray'] = new SOAP_Value("input2DStringArray","Array", array( + array( new SOAP_Value("item","string","row0col0"), new SOAP_Value("item","string","row0col1"), - new SOAP_Value("item","string","row0col2"), + new SOAP_Value("item","string","row0col2") + ), + array( new SOAP_Value("item","string","row1col0"), - new SOAP_Value("item","string","row2col1"), - new SOAP_Value("item","string","row3col2") + new SOAP_Value("item","string","row1col1"), + new SOAP_Value("item","string","row1col2") + ) ) ); @@ -205,7 +211,7 @@ "varArray" => array("red","blue","green") ); $method_params["GroupB"]['soapval']["echoNestedArray"]['inputStruct'] = - new SOAP_Value("inputStruct","Array", + new SOAP_Value("inputStruct","struct", array( #push struct elements into one soap value new SOAP_Value("varString","string","arg"), new SOAP_Value("varInt","int",34), Index: pear/SOAP/interop/client_round2_base.php diff -u pear/SOAP/interop/client_round2_base.php:1.4 pear/SOAP/interop/client_round2_base.php:1.5 --- pear/SOAP/interop/client_round2_base.php:1.4 Wed Feb 20 03:16:33 2002 +++ pear/SOAP/interop/client_round2_base.php Mon Feb 25 00:06:37 2002 @@ -17,33 +17,54 @@ // | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author | // +----------------------------------------------------------------------+ // -// $Id: client_round2_base.php,v 1.4 2002/02/20 08:16:33 shane Exp $ +// $Id: client_round2_base.php,v 1.5 2002/02/25 05:06:37 shane Exp $ // require_once("SOAP/Client.php"); require_once("client_params.php"); +require_once("SOAP/test/test.utility.php"); + error_reporting(E_ALL ^ E_NOTICE); -$localonly = 1; // set to 1 to test only your local server -$test = 'base'; // which test to do: base, GroupB, GroupC +$localonly = 0; // set to 1 to test only your local server +$usebuiltin = 1; // use builtin list of endpoints +$test = 'GroupB'; // which test to do: base, GroupB, GroupC $parm = 'soapval'; // use base types: php, soapval $show = 1; $debug = 0; -$numservers = 1; // zero for all of them -$testfunc = ""; // test a single function -$specificendpoint = ""; //"http://63.142.188.184:1122/"; // endpoint url +$numservers = 0; // zero for all of them +$testfunc = "echo2DStringArray"; // test a single function +$specificendpoint = "http://soap.4s4c.com/ilab/soap.asp"; //"http://63.142.188.184:1122/"; // endpoint url if ($localonly) { # define your test servers endpointURL here $endpoints[$SOAP_LibraryName] = array( "endpointURL" => "http://127.0.0.1/soap/interop.php", "name" => $SOAP_LibraryName); +} elseif ($usebuiltin) { + $endpoints["4s4c"] = array( + "endpointURL" => "http://soap.4s4c.com/ilab/soap.asp", + "name" => "4s4c"); + $endpoints["Apache Axis"] = array( + "endpointURL" => "http://nagoya.apache.org:5049/axis/services/echo", + "name" => "Apache Axis"); + #$endpoints["GLUE"] = array( + # "endpointURL" => "http://www.themindelectric.net:8005/glue/round2", + # "name" => "GLUE"); + #$endpoints["HP SOAP"] = array( + # "endpointURL" => "http://soap.bluestone.com/hpws/soap/EchoService", + # "name" => "HP SOAP"); + #$endpoints["IONA XMLBus"] = array( + # "endpointURL" => "http://interop.xmlbus.com:7002/xmlbus/container/InteropTest/BaseService/BasePort", + # "name" => "IONA XMLBus"); } /******************************************************************** * you don't need to do anything below here */ -if ($localonly || getInteropEndpoints($test)) { +if ($localonly || $usebuiltin || + getInteropEndpoints($test) + ) { do_interopTest($method_params[$test][$parm], $testfunc, $numservers); } @@ -52,6 +73,10 @@ // get other interop endpoints $soapclient = new SOAP_Client("http://www.whitemesa.net/interopInfo"); if($endpointArray = $soapclient->call("GetEndpointInfo",array("groupName"=>$base),"http://soapinterop.org/info/","http://soapinterop.org/info/")){ + if (PEAR::isError($endpointArray)) { + print_r($endpointArray); + return FALSE; + } #print_r($endpointArray); foreach($endpointArray as $k => $v){ $endpoints[$v["endpointName"]] = $v; @@ -101,7 +126,7 @@ $soap->debug_flag = true; $return = $soap->call($method,$method_params,"http://soapinterop.org/","http://soapinterop.org/"); - if(!$soap->fault){ + if(!PEAR::isError($return) && !$soap->fault){ if (is_array($method_params) && count($method_params) == 1) { $sent = array_shift($method_params); } else { @@ -114,6 +139,8 @@ $sent = decode_soapval($sent); $ok = 0; + $sent_type = gettype($sent); + $return_type = gettype($return); if ($sent_type == "array" && $return_type == "array") { # compare arrays $ok = array_compare($sent, $return); @@ -206,55 +233,6 @@ } } */ -} - - - -function number_compare($f1, $f2) -{ - # figure out which has the least fractional digits - preg_match('/.*?\.(.*)/',$f1,$m1); - preg_match('/.*?\.(.*)/',$f2,$m2); - #print_r($m1); - # always use at least 2 digits of precision - $d = max(min(strlen($m1[1]),strlen($m2[1])),2); - $f1 = round($f1, $d); - $f2 = round($f2, $d); - return bccomp($f1, $f2, $d) == 0; -} - -function string_compare($e1, $e2) -{ - if (is_numeric($e1) && is_numeric($e2)) { - return number_compare($e1, $e2); - } - # handle dateTime comparison - $e1_type = gettype($e1); - $e2_type = gettype($e2); - $ok = FALSE; - if ($e1_type == "string") { - $dt = new SOAP_Type_dateTime(); - $ok = $dt->compare($e1, $e2) == 0; - } - return $ok || $e1 == $e2 || strcasecmp($e1, $e2) == 0; -} - -function array_compare($ar1, $ar2) -{ - # first a shallow diff - $diff = array_diff($sent, $return); - if (count($diff) == 0) return TRUE; - - # diff failed, do a full check of the array - foreach ($ar1 as $k => $v) { - print "comparing $v == $ar2[$k]\n"; - if (gettype($v) == "array") { - if (!array_compare($v, $ar2[$k])) return FALSE; - } else { - if (!string_compare($v, $ar2[$k])) return FALSE; - } - } - return FALSE; } ?> Index: pear/SOAP/interop/interop.php diff -u pear/SOAP/interop/interop.php:1.2 pear/SOAP/interop/interop.php:1.3 --- pear/SOAP/interop/interop.php:1.2 Tue Feb 19 20:45:42 2002 +++ pear/SOAP/interop/interop.php Mon Feb 25 00:06:37 2002 @@ -17,7 +17,7 @@ // | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author | // +----------------------------------------------------------------------+ // -// $Id: interop.php,v 1.2 2002/02/20 01:45:42 ssb Exp $ +// $Id: interop.php,v 1.3 2002/02/25 05:06:37 shane Exp $ // // 1. include server.php @@ -40,6 +40,7 @@ */ include("server_soapinterop_base.php"); +include("server_soapinterop_groupB.php"); // 4. call the service method to initiate transaction // and send response Index: pear/SOAP/interop/server_soapinterop_groupB.php +++ pear/SOAP/interop/server_soapinterop_groupB.php <? // // +----------------------------------------------------------------------+ // | PHP Version 4 | // +----------------------------------------------------------------------+ // | Copyright (c) 1997-2002 The PHP Group | // +----------------------------------------------------------------------+ // | This source file is subject to version 2.02 of the PHP license, | // | that is bundled with this package in the file LICENSE, and is | // | available at through the world-wide-web at | // | http://www.php.net/license/2_02.txt. | // | If you did not receive a copy of the PHP license and are unable to | // | obtain it through the world-wide-web, please send a note to | // | license@php.net so we can mail you a copy immediately. | // +----------------------------------------------------------------------+ // | Authors: Shane Caraveo <Shane@Caraveo.com> Port to PEAR and more | // | Authors: Dietrich Ayala <dietrich@ganx4.com> Original Author | // +----------------------------------------------------------------------+ // // $Id: server_soapinterop_groupB.php,v 1.1 2002/02/25 05:06:37 shane Exp $ // require_once('SOAP/Server.php'); $server->addToMap('echoStructAsSimpleTypes', array('inputStruct' => 'struct'), array('outputString' => 'string', 'outputInteger' => 'int', 'outputFloat' => 'float')); function echoStructAsSimpleTypes ($struct) { # convert a SOAPStruct to an array return array_values($struct); } $server->addToMap('echoSimpleTypesAsStruct', array('outputString' => 'string', 'outputInteger' => 'int', 'outputFloat' => 'float'), array('return' => 'struct')); function echoSimpleTypesAsStruct($string, $int, $float) { # convert a SOAPStruct to an array $ret = array($string, $int, $float); return $ret; } function echoNestedStruct($struct) { return $struct; } function echo2DStringArray($ary) { return $ary; } function echoNestedArray($ary) { return $ary; } ?>
« previous php.pear.cvs (#2606) next »