Source for file interop_client.php
Documentation is available at interop_client.php
// +----------------------------------------------------------------------+
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2003 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> |
// +----------------------------------------------------------------------+
// $Id: interop_client.php,v 1.13 2007/01/21 16:15:00 yunosh Exp $
require_once 'DB.php'; // PEAR/DB
require_once 'SOAP/Client.php';
require_once 'config.php';
require_once 'interop_test_functions.php';
require_once 'interop_test.php';
require_once 'params_Round2Base.php';
require_once 'params_Round2GroupB.php';
require_once 'params_Round2GroupC.php';
require_once 'params_Round3GroupD.php';
require_once 'registrationAndNotification.php';
$INTEROP_LOCAL_SERVER = false;
// our central interop server, where we can get the list of endpoints
// our local endpoint, will always get added to the database for all tests
var $currentTest = 'Round 2 Base'; // see $tests above
var $paramType = 'php'; // 'php' or 'soapval'
var $useWSDL = 0; // 1= do wsdl tests
var $numServers = 0; // 0 = all
var $specificEndpoint = ''; // test only this endpoint
var $testMethod = ''; // test only this method
var $skipEndpointList = array (); // endpoints to skip
var $client_type = 'pear'; // name of client
var $showFaults = 0; // used in result table output
var $tests = array ('Round 2 Base',
'Round 3 Group D Compound 1',
'Round 3 Group D Compound 2',
'Round 3 Group D DocLit',
'Round 3 Group D DocLitParams',
'Round 3 Group D Import 1',
'Round 3 Group D Import 2',
'Round 3 Group D Import 3',
var $paramTypes = array ('php', 'soapval');
var $endpoints = array ();
function Interop_Client () {
$this->DSN = $interopConfig['DSN'];
$this->registrationDB = & new SOAP_Interop_registrationDB ();
// XXX for now, share the database for results also
$this->dbc = & $this->registrationDB->dbc;
* retreive endpoints interop server
function fetchEndpoints ($name = 'Round 2 Base') {
$service = & $this->registrationDB->findService ($name);
$this->endpoints = & $this->registrationDB->getServerList ($service->id ,TRUE );
* retreive endpoints from either database or interop server
* @param string name (see local var $tests)
* @param boolean all (if false, only get valid endpoints, status=1)
function getEndpoints ($name = 'Round 2 Base', $all = 0 ) {
$service = & $this->registrationDB->findService ($name);
$this->endpoints = & $this->registrationDB->getServerList ($service->id );
* retreive results from the database, stuff them into the endpoint array
function getResults ($test = 'Round 2 Base', $type = 'php', $wsdl = 0 ) {
// be sure we have the right endpoints for this test result
$this->getEndpoints ($test);
$c = count($this->endpoints);
// retreive the results and put them into the endpoint info
$sql = " select * from results where class='$test' and type='$type' and wsdl=$wsdl";
$results = & $this->dbc->getAll ($sql,NULL , DB_FETCHMODE_ASSOC );
for ($j=0; $j < $rc; $j++ ) {
if ($this->endpoints[$i]->id == $result['endpoint']) {
if (!isset ($this->endpoints[$i]->methods ))
$this->endpoints[$i]->methods = array ();
$this->endpoints[$i]->methods [$result['function']] = & $result;
* save the results of a method test into the database
function _saveResults ($endpoint_id, &$soap_test) {
if ($this->nosave) return;
$result = & $soap_test->result;
$wire = & $result['wire'];
if ($result['success']) {
$success = $result['fault']->faultcode;
$error = $result['fault']->faultstring;
if (!$wire) $wire= $result['fault']->faultdetail;
if (!$wire) $wire= $result['fault']->faultstring;
$test_name = $soap_test->test_name;
// add header info to the test name
if ($soap_test->headers ) {
foreach ($soap_test->headers as $h) {
if ($h->attributes ['SOAP-ENV:actor'] == 'http://schemas.xmlsoap.org/soap/actor/next') $destination = 1;
$test_name .= " :{$h->name },$destination,{$h->attributes ['SOAP-ENV:mustUnderstand']}";
if (!$h[3 ] || $h[3 ] == 'http://schemas.xmlsoap.org/soap/actor/next') $destination = 1;
$test_name .= " :{$qn->name },$destination,".(int) $h[2 ];
$sql = " delete from results where endpoint=$endpoint_id ".
" and class='$this->currentTest' and type='$this->paramType' ".
" and wsdl=$this->useWSDL and client='$this->client_type' and function=".
$this->dbc->quote ($test_name);
$res = & $this->dbc->query ($sql);
die ($res->getMessage ());
$sql = "insert into results (client,endpoint,stamp,class,type,wsdl,function,result,error,wire) ".
" values('$this->client_type',$endpoint_id,". time()." ,'$this->currentTest',".
" '$this->paramType',$this->useWSDL,".
$this->dbc->quote ($test_name). ",".
$this->dbc->quote ($success). ",".
$this->dbc->quote ($error). ",".
($wire? $this->dbc->quote ($wire): "''"). ")";
$res = & $this->dbc->query ($sql);
die ($res->getMessage ());
* compare two php types for a match
* @param string test_result
function compareResult (&$expect, &$result, $type = NULL )
if ($expect_type == "array" && $result_type == "array") {
# we'll only compare to 3 digits of precision
* run a method on an endpoint and store it's results to the database
* @param array endpoint_info
function doEndpointMethod (&$endpoint_info, &$soap_test) {
// prepare a holder for the test results
$soap_test->result ['class'] = $this->currentTest;
$soap_test->result ['type'] = $this->paramType;
$soap_test->result ['wsdl'] = $this->useWSDL;
#global $soap_value_total;
#print "SOAP VALUES TEST-START: $soap_value_total\n";
if ($endpoint_info->wsdlURL ) {
if (!$endpoint_info->client ) {
if (0 /* dynamic client */) {
$endpoint_info->wsdl = & new SOAP_WSDL ($endpoint_info->wsdlURL );
$endpoint_info->wsdl ->trace=1;
$endpoint_info->client = & $endpoint_info->wsdl ->getProxy ('',$endpoint_info->name );
$endpoint_info->client = & new SOAP_Client ($endpoint_info->wsdlURL ,1 );
$endpoint_info->client ->_auto_translation = true;
if ($endpoint_info->client ->_wsdl ->__isfault ()) {
$fault = & $endpoint_info->client ->_wsdl ->fault ->getFault ();
$detail = $fault->faultstring. "\n\n". $fault->faultdetail;
$soap_test->setResult (0 ,'WSDL',
if ($soap_test->service ) {
$endpoint_info->client ->_wsdl ->set_service ($soap_test->service );
$soap = & $endpoint_info->client;
#$port = $soap->_wsdl->getPortName($soap_test->method_name);
#$opdata = $soap->_wsdl->getOperationData($port, $soap_test->method_name);
'faultstring'=>" no WSDL defined for $endpoint" );
$soap_test->setResult (0 ,'WSDL',
$options = array ('trace'=>1 );
$namespace = $soapaction = 'http://soapinterop.org/';
// hack to make tests work with MS SoapToolkit
// it's the only one that uses this soapaction, and breaks if
// it isn't right. Can't wait for soapaction to be fully depricated
# 8/25/2002, seems this is fixed now
#if ($this->currentTest == 'Round 2 Base' &&
# strstr($endpoint_info->name,'MS SOAP ToolKit 2.0')) {
# $soapaction = 'urn:soapinterop';
if (!$endpoint_info->client ) {
$endpoint_info->client = & new SOAP_Client ($endpoint_info->endpointURL );
$endpoint_info->client ->_auto_translation = true;
$soap = &$endpoint_info->client;
$options = array ('namespace'=> $namespace,
'soapaction'=> $soapaction,
// add headers to the test
if ($soap_test->headers ) {
// $header is already a SOAP_Header class
$soap->headersOut = array ();
$soap->headersIn = array ();
$hc = count($soap_test->headers );
for ($i=0; $i < $hc; $i++ ) {
$soap->addHeader ($soap_test->headers [$i]);
$soap->setEncoding ($soap_test->encoding );
# if (isset($opdata['style']))
# $options['style'] = $opdata['style'];
# if (isset($opdata['soapAction']))
# $options['soapaction'] = $opdata['soapAction'];
# if (isset($opdata['input']) &&
# isset($opdata['input']['use']))
# $options['use'] = $opdata['input']['use'];
# if (isset($opdata['input']) &&
# isset($opdata['input']['namespace']))
# $options['namespace'] = $soap->_wsdl->namespaces[$opdata['input']['namespace']];
# $wsdlcall = '$return = $soap->'.$soap_test->method_name.'(';
# if ($soap_test->method_params) {
# $pnames = array_keys($soap_test->method_params);
# foreach ($pnames as $argname) {
# if ($args) $args .=',';
# $args .= '$soap_test->method_params[\''.$argname.'\']';
# $wsdlcall = $wsdlcall.$args.');';
$return = & $soap->call ($soap_test->method_name ,$soap_test->method_params , $options);
if(!PEAR ::isError ($return)){
if (is_array($soap_test->method_params ) && count($soap_test->method_params ) == 1 ) {
$sent = $soap_test->method_params;
// compare header results
$header_result = array ();
if ($soap_test->headers ) {
// $header is already a SOAP_Header class
$hc = count($soap_test->headers );
for ($i=0; $i < $hc; $i++ ) {
$header = & $soap_test->headers [$i];
$header = & new SOAP_Header ($header[0 ], NULL , $header[1 ], $header[2 ], $header[3 ], $header[4 ]);
$expect = $soap_test->headers_expect [$header->name ];
$header_result[$header->name ] = array ();
// XXX need to fix need_result to identify the actor correctly
$need_result = $hresult ||
($header->attributes ['SOAP-ENV:actor'] == 'http://schemas.xmlsoap.org/soap/actor/next'
&& $header->attributes ['SOAP-ENV:mustUnderstand']);
$hresult = $soap->headersIn [key($expect)];
$ok = !$need_result || $this->compareResult ($hresult ,$expect[key($expect)]);
$hresult = $soap->headersIn [$header->name ];
$expect = & $soap->_decode ($header);
$ok = !$need_result || $this->compareResult ($hresult ,$expect);
$header_result[$header->name ]['ok'] = $ok;
if (!$ok) $headers_ok = FALSE;
# we need to decode what we sent so we can compare!
$sent_d = & $soap->_decode ($sent);
#$soap_test->result['sent'] =& $sent;
#$soap_test->result['return'] =& $return;
// compare the results with what we sent
$ok = $this->compareResult ($sent_d,$return, $sent->type );
if (!$ok && $soap_test->expect ) {
$ok = $this->compareResult ($soap_test->expect ,$return);
$fault->faultcode = 'HEADER';
$fault->faultstring = 'The returned result did not match what we expected to receive';
$soap_test->setResult (0 ,$fault->faultcode ,
$soap_test->setResult (1 ,'OK',$soap->__get_wire ());
$fault = & new stdclass ();
$fault->faultcode = 'RESULT';
$fault->faultstring = 'The returned result did not match what we expected to receive';
$fault->faultdetail = ''/*"SENT:\n".var_export($soap_test->result['sent']).
"\n\nRECIEVED:\n".var_export($soap_test->result['return'])*/;
$soap_test->setResult (0 ,$fault->faultcode ,
$fault = $return->getFault ();
if ($soap_test->expect_fault ) {
$soap_test->setResult ($ok,$res, $soap->__get_wire (),$fault->faultstring , $fault);
#print "SOAP VALUES TEST-END: $soap_value_total\n";
* run a single round of tests
// get endpoints for this test
if (!$this->currentTest) {
die ("Asked to run a test, but no testname!\n");
$this->getEndpoints ($this->currentTest);
$c = count($this->endpoints);
for ($i=0; $i< $c; $i++ ) {
$endpoint_info = & $this->endpoints[$i];
// if we specify an endpoint, skip until we find it
if ($this->specificEndpoint && $endpoint_info->name != $this->specificEndpoint) continue;
if ($this->useWSDL && !$endpoint_info->wsdlURL ) continue;
$this->totals['servers']++;
#$endpoint_info['tests'] = array();
if ($this->show) print " Processing {$endpoint_info->name } at {$endpoint_info->endpointURL }\n";
$tc = count($soap_tests[$this->currentTest]);
for($ti=0; $ti< $tc; $ti++ ) {
$soap_test = & $soap_tests[$this->currentTest][$ti];
// only run the type of test we're looking for (php or soapval)
if ($soap_test->type != $this->paramType) continue;
// if this is in our skip list, skip it
if (in_array($endpoint_info->name , $this->skipEndpointList)) {
$skipfault = & new stdclass;
$skipfault->faultcode= 'SKIP';
$skipfault->faultstring= 'endpoint skipped';
$soap_test->setResult (0 ,$skipfault->faultcode , $empty_string,
#$endpoint_info['tests'][] = &$soap_test;
#$soap_test->showTestResult($this->debug);
#$this->_saveResults($endpoint_info['id'], $soap_test->method_name);
$soap_test->result = NULL;
// if we're looking for a specific method, skip unless we have it
if ($this->testMethod && strcmp($this->testMethod,$soap_test->test_name )!=0 ) continue;
if ($this->testMethod && $this->currentTest == 'Round 2 Group C') {
// we have to figure things out now
if (!preg_match('/(.*):(.*),(\d),(\d)/',$this->testMethod, $m)) continue;
// is the header in the headers list?
$thc = count($soap_test->headers );
for ($thi = 0; $thi < $thc; $thi++ ) {
$header = & $soap_test->headers [$thi];
if ($header->name == $m[2 ]) {
$gotit = $gotit && $header->attributes ['SOAP-ENV:mustUnderstand'] == $m[4 ];
if ($header[0 ] == $m[2 ]) {
$gotit = $gotit && $header[4 ] == $m[4 ];
// if we are skipping the rest of the tests (due to error) note a fault
$soap_test->setResult (0 ,$skipfault->faultcode , $empty_string,
#$endpoint_info['tests'][] = &$soap_test;
unset ($soap_test->result );
if ($this->doEndpointMethod ($endpoint_info, $soap_test)) {
$this->totals['success']++;
$skipendpoint = $soap_test->result ['fault']->faultcode== 'HTTP';
if ($skipendpoint) $skipfault = $soap_test->result ['fault'];
#$endpoint_info['tests'][] = &$soap_test;
$soap_test->showTestResult ($this->debug);
$this->_saveResults ($endpoint_info->id , $soap_test);
$this->totals['calls']++;
unset ($endpoint_info->client );
if ($this->numservers && ++ $i >= $this->numservers) break;
function doGroupTests () {
foreach($dowsdl as $usewsdl) {
$this->useWSDL = $usewsdl;
foreach($this->paramTypes as $ptype) {
if ($usewsdl && $ptype == 'soapval') break;
if (stristr($this->currentTest, 'Round 3') && !$usewsdl) break;
$this->paramType = $ptype;
* go all out. This takes time.
// the mother of all interop tests
foreach($this->tests as $test) {
$this->currentTest = $test;
foreach($dowsdl as $usewsdl) {
$this->useWSDL = $usewsdl;
foreach($this->paramTypes as $ptype) {
if ($usewsdl && $ptype == 'soapval') break;
if (stristr($this->currentTest, 'Round 3') && !$usewsdl) break;
$this->paramType = $ptype;
// ***********************************************************
* retreive results from the database, stuff them into the endpoint array
function getMethodList ($test = 'base') {
$this->dbc->setFetchMode (DB_FETCHMODE_ORDERED );
// retreive the results and put them into the endpoint info
$sql = " select distinct(function) from results where client='$this->client_type' and class='$test' order by function";
$results = $this->dbc->getAll ($sql);
foreach($results as $result) {
$methods = $this->getMethodList ($this->currentTest);
$this->getResults ($this->currentTest,$this->paramType,$this->useWSDL);
echo " <b>Testing $this->currentTest ";
if ($this->useWSDL) echo "using WSDL ";
else echo "using Direct calls ";
echo " with $this->paramType values</b><br>\n";
// calculate totals for this table
$this->totals['success'] = 0;
$this->totals['fail'] = 0;
$this->totals['result'] = 0;
$this->totals['wsdl'] = 0;
$this->totals['connect'] = 0;
$this->totals['servers'] = 0; #count($this->endpoints);
$c = count ($this->endpoints);
$endpoint_info = & $this->endpoints[$i];
if (!$endpoint_info->name ) continue;
if (count($endpoint_info->methods ) > 0 ) {
$this->totals['servers']++;
foreach ($methods as $method) {
$r = $endpoint_info->methods [$method]['result'];
if ($r == 'OK') $this->totals['success']++;
else if (stristr($r,'result')) $this->totals['result']++;
else if (stristr($r,'wsdlcache')) $this->totals['connect']++;
else if (stristr($r,'wsdl')) $this->totals['wsdl']++;
else if (stristr($r,'http')) $this->totals['connect']++;
else $this->totals['fail']++;
//unset($this->endpoints[$i]);
$this->totals['calls'] = count($methods) * $this->totals['servers'];
#if ($this->totals['fail'] == $this->totals['calls']) {
# // assume tests have not run, skip outputing table
# print "No Data Available<br>\n";
echo " \n\n<b>Servers: {$this->totals['servers']} Calls: { $this->totals['calls']} ".
" Success: {$this->totals['success']} <br>\n".
" System-Fail: {$this->totals['fail']} Result-Failure: { $this->totals['result']} ".
" Connect-Failure: {$this->totals['connect']} WSDL-Failure: { $this->totals['wsdl']} </b><br>\n";
echo "<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">\n";
echo "<tr><td class=\"BLANK\">Endpoint</td>\n";
foreach ($methods as $method) {
$info = split(':', $method);
echo "<td class='BLANK' valign='top'>";
echo '<b>'. $hi[0 ]. "</b><br>\n";
echo " Actor=". ($hi[1 ]? 'Target': 'Not Target'). "<br>\n";
echo " MustUnderstand=$hi[2]<br>\n";
$c = count ($this->endpoints);
$endpoint_info = & $this->endpoints[$i];
if (!$endpoint_info->name ) continue;
if ($endpoint_info->wsdlURL ) {
echo " <tr><td class=\"BLANK\"><a href=\"{$endpoint_info->wsdlURL }\">{$endpoint_info->name }</a></td>\n";
echo " <tr><td class=\"BLANK\">{$endpoint_info->name }</td>\n";
foreach ($methods as $method) {
$id = $endpoint_info->methods [$method]['id'];
$r = $endpoint_info->methods [$method]['result'];
$e = $endpoint_info->methods [$method]['error'];
echo " <td class='$r'><a href='$PHP_SELF?wire=$id'>$r</a></td>\n";
echo "<td class='untested'>untested</td>\n";
if ($this->showFaults && count($faults) > 0 ) {
echo "<b>ERROR Details:</b><br>\n<ul>\n";
# output more error detail
foreach ($faults as $fault) {
echo '<li>'.HTMLSpecialChars ($fault). "</li>\n";
function outputTables () {
// the mother of all interop tests
foreach($this->tests as $test) {
$this->currentTest = $test;
foreach($dowsdl as $usewsdl) {
$this->useWSDL = $usewsdl;
foreach($this->paramTypes as $ptype) {
if ($usewsdl && $ptype == 'soapval') break;
if (stristr($this->currentTest, 'Round 3') && !$usewsdl) break;
$this->paramType = $ptype;
$results = $this->dbc->getAll (" select * from results where id=$id" ,NULL , DB_FETCHMODE_ASSOC );
#$wire = preg_replace("/>/",">\n",$results[0]['wire']);
$wire = $results[0 ]['wire'];
echo "<pre>\n".HTMLSpecialChars ($wire). "</pre>\n";
Documentation generated on Mon, 11 Mar 2019 14:54:33 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|