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.16 2007/01/26 17:21:26 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 = ''; // see $tests above
var $paramType = 'php'; // 'php' or 'soapval'
var $useWSDL = false; // true: 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 );
* Retreives results from the database and stuffs them into the endpoint
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 , $rc = count($results); $j < $rc; ++ $j) {
for ($i = 0; $i < $c; $i++ ) {
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;
* Saves the results of a method test into the database.
function _saveResults ($endpoint_id, &$soap_test)
$result = & $soap_test->result;
if ($result['success']) {
$success = $result['fault']->faultcode;
$error = $result['fault']->faultstring;
$wire = $result['fault']->faultdetail;
$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') {
$test_name .= " :{$h->name },$destination,{$h->attributes ['SOAP-ENV:mustUnderstand']}";
$h[3 ] == 'http://schemas.xmlsoap.org/soap/actor/next') {
$test_name .= " :{$qn->name },$destination," . (int) $h[2 ];
$sql = 'DELETE FROM results WHERE endpoint = ? AND class = ? AND type = ? AND wsdl = ? AND client = ? AND function = ?';
$values = array ($endpoint_id, $this->currentTest, $this->paramType,
$this->useWSDL, $this->client_type, $test_name);
$res = $this->dbc->query ($sql, $values);
$sql = 'INSERT INTO results (client, endpoint, stamp, class, type, wsdl, function, result, error, wire) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
$values = array ($this->client_type, $endpoint_id, time(),
$this->currentTest, $this->paramType, $this->useWSDL,
$test_name, $success, $error,
$res = $this->dbc->query ($sql, $values);
* Compares two PHP types for a match.
* @param mixed $test_result
function compareResult (&$expect, &$result, $type = null )
if ($expect_type == 'array' && $result_type == 'array') {
// We'll only compare to 3 digits of precision.
if ($type == 'boolean') {
* Runs a method on an endpoint and stores its results to the database.
* @param array $endpoint_info
* @param SOAP_Test $soap_test
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;
//echo "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;
if ($soap_test->service ) {
$endpoint_info->client ->_wsdl ->setService ($soap_test->service );
$soap = & $endpoint_info->client;
//$port = $soap->_wsdl->getPortName($soap_test->method_name);
//$opdata = $soap->_wsdl->getOperationData($port, $soap_test->method_name);
$fault = array ('faultcode' => 'WSDL',
'faultstring' => " no WSDL defined for $endpoint" );
$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 deprecated
// 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 ();
for ($i = 0 , $hc = count($soap_test->headers ); $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
for ($i = 0 , $hc = count($soap_test->headers ); $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;
// We need to decode what we sent so we can compare!
$sent_d = & $soap->_decode ($sent);
// 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);
$expected = $soap_test->expect;
$fault->faultcode = 'HEADER';
$fault->faultstring = 'The returned result did not match what we expected to receive';
$soap_test->setResult (1 , 'OK', $soap->getWire ());
$fault->faultcode = 'RESULT';
$fault->faultstring = 'The returned result did not match what we expected to receive';
$fault->faultdetail = "RETURNED:\n" . var_export($return, true ) . "\n\nEXPECTED:\n" . var_export($expected, true );
$fault = $return->getFault ();
if ($soap_test->expect_fault ) {
$res = $fault->faultcode;
$soap_test->setResult ($ok,
* Runs 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);
for ($i = 0 , $c = count($this->endpoints); $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) ||
($this->useWSDL && !$endpoint_info->wsdlURL )) {
$this->totals['servers']++;
//$endpoint_info['tests'] = array();
echo " Processing {$endpoint_info->name } at {$endpoint_info->endpointURL }\n";
for ($ti = 0 , $tc = count($soap_tests[$this->currentTest]); $ti < $tc; ++ $ti) {
$soap_test = $soap_tests[$this->currentTest][$ti];
// Only run the type of test we're looking for (php or
if ($soap_test->type != $this->paramType) {
// 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';
//$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
strcmp($this->testMethod, $soap_test->test_name ) != 0 ) {
$this->currentTest == 'Round 2 Group C') {
// We have to figure things out now.
if (!preg_match('/(.*):(.*),(\d),(\d)/', $this->testMethod, $m)) {
// 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 ];
} elseif ($header[0 ] == $m[2 ]) {
$gotit = $gotit && $header[4 ] == $m[4 ];
// If we are skipping the rest of the tests (due to error)
//$endpoint_info['tests'][] = &$soap_test;
// Run the endpoint test.
unset ($soap_test->result );
if ($this->doEndpointMethod ($endpoint_info, $soap_test)) {
$this->totals['success']++;
$skipendpoint = $soap_test->result ['fault']->faultcode == 'HTTP';
$skipfault = $skipendpoint ? $soap_test->result ['fault'] : null;
//$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) {
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) {
// Skip a pointless test.
if ($usewsdl && $ptype == 'soapval') {
if (stristr($this->currentTest, 'Round 3') && !$usewsdl) {
$this->paramType = $ptype;
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 ";
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);
for ($i = 0 , $c = count($this->endpoints); $i < $c; ++ $i) {
$endpoint_info = $this->endpoints[$i];
if (!$endpoint_info->name ) {
if (count($endpoint_info->methods ) > 0 ) {
$this->totals['servers']++;
foreach ($methods as $method) {
$r = $endpoint_info->methods [$method]['result'];
$this->totals['success']++;
$this->totals['result']++;
} elseif (stristr($r, 'wsdlcache')) {
$this->totals['connect']++;
$this->totals['connect']++;
//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
// echo "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"
. "<table border=\"1\" cellspacing=\"0\" cellpadding=\"2\">\n"
. "<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 MustUnderstand=$hi[2]<br>\n";
for ($i = 0 , $c = count($this->endpoints); $i < $c; ++ $i) {
$endpoint_info = $this->endpoints[$i];
if (!$endpoint_info->name ) {
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) {
foreach($this->tests as $test) {
$this->currentTest = $test;
foreach ($dowsdl as $usewsdl) {
$this->useWSDL = $usewsdl;
foreach ($this->paramTypes as $ptype) {
// Skip a pointless test.
if ($usewsdl && $ptype == 'soapval') {
if (stristr($this->currentTest, 'Round 3') && !$usewsdl) {
$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'];
Documentation generated on Mon, 11 Mar 2019 15:06:25 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|