Back to index

php5  5.3.10
client_round2_interop.php
Go to the documentation of this file.
00001 <?php
00002 //
00003 // +----------------------------------------------------------------------+
00004 // | PHP Version 4                                                        |
00005 // +----------------------------------------------------------------------+
00006 // | Copyright (c) 1997-2003 The PHP Group                                |
00007 // +----------------------------------------------------------------------+
00008 // | This source file is subject to version 2.02 of the PHP license,      |
00009 // | that is bundled with this package in the file LICENSE, and is        |
00010 // | available through the world-wide-web at                              |
00011 // | http://www.php.net/license/2_02.txt.                                 |
00012 // | If you did not receive a copy of the PHP license and are unable to   |
00013 // | obtain it through the world-wide-web, please send a note to          |
00014 // | license@php.net so we can mail you a copy immediately.               |
00015 // +----------------------------------------------------------------------+
00016 // | Authors: Shane Caraveo <Shane@Caraveo.com>                           |
00017 // +----------------------------------------------------------------------+
00018 //
00019 // $Id: client_round2_interop.php 242949 2007-09-26 15:44:16Z cvs2svn $
00020 //
00021 require_once 'DB.php'; // PEAR/DB
00022 require_once 'client_round2_params.php';
00023 require_once 'test.utility.php';
00024 require_once 'config.php';
00025 
00026 error_reporting(E_ALL ^ E_NOTICE);
00027 
00028 class Interop_Client
00029 {
00030     // database DNS
00031     var $DSN = "";
00032 
00033     var $baseURL = "";
00034 
00035     // our central interop server, where we can get the list of endpoints
00036     var $interopServer = "http://www.whitemesa.net/wsdl/interopInfo.wsdl";
00037 
00038     // our local endpoint, will always get added to the database for all tests
00039     var $localEndpoint;
00040 
00041     // specify testing
00042     var $currentTest = 'base';      // see $tests above
00043     var $paramType = 'php';     // 'php' or 'soapval'
00044     var $useWSDL = 0;           // 1= do wsdl tests
00045     var $numServers = 0;        // 0 = all
00046     var $specificEndpoint = ''; // test only this endpoint
00047     var $testMethod = '';       // test only this method
00048     var $skipEndpointList = array(); // endpoints to skip
00049     var $nosave = 0;
00050     var $startAt = ''; // start in list at this endpoint
00051     // debug output
00052     var $show = 1;
00053     var $debug = 0;
00054     var $showFaults = 0; // used in result table output
00055 
00056     // PRIVATE VARIABLES
00057     var $dbc = NULL;
00058     var $totals = array();
00059     var $tests = array('base','GroupB', 'GroupC');
00060     var $paramTypes = array('php', 'soapval');
00061     var $endpoints = array();
00062     var $html = 1;
00063 
00064     function Interop_Client() {
00065         global $interopConfig;
00066         $this->DSN = $interopConfig['DSN'];
00067         $this->baseURL = $interopConfig['baseURL'];
00068         //$this->baseURL = 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
00069         // set up the database connection
00070         $this->dbc = DB::connect($this->DSN, true);
00071         // if it errors out, just ignore it and rely on regular methods
00072         if (DB::isError($this->dbc)) {
00073             echo $this->dbc->getMessage();
00074             $this->dbc = NULL;
00075         }
00076         // set up local endpoint
00077         $this->localEndpoint['base'] = (object)array(
00078                                 'endpointName'=>'PHP ext/soap',
00079                                 'endpointURL'=>$this->baseURL.'/server_round2_base.php',
00080                                 'wsdlURL'=>$this->baseURL.'/interop.wsdl.php'
00081                               );
00082         $this->localEndpoint['GroupB'] = (object)array(
00083                                 'endpointName'=>'PHP ext/soap',
00084                                 'endpointURL'=>$this->baseURL.'/server_round2_groupB.php',
00085                                 'wsdlURL'=>$this->baseURL.'/interopB.wsdl.php'
00086                               );
00087         $this->localEndpoint['GroupC'] = (object)array(
00088                                 'endpointName'=>'PHP ext/soap',
00089                                 'endpointURL'=>$this->baseURL.'/server_round2_groupC.php',
00090                                 'wsdlURL'=>$this->baseURL.'/echoheadersvc.wsdl.php');
00091     }
00092 
00093     function _fetchEndpoints(&$soapclient, $test) {
00094         $this->_getEndpoints($test, 1);
00095 
00096         // retreive endpoints from the endpoint server
00097         $endpointArray = $soapclient->__soapCall("GetEndpointInfo",array("groupName"=>$test),array('soapaction'=>"http://soapinterop.org/",'uri'=>"http://soapinterop.org/"));
00098         if (is_soap_fault($endpointArray) || PEAR::isError($endpointArray)) {
00099             if ($this->html) print "<pre>";
00100             print $soapclient->wire."\n";
00101             print_r($endpointArray);
00102             if ($this->html) print "</pre>";
00103             print "\n";
00104             return;
00105         }
00106 
00107         // add our local endpoint
00108         if ($this->localEndpoint[$test]) {
00109           array_push($endpointArray, $this->localEndpoint[$test]);
00110         }
00111 
00112         if (!$endpointArray) return;
00113 
00114         // reset the status to zero
00115         $res = $this->dbc->query("update endpoints set status = 0 where class='$test'");
00116         if (DB::isError($res)) {
00117             die ($res->getMessage());
00118         }
00119         if (is_object($res)) $res->free();
00120         // save new endpoints into database
00121         foreach($endpointArray as $k => $v){
00122             if (array_key_exists($v->endpointName,$this->endpoints)) {
00123                 $res = $this->dbc->query("update endpoints set endpointURL='{$v->endpointURL}', wsdlURL='{$v->wsdlURL}', status=1 where id={$this->endpoints[$v->endpointName]['id']}");
00124             } else {
00125                 $res = $this->dbc->query("insert into endpoints (endpointName,endpointURL,wsdlURL,class) values('{$v->endpointName}','{$v->endpointURL}','{$v->wsdlURL}','$test')");
00126             }
00127             if (DB::isError($res)) {
00128                 die ($res->getMessage());
00129             }
00130             if (is_object($res)) $res->free();
00131         }
00132     }
00133 
00141     function fetchEndpoints($test = NULL) {
00142         // fetch from the interop server
00143         try {
00144             $soapclient = new SoapClient($this->interopServer);
00145             if ($test) {
00146                 $this->_fetchEndpoints($soapclient, $test);
00147             } else {
00148                 foreach ($this->tests as $test) {
00149                     $this->_fetchEndpoints($soapclient, $test);
00150                 }
00151                 $test = 'base';
00152             }
00153         } catch (SoapFault $fault) {
00154             if ($this->html) {
00155                 echo "<pre>$fault</pre>\n";
00156             } else {
00157                 echo "$fault\n";
00158             }
00159             return NULL;
00160         }
00161         // retreive all endpoints now
00162         $this->currentTest = $test;
00163         $x = $this->_getEndpoints($test);
00164         return $x;
00165     }
00166 
00176     function getEndpoints($base = 'base', $all = 0) {
00177         if (!$this->_getEndpoints($base, $all)) {
00178             return $this->fetchEndpoints($base);
00179         }
00180         return TRUE;
00181     }
00182 
00192     function _getEndpoints($base = "", $all = 0) {
00193         $this->endpoints = array();
00194 
00195         // build sql
00196         $sql = "select * from endpoints ";
00197         if ($base) {
00198             $sql .= "where class='$base' ";
00199             if (!$all) $sql .= "and status=1";
00200         } else
00201         if (!$all) $sql .= "where status=1";
00202         $sql .= " order by endpointName";
00203         
00204 
00205         $db_ep = $this->dbc->getAll($sql,NULL, DB_FETCHMODE_ASSOC );
00206         if (DB::isError($db_ep)) {
00207             echo $sql."\n";
00208             echo $db_ep->getMessage();
00209             return FALSE;
00210         }
00211         // rearange the array
00212         foreach ($db_ep as $entry) {
00213             $this->endpoints[$entry['endpointName']] = $entry;
00214         }
00215 
00216         if (count($this->endpoints) > 0) {
00217             $this->currentTest = $base;
00218             return TRUE;
00219         }
00220         return FALSE;
00221     }
00222 
00229     function getResults($test = 'base', $type = 'php', $wsdl = 0) {
00230         // be sure we have the right endpoints for this test result
00231         $this->getEndpoints($test);
00232 
00233         // retreive the results and put them into the endpoint info
00234         $sql = "select * from results where class='$test' and type='$type' and wsdl=$wsdl";
00235         $results = $this->dbc->getAll($sql,NULL, DB_FETCHMODE_ASSOC );
00236         foreach ($results as $result) {
00237             // find the endpoint
00238             foreach ($this->endpoints as $epn => $epi) {
00239                 if ($epi['id'] == $result['endpoint']) {
00240                     // store the info
00241                     $this->endpoints[$epn]['methods'][$result['function']] = $result;
00242                     break;
00243                 }
00244             }
00245         }
00246     }
00247 
00254     function _saveResults($endpoint_id, &$soap_test) {
00255         if ($this->nosave) return;
00256 
00257         $result = $soap_test->result;
00258         $wire = $result['wire'];
00259         if ($result['success']) {
00260             $success = 'OK';
00261             $error = '';
00262         } else {
00263             $success = $result['fault']->faultcode;
00264             $pos = strpos($success,':');
00265             if ($pos !== false) {
00266               $success = substr($success,$pos+1);                 
00267             }
00268             $error = $result['fault']->faultstring;
00269             if (!$wire) $wire= $result['fault']->detail;
00270         }
00271 
00272         $test_name = $soap_test->test_name;
00273 
00274         $sql = "delete from results where endpoint=$endpoint_id ".
00275                     "and class='$this->currentTest' and type='$this->paramType' ".
00276                     "and wsdl=$this->useWSDL and function=".
00277                     $this->dbc->quote($test_name);
00278         #echo "\n".$sql;
00279         $res = $this->dbc->query($sql);
00280         if (DB::isError($res)) {
00281             die ($res->getMessage());
00282         }
00283         if (is_object($res)) $res->free();
00284 
00285         $sql = "insert into results (endpoint,stamp,class,type,wsdl,function,result,error,wire) ".
00286                     "values($endpoint_id,".time().",'$this->currentTest',".
00287                     "'$this->paramType',$this->useWSDL,".
00288                     $this->dbc->quote($test_name).",".
00289                     $this->dbc->quote($success).",".
00290                     $this->dbc->quote($error).",".
00291                     ($wire?$this->dbc->quote($wire):"''").")";
00292         #echo "\n".$sql;
00293         $res = $this->dbc->query($sql);
00294 
00295         if (DB::isError($res)) {
00296             die ($res->getMessage());
00297         }
00298         if (is_object($res)) $res->free();
00299     }
00300 
00309     function decodeSoapval($soapval)
00310     {
00311         if (gettype($soapval) == "object" &&
00312             (strcasecmp(get_class($soapval),"SoapParam") == 0 ||
00313              strcasecmp(get_class($soapval),"SoapVar") == 0)) {
00314                 if (strcasecmp(get_class($soapval),"SoapParam") == 0)
00315                     $val = $soapval->param_data->enc_value;
00316                 else
00317                     $val = $soapval->enc_value;
00318         } else {
00319             $val = $soapval;
00320         }
00321         if (is_array($val)) {
00322             foreach($val as $k => $v) {
00323                 if (gettype($v) == "object" &&
00324                     (strcasecmp(get_class($soapval),"SoapParam") == 0 ||
00325                     strcasecmp(get_class($soapval),"SoapVar") == 0)) {
00326                     $val[$k] = $this->decodeSoapval($v);
00327                 }
00328             }
00329         }
00330         return $val;
00331     }
00332 
00342     function compareResult($expect, $result, $type = NULL)
00343     {
00344       return compare($expect, $result);
00345     }
00346 
00347 
00357     function doEndpointMethod(&$endpoint_info, &$soap_test) {
00358         $ok = FALSE;
00359 
00360         // prepare a holder for the test results
00361         $soap_test->result['class'] = $this->currentTest;
00362         $soap_test->result['type'] = $this->paramType;
00363         $soap_test->result['wsdl'] = $this->useWSDL;
00364 
00365         if ($this->useWSDL) {
00366             if (array_key_exists('wsdlURL',$endpoint_info)) {
00367                 if (!array_key_exists('client',$endpoint_info)) {
00368                     try {
00369                         $endpoint_info['client'] = new SoapClient($endpoint_info['wsdlURL'], array("trace"=>1));
00370                     } catch (SoapFault $ex) {
00371                         $endpoint_info['client']->wsdl->fault = $ex;
00372                     }
00373                 }
00374                 $soap =& $endpoint_info['client'];
00375 
00376                 # XXX how do we determine a failure on retreiving/parsing wsdl?
00377                 if ($soap->wsdl->fault) {
00378                     $fault = $soap->wsdl->fault;
00379                     $soap_test->setResult(0,'WSDL',
00380                                           $fault->faultstring."\n\n".$fault->detail,
00381                                           $fault->faultstring,
00382                                           $fault
00383                                           );
00384                     return FALSE;
00385                 }
00386             } else {
00387                 $fault = new SoapFault('WSDL',"no WSDL defined for $endpoint");
00388                 $soap_test->setResult(0,'WSDL',
00389                                       $fault->faultstring,
00390                                       $fault->faultstring,
00391                                       $fault
00392                                       );
00393                 return FALSE;
00394             }
00395             $namespace = false;
00396             $soapaction = false;
00397         } else {
00398             $namespace = $soapaction = 'http://soapinterop.org/';
00399             // hack to make tests work with MS SoapToolkit
00400             // it's the only one that uses this soapaction, and breaks if
00401             // it isn't right.  Can't wait for soapaction to be fully depricated
00402             if ($this->currentTest == 'base' &&
00403                 strstr($endpoint_info['endpointName'],'MS SOAP ToolKit 2.0')) {
00404                 $soapaction = 'urn:soapinterop';
00405             }
00406             if (!array_key_exists('client',$endpoint_info)) {
00407                 $endpoint_info['client'] = new SoapClient(null,array('location'=>$endpoint_info['endpointURL'],'uri'=>$soapaction,'trace'=>1));
00408             }
00409             $soap = $endpoint_info['client'];
00410         }
00411 //        // add headers to the test
00412 //        if ($soap_test->headers) {
00413 //            // $header is already a SOAP_Header class
00414 //            foreach ($soap_test->headers as $header) {
00415 //              $soap->addHeader($header);
00416 //            }
00417 //        }
00418         // XXX no way to set encoding
00419         // this lets us set UTF-8, US-ASCII or other
00420         //$soap->setEncoding($soap_test->encoding);
00421 try {
00422         if ($this->useWSDL && !$soap_test->headers && !$soap_test->headers_expect) {
00423             $args = '';
00424             foreach ($soap_test->method_params as $pname => $param) {
00425                 $arg = '$soap_test->method_params["'.$pname.'"]';
00426                 $args .= $args?','.$arg:$arg;
00427             }
00428             $return = eval('return $soap->'.$soap_test->method_name.'('.$args.');');
00429         } else {
00430           if ($soap_test->headers || $soap_test->headers_expect) {
00431             $return = $soap->__soapCall($soap_test->method_name,$soap_test->method_params,array('soapaction'=>$soapaction,'uri'=>$namespace), $soap_test->headers, $result_headers);
00432           } else {
00433             $return = $soap->__soapCall($soap_test->method_name,$soap_test->method_params,array('soapaction'=>$soapaction,'uri'=>$namespace));
00434           }
00435         }
00436 } catch (SoapFault $ex) {
00437   $return = $ex;
00438 }
00439 
00440         if(!is_soap_fault($return)){
00441             if ($soap_test->expect !== NULL) {
00442                 $sent = $soap_test->expect;
00443             } else if (is_array($soap_test->method_params) && count($soap_test->method_params) == 1) {
00444                 reset($soap_test->method_params);
00445                 $sent = current($soap_test->method_params);
00446             } else if (is_array($soap_test->method_params) && count($soap_test->method_params) == 0) {
00447                 $sent = null;
00448             } else {
00449                 $sent = $soap_test->method_params;
00450             }
00451 
00452             // compare header results
00453             $headers_ok = TRUE;
00454             if ($soap_test->headers || $soap_test->headers_expect) {
00455               $headers_ok = $this->compareResult($soap_test->headers_expect, $result_headers);              
00456             }
00457 
00458             # we need to decode what we sent so we can compare!
00459             $sent_d = $this->decodeSoapval($sent);
00460 
00461             $soap_test->result['sent'] = $sent;
00462             $soap_test->result['return'] = $return;
00463 
00464             // compare the results with what we sent
00465 
00466             if ($soap_test->cmp_func !== NULL) {
00467               $cmp_func = $soap_test->cmp_func;
00468               $ok = $cmp_func($sent_d,$return);
00469             } else {
00470               $ok = $this->compareResult($sent_d,$return, $sent->type);
00471               if (!$ok && $soap_test->expect) {
00472                 $ok = $this->compareResult($soap_test->expect,$return);
00473               }
00474             }
00475 
00476             // save the wire
00477             $wire = "REQUEST:\n".str_replace('" ',"\" \n",str_replace('>',">\n",$soap->__getlastrequest()))."\n\n".
00478                     "RESPONSE:\n".str_replace('" ',"\" \n",str_replace('>',">\n",$soap->__getlastresponse()))."\n\n".
00479                     "EXPECTED:\n".var_dump_str($sent_d)."\n".
00480                     "RESULTL:\n".var_dump_str($return);
00481             if ($soap_test->headers_expect) {
00482               $wire .= "\nEXPECTED HEADERS:\n".var_dump_str($soap_test->headers_expect)."\n".
00483                        "RESULT HEADERS:\n".var_dump_str($result_headers);
00484             }
00485             #print "Wire:".htmlentities($wire);
00486 
00487             if($ok){
00488                 if (!$headers_ok) {
00489                     $fault = new SoapFault('HEADER','The returned result did not match what we expected to receive');
00490                     $soap_test->setResult(0,$fault->faultcode,
00491                                       $wire,
00492                                       $fault->faultstring,
00493                                       $fault
00494                                       );
00495                 } else {
00496                     $soap_test->setResult(1,'OK',$wire);
00497                     $success = TRUE;
00498                 }
00499             } else {
00500                 $fault = new SoapFault('RESULT','The returned result did not match what we expected to receive');
00501                 $soap_test->setResult(0,$fault->faultcode,
00502                                   $wire,
00503                                   $fault->faultstring,
00504                                   $fault
00505                                   );
00506             }
00507         } else {
00508             $fault = $return;
00509             if ($soap_test->expect_fault) {
00510                 $ok = 1;
00511                 $res = 'OK';
00512             } else {
00513                 $ok = 0;
00514                 $res =$fault->faultcode;
00515                 $pos = strpos($res,':');
00516                 if ($pos !== false) {
00517                   $res = substr($res,$pos+1);                 
00518                 }
00519             }
00520             // save the wire
00521             $wire = "REQUEST:\n".str_replace('" ',"\" \n",str_replace('>',">\n",$soap->__getlastrequest()))."\n\n".
00522                     "RESPONSE:\n".str_replace('" ',"\" \n",str_replace('>',">\n",$soap->__getlastresponse()))."\n".
00523                     "RESULTL:\n".var_dump_str($return);
00524             #print "Wire:".htmlentities($wire);
00525 
00526             $soap_test->setResult($ok,$res, $wire,$fault->faultstring, $fault);
00527 
00528         }
00529         return $ok;
00530     }
00531 
00532 
00539     function doTest() {
00540         global $soap_tests;
00541         // get endpoints for this test
00542         $this->getEndpoints($this->currentTest);
00543         #clear totals
00544         $this->totals = array();
00545 
00546         $i = 0;
00547         foreach($this->endpoints as $endpoint => $endpoint_info){
00548 
00549             // if we specify an endpoint, skip until we find it
00550             if ($this->specificEndpoint && $endpoint != $this->specificEndpoint) continue;
00551             if ($this->useWSDL && !$endpoint_info['endpointURL']) continue;
00552 
00553             $skipendpoint = FALSE;
00554             $this->totals['servers']++;
00555             #$endpoint_info['tests'] = array();
00556 
00557             if ($this->show) {
00558               print "Processing $endpoint at {$endpoint_info['endpointURL']}";
00559               if ($this->html) print "<br>\n"; else print "\n";
00560             }
00561 
00562             foreach($soap_tests[$this->currentTest] as $soap_test) {
00563             //foreach(array_keys($method_params[$this->currentTest][$this->paramType]) as $method)
00564 
00565                 // only run the type of test we're looking for (php or soapval)
00566                 if ($soap_test->type != $this->paramType) continue;
00567 
00568                 // if we haven't reached our startpoint, skip
00569                 if ($this->startAt && $this->startAt != $endpoint_info['endpointName']) continue;
00570                 $this->startAt = '';
00571 
00572                 // if this is in our skip list, skip it
00573                 if (in_array($endpoint, $this->skipEndpointList)) {
00574                     $skipendpoint = TRUE;
00575                     $skipfault = new SoapFault('SKIP','endpoint skipped');
00576                     $soap_test->setResult(0,$fault->faultcode, '',
00577                                   $skipfault->faultstring,
00578                                   $skipfault
00579                                   );
00580                     #$endpoint_info['tests'][] = &$soap_test;
00581                     #$soap_test->showTestResult($this->debug, $this->html);
00582                     #$this->_saveResults($endpoint_info['id'], $soap_test->method_name);
00583                     $soap_test->result = NULL;
00584                     continue;
00585                 }
00586 
00587                 // if we're looking for a specific method, skip unless we have it
00588                 if ($this->testMethod && strcmp($this->testMethod,$soap_test->test_name) != 0) continue;
00589 
00590                 // if we are skipping the rest of the tests (due to error) note a fault
00591                 if ($skipendpoint) {
00592                     $soap_test->setResult(0,$fault->faultcode, '',
00593                                   $skipfault->faultstring,
00594                                   $skipfault
00595                                   );
00596                     #$endpoint_info['tests'][] = &$soap_test;
00597                     $this->totals['fail']++;
00598                 } else {
00599                     // run the endpoint test
00600                     if ($this->doEndpointMethod($endpoint_info, $soap_test)) {
00601                         $this->totals['success']++;
00602                     } else {
00603                         $skipendpoint = $soap_test->result['fault']->faultcode=='HTTP'
00604                             && strstr($soap_test->result['fault']->faultstring,'Connect Error');
00605                         $skipfault = $soap_test->result['fault'];
00606                         $this->totals['fail']++;
00607                     }
00608                     #$endpoint_info['tests'][] = &$soap_test;
00609                 }
00610                 $soap_test->showTestResult($this->debug, $this->html);
00611                 $this->_saveResults($endpoint_info['id'], $soap_test);
00612                 $soap_test->result = NULL;
00613                 $this->totals['calls']++;
00614             }
00615             if ($this->numservers && ++$i >= $this->numservers) break;
00616         }
00617     }
00618 
00619     function doGroupTests() {
00620         $dowsdl = array(0,1);
00621         foreach($dowsdl as $usewsdl) {
00622             $this->useWSDL = $usewsdl;
00623             foreach($this->paramTypes as $ptype) {
00624                 // skip a pointless test
00625                 if ($usewsdl && $ptype == 'soapval') break;
00626                 $this->paramType = $ptype;
00627                 $this->doTest();
00628             }
00629         }
00630     }
00631 
00638     function doTests() {
00639         // the mother of all interop tests
00640         $dowsdl = array(0,1);
00641         foreach($this->tests as $test) {
00642             $this->currentTest = $test;
00643             foreach($dowsdl as $usewsdl) {
00644                 $this->useWSDL = $usewsdl;
00645                 foreach($this->paramTypes as $ptype) {
00646                     // skip a pointless test
00647                     if ($usewsdl && $ptype == 'soapval') break;
00648                     $this->paramType = $ptype;
00649                     $this->doTest();
00650                 }
00651             }
00652         }
00653     }
00654 
00655     // ***********************************************************
00656     // output functions
00657 
00664     function getMethodList($test = 'base') {
00665         // retreive the results and put them into the endpoint info
00666         $sql = "select distinct(function) from results where class='$test' order by function";
00667         $results = $this->dbc->getAll($sql);
00668         $ar = array();
00669         foreach($results as $result) {
00670             $ar[] = $result[0];
00671         }
00672         return $ar;
00673     }
00674 
00675     function outputTable()
00676     {
00677         $methods = $this->getMethodList($this->currentTest);
00678         if (!$methods) return;
00679         $this->getResults($this->currentTest,$this->paramType,$this->useWSDL);
00680 
00681         echo "<b>Testing $this->currentTest ";
00682         if ($this->useWSDL) echo "using WSDL ";
00683         else echo "using Direct calls ";
00684         echo "with $this->paramType values</b><br>\n";
00685 
00686         // calculate totals for this table
00687         $this->totals['success'] = 0;
00688         $this->totals['fail'] = 0;
00689         $this->totals['servers'] = 0; #count($this->endpoints);
00690         foreach ($this->endpoints as $endpoint => $endpoint_info) {
00691             if (count($endpoint_info['methods']) > 0) {
00692                 $this->totals['servers']++;
00693                 foreach ($methods as $method) {
00694                     $r = $endpoint_info['methods'][$method]['result'];
00695                     if ($r == 'OK') $this->totals['success']++;
00696                     else $this->totals['fail']++;
00697                 }
00698             } else {
00699                 unset($this->endpoints[$endpoint]);
00700             }
00701         }
00702         $this->totals['calls'] = count($methods) * $this->totals['servers'];
00703 
00704         echo "\n\n<b>Servers: {$this->totals['servers']} Calls: {$this->totals['calls']} Success: {$this->totals['success']} Fail: {$this->totals['fail']}</b><br>\n";
00705 
00706         echo "<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">\n";
00707         echo "<tr><td class=\"BLANK\">Endpoint</td>\n";
00708         foreach ($methods as $method) {
00709             $info = split(':', $method);
00710             echo "<td class='BLANK' valign='top'>";
00711             foreach ($info as $m) {
00712                 $hi = split(',',$m);
00713                 echo '<b>'.$hi[0]."</b><br>\n";
00714                 if (count($hi) > 1) {
00715                     echo "&nbsp;&nbsp;Actor=".($hi[1]?'Target':'Not Target')."<br>\n";
00716                     echo "&nbsp;&nbsp;MustUnderstand=$hi[2]<br>\n";
00717                 }
00718             }
00719             echo "</td>\n";
00720         }
00721         echo "</tr>\n";
00722         $faults = array();
00723         $fi = 0;
00724         foreach ($this->endpoints as $endpoint => $endpoint_info) {
00725             if (array_key_exists('wsdlURL',$endpoint_info)) {
00726                 echo "<tr><td class=\"BLANK\"><a href=\"{$endpoint_info['wsdlURL']}\">$endpoint</a></td>\n";
00727             } else {
00728                 echo "<tr><td class=\"BLANK\">$endpoint</td>\n";
00729             }
00730             foreach ($methods as $method) {
00731                 $id = $endpoint_info['methods'][$method]['id'];
00732                 $r = $endpoint_info['methods'][$method]['result'];
00733                 $e = $endpoint_info['methods'][$method]['error'];
00734                 if ($e) {
00735                     $faults[$fi++] = $e;
00736                 }
00737                 if ($r) {
00738                     echo "<td class='$r'><a href='$PHP_SELF?wire=$id'>$r</a></td>\n";
00739                 } else {
00740                     echo "<td class='untested'>untested</td>\n";
00741                 }
00742             }
00743             echo "</tr>\n";
00744         }
00745         echo "</table><br>\n";
00746         if ($this->showFaults && count($faults) > 0) {
00747             echo "<b>ERROR Details:</b><br>\n<ul>\n";
00748             # output more error detail
00749             foreach ($faults as $fault) {
00750                 echo '<li>'.HTMLSpecialChars($fault)."</li>\n";
00751             }
00752         }
00753         echo "</ul><br><br>\n";
00754     }
00755 
00756     function outputTables() {
00757         // the mother of all interop tests
00758         $dowsdl = array(0,1);
00759         foreach($this->tests as $test) {
00760             $this->currentTest = $test;
00761             foreach($dowsdl as $usewsdl) {
00762                 $this->useWSDL = $usewsdl;
00763                 foreach($this->paramTypes as $ptype) {
00764                     // skip a pointless test
00765                     if ($usewsdl && $ptype == 'soapval') break;
00766                     $this->paramType = $ptype;
00767                     $this->outputTable();
00768                 }
00769             }
00770         }
00771     }
00772 
00773     function showWire($id) {
00774         $results = $this->dbc->getAll("select * from results where id=$id",NULL, DB_FETCHMODE_ASSOC );
00775         #$wire = preg_replace("/>/",">\n",$results[0]['wire']);
00776         $wire = $results[0]['wire'];
00777         if ($this->html) print "<pre>";
00778         echo "\n".HTMLSpecialChars($wire);
00779         if ($this->html) print "</pre>";
00780         print "\n";
00781     }
00782 
00783 }
00784 
00785 ?>