SOAP_Interop
[ class tree: SOAP_Interop ] [ index: SOAP_Interop ] [ all elements ]

Source for file interop_client.php

Documentation is available at interop_client.php

  1. <?php
  2. //
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2003 The PHP Group                                |
  7. // +----------------------------------------------------------------------+
  8. // | This source file is subject to version 2.02 of the PHP license,      |
  9. // | that is bundled with this package in the file LICENSE, and is        |
  10. // | available at through the world-wide-web at                           |
  11. // | http://www.php.net/license/2_02.txt.                                 |
  12. // | If you did not receive a copy of the PHP license and are unable to   |
  13. // | obtain it through the world-wide-web, please send a note to          |
  14. // | license@php.net so we can mail you a copy immediately.               |
  15. // +----------------------------------------------------------------------+
  16. // | Authors: Shane Caraveo <Shane@Caraveo.com>                           |
  17. // +----------------------------------------------------------------------+
  18. //
  19. // $Id: interop_client.php,v 1.13 2007/01/21 16:15:00 yunosh Exp $
  20. //
  21. require_once 'DB.php'// PEAR/DB
  22. require_once 'SOAP/Client.php';
  23.  
  24. require_once 'config.php';
  25. require_once 'interop_test_functions.php';
  26. require_once 'interop_test.php';
  27. require_once 'params_Round2Base.php';
  28. require_once 'params_Round2GroupB.php';
  29. require_once 'params_Round2GroupC.php';
  30. require_once 'params_Round3GroupD.php';
  31. require_once 'registrationAndNotification.php';
  32.  
  33. error_reporting(E_ALL ^ E_NOTICE);
  34. $INTEROP_LOCAL_SERVER = false;
  35.  
  36. class Interop_Client
  37. {
  38.     // database DNS
  39.     var $DSN;
  40.  
  41.     // our central interop server, where we can get the list of endpoints
  42.     var $registrationDB;
  43.     
  44.     // our local endpoint, will always get added to the database for all tests
  45.     var $localEndpoint;
  46.     
  47.     // specify testing
  48.     var $currentTest 'Round 2 Base';      // see $tests above
  49.     var $paramType 'php';     // 'php' or 'soapval'
  50.     var $useWSDL = 0;           // 1= do wsdl tests
  51.     var $numServers = 0;        // 0 = all
  52.     var $specificEndpoint ''// test only this endpoint
  53.     var $testMethod '';       // test only this method
  54.     var $skipEndpointList = array()// endpoints to skip
  55.     var $nosave = 0;
  56.     var $client_type 'pear'//  name of client
  57.     
  58.     // debug output
  59.     var $show = 1;
  60.     var $debug = 0;
  61.     var $showFaults = 0; // used in result table output
  62.     
  63.     // PRIVATE VARIABLES
  64.     var $dbc = NULL;
  65.     var $totals = array();
  66.     var $tests = array('Round 2 Base',
  67.                        'Round 2 Group B'
  68.                        'Round 2 Group C'
  69.                        'Round 3 Group D Compound 1',
  70.                        'Round 3 Group D Compound 2',
  71.                        'Round 3 Group D DocLit',
  72.                        'Round 3 Group D DocLitParams',
  73.                        'Round 3 Group D Import 1',
  74.                        'Round 3 Group D Import 2',
  75.                        'Round 3 Group D Import 3',
  76.                        'Round 3 Group D RpcEnc'
  77.             );
  78.     var $paramTypes = array('php''soapval');
  79.     var $endpoints = array();
  80.     
  81.     function Interop_Client({
  82.         global $interopConfig;
  83.         $this->DSN $interopConfig['DSN'];
  84.         $this->registrationDB =new SOAP_Interop_registrationDB();
  85.         
  86.         // XXX for now, share the database for results also
  87.         $this->dbc =$this->registrationDB->dbc;
  88.     }
  89.     
  90.     /**
  91.     *  fetchEndpoints
  92.     * retreive endpoints interop server
  93.     *
  94.     * @return boolean result
  95.     * @access private
  96.     */    
  97.     function fetchEndpoints($name 'Round 2 Base'{
  98.         $service =$this->registrationDB->findService($name);
  99.         $this->endpoints =$this->registrationDB->getServerList($service->id,TRUE);
  100.         return TRUE;
  101.     }
  102.     
  103.     /**
  104.     *  getEndpoints
  105.     * retreive endpoints from either database or interop server
  106.     *
  107.     * @param string name (see local var $tests)
  108.     * @param boolean all (if false, only get valid endpoints, status=1)
  109.     * @return boolean result
  110.     * @access private
  111.     */    
  112.     function getEndpoints($name 'Round 2 Base'$all = 0{
  113.         $service =$this->registrationDB->findService($name);
  114.         $this->endpoints =$this->registrationDB->getServerList($service->id);
  115.         return TRUE;
  116.     }
  117.  
  118.     /**
  119.     *  getResults
  120.     * retreive results from the database, stuff them into the endpoint array
  121.     *
  122.     * @access private
  123.     */
  124.     function getResults($test 'Round 2 Base'$type 'php'$wsdl = 0{
  125.         // be sure we have the right endpoints for this test result
  126.         $this->getEndpoints($test);
  127.         $c count($this->endpoints);
  128.  
  129.         // retreive the results and put them into the endpoint info
  130.         $sql = "select * from results where class='$test' and type='$type' and wsdl=$wsdl";
  131.         $results =$this->dbc->getAll($sql,NULLDB_FETCHMODE_ASSOC );
  132.         $rc count($results);
  133.         for ($j=0; $j $rc$j++{
  134.             $result =$results[$j];
  135.             // find the endpoint
  136.             for ($i=0;$i<$c;$i++{
  137.                 if ($this->endpoints[$i]->id == $result['endpoint']{
  138.                     // store the info
  139.                     if (!isset($this->endpoints[$i]->methods))
  140.                         $this->endpoints[$i]->methods = array();
  141.                     $this->endpoints[$i]->methods[$result['function']] =$result;
  142.                     break;
  143.                 }
  144.             }
  145.         }
  146.     }
  147.     
  148.     /**
  149.     *  saveResults
  150.     * save the results of a method test into the database
  151.     *
  152.     * @access private
  153.     */
  154.     function _saveResults($endpoint_id&$soap_test{
  155.         if ($this->nosavereturn;
  156.         
  157.         $result =$soap_test->result;
  158.         $wire =$result['wire'];
  159.         if ($result['success']{
  160.             $success 'OK';
  161.             $error '';
  162.         else {
  163.             $success $result['fault']->faultcode;
  164.             $error $result['fault']->faultstring;
  165.             if (!$wire$wire$result['fault']->faultdetail;
  166.             if (!$wire$wire$result['fault']->faultstring;
  167.         }
  168.         
  169.         $test_name $soap_test->test_name;
  170.         // add header info to the test name
  171.         if ($soap_test->headers{
  172.             foreach ($soap_test->headers as $h{
  173.                 $destination = 0;
  174.                 if (strtolower(get_class($h)) == 'soap_header'{
  175.                     if ($h->attributes['SOAP-ENV:actor'== 'http://schemas.xmlsoap.org/soap/actor/next'$destination = 1;
  176.                     $test_name .= ":{$h->name},$destination,{$h->attributes['SOAP-ENV:mustUnderstand']}";
  177.                 else {
  178.                     if (!$h[3|| $h[3== 'http://schemas.xmlsoap.org/soap/actor/next'$destination = 1;
  179.                     if (!$h[2]$h[2= 0;
  180.                     $qn =new QName($h[0]);
  181.                     $test_name .= ":{$qn->name},$destination,".(int)$h[2];
  182.                 }
  183.             }
  184.         }
  185.         
  186.         $sql = "delete from results where endpoint=$endpoint_id ".
  187.                     "and class='$this->currentTest' and type='$this->paramType".
  188.                     "and wsdl=$this->useWSDL and client='$this->client_type' and function=".
  189.                     $this->dbc->quote($test_name);
  190.         #echo "\n".$sql;
  191.         $res =$this->dbc->query($sql);
  192.         if (DB::isError($res)) {
  193.             die ($res->getMessage());
  194.         }
  195.         if (is_object($res)) $res->free();
  196.         
  197.         $sql "insert into results (client,endpoint,stamp,class,type,wsdl,function,result,error,wire) ".
  198.                     "values('$this->client_type',$endpoint_id,".time().",'$this->currentTest',".
  199.                     "'$this->paramType',$this->useWSDL,".
  200.                     $this->dbc->quote($test_name).",".
  201.                     $this->dbc->quote($success).",".
  202.                     $this->dbc->quote($error).",".
  203.                     ($wire?$this->dbc->quote($wire):"''").")";
  204.         #echo "\n".$sql;
  205.         $res =$this->dbc->query($sql);
  206.         
  207.         if (DB::isError($res)) {
  208.             die ($res->getMessage());
  209.         }
  210.         if (is_object($res)) $res->free();
  211.     }
  212.  
  213.     /**
  214.     *  compareResult
  215.     * compare two php types for a match
  216.     *
  217.     * @param string expect
  218.     * @param string test_result
  219.     * @return boolean result
  220.     * @access public
  221.     */    
  222.     function compareResult(&$expect&$result$type = NULL)
  223.     {
  224.         $ok = 0;
  225.         $expect_type gettype($expect);
  226.         $result_type gettype($result);
  227.         if ($expect_type == "array" && $result_type == "array"{
  228.             # compare arrays
  229.             $ok array_compare($expect$result);
  230.         else {
  231.             if ($type == 'float')
  232.                 # we'll only compare to 3 digits of precision
  233.                 $ok number_compare($expect$result);
  234.             if ($type == 'boolean')
  235.                 $ok boolean_compare($expect$result);
  236.             else
  237.                 $ok string_compare($expect$result);
  238.         }
  239.         return $ok;
  240.     }
  241.  
  242.  
  243.     /**
  244.     *  doEndpointMethod
  245.     *  run a method on an endpoint and store it's results to the database
  246.     *
  247.     * @param array endpoint_info
  248.     * @param SOAP_Test test
  249.     * @return boolean result
  250.     * @access public
  251.     */    
  252.     function doEndpointMethod(&$endpoint_info&$soap_test{
  253.         $ok = FALSE;
  254.         
  255.         // prepare a holder for the test results
  256.         $soap_test->result['class'$this->currentTest;
  257.         $soap_test->result['type'$this->paramType;
  258.         $soap_test->result['wsdl'$this->useWSDL;
  259.         $opdata = NULL;
  260.         #global $soap_value_total;
  261.         #print "SOAP VALUES TEST-START: $soap_value_total\n";
  262.         
  263.         if ($this->useWSDL{
  264.             if ($endpoint_info->wsdlURL{
  265.                 if (!$endpoint_info->client{
  266.                     if (/* dynamic client */{
  267.                     $endpoint_info->wsdl =new SOAP_WSDL($endpoint_info->wsdlURL);
  268.                     $endpoint_info->wsdl->trace=1;
  269.                     $endpoint_info->client =$endpoint_info->wsdl->getProxy('',$endpoint_info->name);
  270.                     else {
  271.                     $endpoint_info->client =new SOAP_Client($endpoint_info->wsdlURL,1);
  272.                     }
  273.                     $endpoint_info->client->_auto_translation = true;
  274.                 }
  275.                 if ($endpoint_info->client->_wsdl->__isfault()) {
  276.                     $fault =$endpoint_info->client->_wsdl->fault->getFault();
  277.                     $detail $fault->faultstring."\n\n".$fault->faultdetail;
  278.                     $soap_test->setResult(0,'WSDL',
  279.                                             $detail,
  280.                                             $fault->faultstring,
  281.                                             $fault
  282.                                             );
  283.                     return FALSE;
  284.                 }
  285.                 if ($soap_test->service{
  286.                     $endpoint_info->client->_wsdl->set_service($soap_test->service);
  287.                 }
  288.                 $soap =$endpoint_info->client;
  289.                 #$port = $soap->_wsdl->getPortName($soap_test->method_name);
  290.                 #$opdata = $soap->_wsdl->getOperationData($port, $soap_test->method_name);
  291.             else {
  292.                 $fault = array(
  293.                     'faultcode'=>'WSDL',
  294.                     'faultstring'=>"no WSDL defined for $endpoint");
  295.                 $soap_test->setResult(0,'WSDL',
  296.                                       $fault->faultstring,
  297.                                       $fault->faultstring,
  298.                                       $fault
  299.                                       );
  300.                 return FALSE;
  301.             }
  302.             $options = array('trace'=>1);
  303.         else {
  304.             $namespace $soapaction 'http://soapinterop.org/';
  305.             // hack to make tests work with MS SoapToolkit
  306.             // it's the only one that uses this soapaction, and breaks if
  307.             // it isn't right.  Can't wait for soapaction to be fully depricated
  308.             # 8/25/2002, seems this is fixed now
  309.             #if ($this->currentTest == 'Round 2 Base' &&
  310.             #    strstr($endpoint_info->name,'MS SOAP ToolKit 2.0')) {
  311.             #    $soapaction = 'urn:soapinterop';
  312.             #}
  313.             if (!$endpoint_info->client{
  314.                 $endpoint_info->client =new SOAP_Client($endpoint_info->endpointURL);
  315.                 $endpoint_info->client->_auto_translation = true;
  316.             }
  317.             $soap &$endpoint_info->client;
  318.             $options = array('namespace'=>$namespace
  319.                          'soapaction'=>$soapaction,
  320.                          'trace'=>1);
  321.         }
  322.         
  323.         // add headers to the test
  324.         if ($soap_test->headers{
  325.             // $header is already a SOAP_Header class
  326.             $soap->headersOut = array();
  327.             $soap->headersIn = array();
  328.             $hc count($soap_test->headers);
  329.             for ($i=0; $i $hc$i++{
  330.                 $soap->addHeader($soap_test->headers[$i]);
  331.             }
  332.         }
  333.         $soap->setEncoding($soap_test->encoding);
  334.         
  335.  
  336.         #if ($opdata) {
  337.         #    if (isset($opdata['style'])) 
  338.         #        $options['style'] = $opdata['style'];
  339.         #    if (isset($opdata['soapAction'])) 
  340.         #        $options['soapaction'] = $opdata['soapAction'];
  341.         #    if (isset($opdata['input']) &&
  342.         #        isset($opdata['input']['use']))
  343.         #        $options['use'] = $opdata['input']['use'];
  344.         #    if (isset($opdata['input']) &&
  345.         #        isset($opdata['input']['namespace']))
  346.         #        $options['namespace'] = $soap->_wsdl->namespaces[$opdata['input']['namespace']];
  347.         #}
  348.         #if ($this->useWSDL) {
  349.         #    $wsdlcall = '$return = $soap->'.$soap_test->method_name.'(';
  350.         #    $args = '';
  351.         #    if ($soap_test->method_params) {
  352.         #    $pnames = array_keys($soap_test->method_params);
  353.         #    foreach ($pnames as $argname) {
  354.         #        if ($args) $args .=',';
  355.         #        $args .= '$soap_test->method_params[\''.$argname.'\']';
  356.         #    }
  357.         #    }
  358.         #    $wsdlcall = $wsdlcall.$args.');';
  359.         #    eval($wsdlcall);
  360.         #} else {
  361.             $return =$soap->call($soap_test->method_name,$soap_test->method_params$options);
  362.         #}
  363.         
  364.         if(!PEAR::isError($return)){
  365.             if (is_array($soap_test->method_params&& count($soap_test->method_params== 1{
  366.                 $sent array_shift(array_values($soap_test->method_params));
  367.             else {
  368.                 $sent $soap_test->method_params;
  369.             }
  370.  
  371.             // compare header results
  372.             $header_result = array();
  373.             $headers_ok = TRUE;
  374.             if ($soap_test->headers{
  375.                 // $header is already a SOAP_Header class
  376.                 $hc count($soap_test->headers);
  377.                 for ($i=0; $i $hc$i++{
  378.                     $header =$soap_test->headers[$i];
  379.                     if (strtolower(get_class($header)) != 'soap_header'{
  380.                         // assume it's an array
  381.                         $header =new SOAP_Header($header[0]NULL$header[1]$header[2]$header[3]$header[4]);
  382.                     }
  383.                     $expect $soap_test->headers_expect[$header->name];
  384.                     $header_result[$header->name= array();
  385.                     // XXX need to fix need_result to identify the actor correctly
  386.                     $need_result $hresult ||
  387.                         ($header->attributes['SOAP-ENV:actor'== 'http://schemas.xmlsoap.org/soap/actor/next'
  388.                          && $header->attributes['SOAP-ENV:mustUnderstand']);
  389.                     if ($expect{
  390.                         $hresult $soap->headersIn[key($expect)];
  391.                         $ok !$need_result || $this->compareResult($hresult ,$expect[key($expect)]);
  392.                     else {
  393.                         $hresult $soap->headersIn[$header->name];
  394.                         $expect =$soap->_decode($header);
  395.                         $ok !$need_result || $this->compareResult($hresult ,$expect);
  396.                     }
  397.                     $header_result[$header->name]['ok'$ok;
  398.                     if (!$ok$headers_ok = FALSE;
  399.                 }
  400.             }
  401.  
  402.             # we need to decode what we sent so we can compare!
  403.             if (gettype($sent== 'object' && (strtolower(get_class($sent)) == 'soap_value' ||
  404.                             is_subclass_of($sent,'soap_value')))
  405.                 $sent_d =$soap->_decode($sent);
  406.             else
  407.                 $sent_d =$sent;
  408.             
  409.             #$soap_test->result['sent'] =& $sent;
  410.             #$soap_test->result['return'] =& $return;
  411.             // compare the results with what we sent
  412.             $ok $this->compareResult($sent_d,$return$sent->type);
  413.             unset($sent_d);
  414.             unset($sent);
  415.             if (!$ok && $soap_test->expect{
  416.                 $ok $this->compareResult($soap_test->expect,$return);
  417.             }
  418.             
  419.             if($ok){
  420.                 if (!$headers_ok{
  421.                     $fault =new stdclass;
  422.                     $fault->faultcode = 'HEADER';
  423.                     $fault->faultstring = 'The returned result did not match what we expected to receive';
  424.                     $soap_test->setResult(0,$fault->faultcode,
  425.                                       $soap->__get_wire(),
  426.                                       $fault->faultstring,
  427.                                       $fault
  428.                                       );
  429.                 else {
  430.                     $soap_test->setResult(1,'OK',$soap->__get_wire());
  431.                     $success = TRUE;
  432.                 }
  433.             else {
  434.                 $fault =new stdclass();
  435.                 $fault->faultcode = 'RESULT';
  436.                 $fault->faultstring = 'The returned result did not match what we expected to receive';
  437.                 $fault->faultdetail = ''/*"SENT:\n".var_export($soap_test->result['sent']).
  438.                                                "\n\nRECIEVED:\n".var_export($soap_test->result['return'])*/;
  439.                 $soap_test->setResult(0,$fault->faultcode,
  440.                                   $soap->__get_wire(),
  441.                                   $fault->faultstring,
  442.                                   $fault
  443.                                   );
  444.             }
  445.         else {
  446.             $fault $return->getFault();
  447.             if ($soap_test->expect_fault{
  448.                 $ok = 1;
  449.                 $res 'OK';
  450.             else {
  451.                 $ok = 0;
  452.                 $res =$fault->faultcode;
  453.             }
  454.             $soap_test->setResult($ok,$res$soap->__get_wire(),$fault->faultstring$fault);
  455.         }
  456.         $soap->_reset();
  457.         unset($return);
  458.         #print "SOAP VALUES TEST-END: $soap_value_total\n";
  459.         return $ok;
  460.     }
  461.     
  462.  
  463.     /**
  464.     *  doTest
  465.     *  run a single round of tests
  466.     *
  467.     * @access public
  468.     */    
  469.     function doTest({
  470.         global $soap_tests;
  471.         $empty_string='';
  472.         // get endpoints for this test
  473.         if (!$this->currentTest{
  474.             die("Asked to run a test, but no testname!\n");
  475.         }
  476.         $this->getEndpoints($this->currentTest);
  477.         #clear totals
  478.         $this->totals = array();
  479.         
  480.         $c count($this->endpoints);
  481.         for ($i=0; $i<$c$i++{
  482.             $endpoint_info =$this->endpoints[$i];
  483.             // if we specify an endpoint, skip until we find it
  484.             if ($this->specificEndpoint && $endpoint_info->name != $this->specificEndpointcontinue;
  485.             if ($this->useWSDL && !$endpoint_info->wsdlURLcontinue;
  486.             
  487.             $skipendpoint = FALSE;
  488.             $this->totals['servers']++;
  489.             #$endpoint_info['tests'] = array();
  490.             
  491.             if ($this->showprint "Processing {$endpoint_info->name} at {$endpoint_info->endpointURL}\n";
  492.             
  493.             $tc count($soap_tests[$this->currentTest]);
  494.             for($ti=0; $ti<$tc$ti++{
  495.                 $soap_test =$soap_tests[$this->currentTest][$ti];
  496.             
  497.                 // only run the type of test we're looking for (php or soapval)
  498.                 if ($soap_test->type != $this->paramTypecontinue;
  499.             
  500.                 // if this is in our skip list, skip it
  501.                 if (in_array($endpoint_info->name$this->skipEndpointList)) {
  502.                     $skipendpoint = TRUE;
  503.                     $skipfault =new stdclass;
  504.                     $skipfault->faultcode='SKIP';
  505.                     $skipfault->faultstring='endpoint skipped';
  506.                     $soap_test->setResult(0,$skipfault->faultcode$empty_string,
  507.                                   $skipfault->faultstring,
  508.                                   $skipfault
  509.                                   );
  510.                     #$endpoint_info['tests'][] = &$soap_test;
  511.                     #$soap_test->showTestResult($this->debug);
  512.                     #$this->_saveResults($endpoint_info['id'], $soap_test->method_name);
  513.                     $soap_test->result = NULL;
  514.                     continue;
  515.                 }
  516.                 
  517.                 // if we're looking for a specific method, skip unless we have it
  518.                 if ($this->testMethod && strcmp($this->testMethod,$soap_test->test_name)!=0continue;
  519.                 if ($this->testMethod && $this->currentTest == 'Round 2 Group C'{
  520.                     // we have to figure things out now
  521.                     if (!preg_match('/(.*):(.*),(\d),(\d)/',$this->testMethod$m)) continue;
  522.                     
  523.                     // is the header in the headers list?
  524.                     $gotit = FALSE;
  525.                     $thc count($soap_test->headers);
  526.                     for ($thi = 0; $thi $thc$thi++{
  527.                         $header =$soap_test->headers[$thi];
  528.                         if (strtolower(get_class($header)) == 'soap_header'{
  529.                             if ($header->name == $m[2]{
  530.                                 $gotit $header->attributes['SOAP-ENV:actor'== ($m[3]?SOAP_TEST_ACTOR_NEXTSOAP_TEST_ACTOR_OTHER);
  531.                                 $gotit $gotit && $header->attributes['SOAP-ENV:mustUnderstand'== $m[4];
  532.                             }
  533.                         else {
  534.                             if ($header[0== $m[2]{
  535.                                 $gotit $gotit && $header[3== ($m[3]?SOAP_TEST_ACTOR_NEXTSOAP_TEST_ACTOR_OTHER);
  536.                                 $gotit $gotit && $header[4== $m[4];
  537.                             }
  538.                         }
  539.                     }
  540.                     if (!$gotitcontinue;
  541.                 }
  542.             
  543.                 // if we are skipping the rest of the tests (due to error) note a fault
  544.                 if ($skipendpoint{
  545.                     
  546.                     $soap_test->setResult(0,$skipfault->faultcode$empty_string,
  547.                                   $skipfault->faultstring,
  548.                                   $skipfault
  549.                                   );
  550.                     #$endpoint_info['tests'][] = &$soap_test;
  551.                     $this->totals['fail']++;
  552.                 else {
  553.                     // run the endpoint test
  554.                     unset($soap_test->result);
  555.                     if ($this->doEndpointMethod($endpoint_info$soap_test)) {
  556.                         $this->totals['success']++;
  557.                     else {
  558.                         $skipendpoint $soap_test->result['fault']->faultcode=='HTTP';
  559.                         if ($skipendpoint$skipfault $soap_test->result['fault'];
  560.                         else  $skipfault = NULL;
  561.                         $this->totals['fail']++;
  562.                     }
  563.                     #$endpoint_info['tests'][] = &$soap_test;
  564.                 }
  565.                 $soap_test->showTestResult($this->debug);
  566.                 $this->_saveResults($endpoint_info->id$soap_test);
  567.                 $soap_test->reset();
  568.                 $this->totals['calls']++;
  569.             }
  570.             unset($endpoint_info->client);
  571.             if ($this->numservers && ++$i >= $this->numserversbreak;
  572.         }
  573.     }
  574.     
  575.     function doGroupTests({
  576.         $dowsdl = array(0,1);
  577.         foreach($dowsdl as $usewsdl{
  578.             $this->useWSDL $usewsdl;
  579.             foreach($this->paramTypes as $ptype{
  580.                 // skip a pointless test
  581.                 if ($usewsdl && $ptype == 'soapval'break;
  582.                 if (stristr($this->currentTest'Round 3'&& !$usewsdlbreak;
  583.                 $this->paramType $ptype;
  584.                 $this->doTest();
  585.             }
  586.         }
  587.     }
  588.     
  589.     /**
  590.     *  doTests
  591.     *  go all out.  This takes time.
  592.     *
  593.     * @access public
  594.     */    
  595.     function doTests({
  596.         // the mother of all interop tests
  597.         $dowsdl = array(0,1);
  598.         foreach($this->tests as $test{
  599.             $this->currentTest $test;
  600.             foreach($dowsdl as $usewsdl{
  601.                 $this->useWSDL $usewsdl;
  602.                 foreach($this->paramTypes as $ptype{
  603.                     // skip a pointless test
  604.                     if ($usewsdl && $ptype == 'soapval'break;
  605.                     if (stristr($this->currentTest'Round 3'&& !$usewsdlbreak;
  606.                     $this->paramType $ptype;
  607.                     $this->doTest();
  608.                 }
  609.             }
  610.         }
  611.     }
  612.     
  613.     // ***********************************************************
  614.     // output functions
  615.     
  616.     /**
  617.     *  getResults
  618.     * retreive results from the database, stuff them into the endpoint array
  619.     *
  620.     * @access private
  621.     */
  622.     function getMethodList($test 'base'{
  623.         $this->dbc->setFetchMode(DB_FETCHMODE_ORDERED);
  624.         // retreive the results and put them into the endpoint info
  625.         $sql = "select distinct(function) from results where client='$this->client_type' and class='$test' order by function";
  626.         $results $this->dbc->getAll($sql);
  627.         $ar = array();
  628.         foreach($results as $result{
  629.             $ar[$result[0];
  630.         }
  631.         return $ar;
  632.     }
  633.     
  634.     function outputTable()
  635.     {
  636.         $methods $this->getMethodList($this->currentTest);
  637.         if (!$methodsreturn;
  638.         $this->getResults($this->currentTest,$this->paramType,$this->useWSDL);
  639.         
  640.         echo "<b>Testing $this->currentTest ";
  641.         if ($this->useWSDLecho "using WSDL ";
  642.         else echo "using Direct calls ";
  643.         echo "with $this->paramType values</b><br>\n";
  644.         
  645.         // calculate totals for this table
  646.         $this->totals['success'= 0;
  647.         $this->totals['fail'= 0;
  648.         $this->totals['result'= 0;
  649.         $this->totals['wsdl'= 0;
  650.         $this->totals['connect'= 0;
  651.         $this->totals['servers'= 0; #count($this->endpoints);
  652.         $c count ($this->endpoints);
  653.         for ($i=0;$i<$c;$i++{
  654.             $endpoint_info =$this->endpoints[$i];
  655.             if (!$endpoint_info->namecontinue;
  656.             if (count($endpoint_info->methods> 0{
  657.                 $this->totals['servers']++;
  658.                 foreach ($methods as $method{
  659.                     $r $endpoint_info->methods[$method]['result'];
  660.                     if ($r == 'OK'$this->totals['success']++;
  661.                     else if (stristr($r,'result')) $this->totals['result']++;
  662.                     else if (stristr($r,'wsdlcache')) $this->totals['connect']++;
  663.                     else if (stristr($r,'wsdl')) $this->totals['wsdl']++;
  664.                     else if (stristr($r,'http')) $this->totals['connect']++;
  665.                     else $this->totals['fail']++;
  666.                 }
  667.             else {
  668.                 //unset($this->endpoints[$i]);
  669.             }
  670.         }
  671.         $this->totals['calls'count($methods$this->totals['servers'];
  672.  
  673.         #if ($this->totals['fail'] == $this->totals['calls']) {
  674.         #    // assume tests have not run, skip outputing table
  675.         #    print "No Data Available<br>\n";
  676.         #    return;
  677.         #}
  678.         
  679.         echo "\n\n<b>Servers: {$this->totals['servers']} Calls: {$this->totals['calls']} ".
  680.             "Success: {$this->totals['success']} <br>\n".
  681.             "System-Fail: {$this->totals['fail']} Result-Failure: {$this->totals['result']} ".
  682.             "Connect-Failure: {$this->totals['connect']} WSDL-Failure: {$this->totals['wsdl']} </b><br>\n";
  683.        
  684.         echo "<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">\n";
  685.         echo "<tr><td class=\"BLANK\">Endpoint</td>\n";
  686.         foreach ($methods as $method{
  687.             $info split(':'$method);
  688.             echo "<td class='BLANK' valign='top'>";
  689.             foreach ($info as $m{
  690.                 $hi split(',',$m);
  691.                 echo '<b>'.$hi[0]."</b><br>\n";
  692.                 if (count($hi> 1{
  693.                     echo "&nbsp;&nbsp;Actor=".($hi[1]?'Target':'Not Target')."<br>\n";
  694.                     echo "&nbsp;&nbsp;MustUnderstand=$hi[2]<br>\n";
  695.                 }
  696.             }
  697.             echo "</td>\n";
  698.         }
  699.         echo "</tr>\n";
  700.         $faults = array();
  701.         $fi = 0;
  702.         $c count ($this->endpoints);
  703.         for ($i=0;$i<$c;$i++{
  704.             $endpoint_info =$this->endpoints[$i];
  705.             if (!$endpoint_info->namecontinue;
  706.             if ($endpoint_info->wsdlURL{
  707.                 echo "<tr><td class=\"BLANK\"><a href=\"{$endpoint_info->wsdlURL}\">{$endpoint_info->name}</a></td>\n";
  708.             else {
  709.                 echo "<tr><td class=\"BLANK\">{$endpoint_info->name}</td>\n";
  710.             }
  711.             foreach ($methods as $method{
  712.                 $id $endpoint_info->methods[$method]['id'];
  713.                 $r $endpoint_info->methods[$method]['result'];
  714.                 $e $endpoint_info->methods[$method]['error'];
  715.                 if ($e{
  716.                     $faults[$fi++$e;
  717.                 }
  718.                 if ($r{
  719.                     echo "<td class='$r'><a href='$PHP_SELF?wire=$id'>$r</a></td>\n";
  720.                 else {
  721.                     echo "<td class='untested'>untested</td>\n";
  722.                 }
  723.             }
  724.             echo "</tr>\n";
  725.         }
  726.         echo "</table><br>\n";
  727.         if ($this->showFaults && count($faults> 0{
  728.             echo "<b>ERROR Details:</b><br>\n<ul>\n";
  729.             # output more error detail
  730.             foreach ($faults as $fault{
  731.                 echo '<li>'.HTMLSpecialChars($fault)."</li>\n";
  732.             }
  733.         }
  734.         echo "</ul><br><br>\n";
  735.     }
  736.     
  737.     function outputTables({
  738.         // the mother of all interop tests
  739.         $dowsdl = array(0,1);
  740.         foreach($this->tests as $test{
  741.             $this->currentTest $test;
  742.             foreach($dowsdl as $usewsdl{
  743.                 $this->useWSDL $usewsdl;
  744.                 foreach($this->paramTypes as $ptype{
  745.                     // skip a pointless test
  746.                     if ($usewsdl && $ptype == 'soapval'break;
  747.                     if (stristr($this->currentTest'Round 3'&& !$usewsdlbreak;
  748.                     $this->paramType $ptype;
  749.                     $this->outputTable();
  750.                 }
  751.             }
  752.         }
  753.     }
  754.     
  755.     function showWire($id{
  756.         $results $this->dbc->getAll("select * from results where id=$id",NULLDB_FETCHMODE_ASSOC );
  757.         #$wire = preg_replace("/>/",">\n",$results[0]['wire']);
  758.         $wire $results[0]['wire'];
  759.         echo "<pre>\n".HTMLSpecialChars($wire)."</pre>\n";
  760.     }
  761.  
  762. }
  763.  
  764. ?>

Documentation generated on Mon, 11 Mar 2019 14:54:33 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.