Skip to content

Commit f3ed4a2

Browse files
committed
support for command line interface was improved
1 parent f46638a commit f3ed4a2

File tree

4 files changed

+65
-33
lines changed

4 files changed

+65
-33
lines changed

ext/soap/interop/client_round2_interop.php

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ class Interop_Client
3030
// database DNS
3131
var $DSN = "";
3232

33+
var $baseURL = "";
34+
3335
// our central interop server, where we can get the list of endpoints
3436
var $interopServer = "http://www.whitemesa.net/wsdl/interopInfo.wsdl";
3537

@@ -57,10 +59,13 @@ class Interop_Client
5759
var $tests = array('base','GroupB', 'GroupC');
5860
var $paramTypes = array('php', 'soapval');
5961
var $endpoints = array();
62+
var $html = 1;
6063

6164
function Interop_Client() {
6265
global $interopConfig;
6366
$this->DSN = $interopConfig['DSN'];
67+
$this->baseURL = $interopConfig['baseURL'];
68+
//$this->baseURL = 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
6469
// set up the database connection
6570
$this->dbc = DB::connect($this->DSN, true);
6671
// if it errors out, just ignore it and rely on regular methods
@@ -71,19 +76,18 @@ function Interop_Client() {
7176
// set up local endpoint
7277
$this->localEndpoint['base'] = (object)array(
7378
'endpointName'=>'PHP ext/soap',
74-
'endpointURL'=>'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/server_round2_base.php',
75-
'wsdlURL'=>'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/interop.wsdl.php'
79+
'endpointURL'=>$this->baseURL.'/server_round2_base.php',
80+
'wsdlURL'=>$this->baseURL.'/interop.wsdl.php'
7681
);
7782
$this->localEndpoint['GroupB'] = (object)array(
7883
'endpointName'=>'PHP ext/soap',
79-
'endpointURL'=>'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/server_round2_groupB.php',
80-
'wsdlURL'=>'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/interopB.wsdl.php'
84+
'endpointURL'=>$this->baseURL.'/server_round2_groupB.php',
85+
'wsdlURL'=>$this->baseURL.'/interopB.wsdl.php'
8186
);
8287
$this->localEndpoint['GroupC'] = (object)array(
8388
'endpointName'=>'PHP ext/soap',
84-
'endpointURL'=>'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/server_round2_groupC.php',
85-
'wsdlURL'=>'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/echoheadersvc.wsdl.php'
86-
);
89+
'endpointURL'=>$this->baseURL.'/server_round2_groupC.php',
90+
'wsdlURL'=>$this->baseURL.'/echoheadersvc.wsdl.php');
8791
}
8892

8993
function _fetchEndpoints(&$soapclient, $test) {
@@ -92,9 +96,11 @@ function _fetchEndpoints(&$soapclient, $test) {
9296
// retreive endpoints from the endpoint server
9397
$endpointArray = $soapclient->__call("GetEndpointInfo",array("groupName"=>$test),array('soapaction'=>"http://soapinterop.org/",'uri'=>"http://soapinterop.org/"));
9498
if (is_soap_fault($endpointArray) || PEAR::isError($endpointArray)) {
95-
print "<pre>".$soapclient->wire."\n";
99+
if ($this->html) print "<pre>";
100+
print $soapclient->wire."\n";
96101
print_r($endpointArray);
97-
print "</pre>";
102+
if ($this->html) print "</pre>";
103+
print "\n";
98104
return;
99105
}
100106

@@ -145,7 +151,11 @@ function fetchEndpoints($test = NULL) {
145151
$test = 'base';
146152
}
147153
} catch (SoapFault $fault) {
148-
echo "<pre>$fault</pre>";
154+
if ($this->html) {
155+
echo "<pre>$fault</pre>\n";
156+
} else {
157+
echo "$fault\n";
158+
}
149159
return NULL;
150160
}
151161
// retreive all endpoints now
@@ -552,7 +562,10 @@ function doTest() {
552562
$this->totals['servers']++;
553563
#$endpoint_info['tests'] = array();
554564

555-
if ($this->show) print "Processing $endpoint at {$endpoint_info['endpointURL']}<br>\n";
565+
if ($this->show) {
566+
print "Processing $endpoint at {$endpoint_info['endpointURL']}";
567+
if ($this->html) print "<br>\n"; else print "\n";
568+
}
556569

557570
foreach($soap_tests[$this->currentTest] as $soap_test) {
558571
//foreach(array_keys($method_params[$this->currentTest][$this->paramType]) as $method)
@@ -573,7 +586,7 @@ function doTest() {
573586
$skipfault
574587
);
575588
#$endpoint_info['tests'][] = &$soap_test;
576-
#$soap_test->showTestResult($this->debug);
589+
#$soap_test->showTestResult($this->debug, $this->html);
577590
#$this->_saveResults($endpoint_info['id'], $soap_test->method_name);
578591
$soap_test->result = NULL;
579592
continue;
@@ -602,7 +615,7 @@ function doTest() {
602615
}
603616
#$endpoint_info['tests'][] = &$soap_test;
604617
}
605-
$soap_test->showTestResult($this->debug);
618+
$soap_test->showTestResult($this->debug, $this->html);
606619
$this->_saveResults($endpoint_info['id'], $soap_test);
607620
$soap_test->result = NULL;
608621
$this->totals['calls']++;
@@ -775,7 +788,10 @@ function showWire($id) {
775788
$results = $this->dbc->getAll("select * from results where id=$id",NULL, DB_FETCHMODE_ASSOC );
776789
#$wire = preg_replace("/>/",">\n",$results[0]['wire']);
777790
$wire = $results[0]['wire'];
778-
echo "<pre>\n".HTMLSpecialChars($wire)."</pre>\n";
791+
if ($this->html) print "<pre>";
792+
echo "\n".HTMLSpecialChars($wire);
793+
if ($this->html) print "</pre>";
794+
print "\n";
779795
}
780796

781797
}

ext/soap/interop/client_round2_params.php

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ function setResult($ok, $result, $wire, $error = '', $fault = NULL)
8181
* @param string method
8282
* @access public
8383
*/
84-
function showTestResult($debug = 0) {
84+
function showTestResult($debug = 0, $html = 0) {
8585
// debug output
8686
if ($debug) $this->show = 1;
8787
if ($debug) {
88-
echo str_repeat("-",50)."<br>\n";
88+
echo str_repeat("-",50).$html?"<br>\n":"\n";
8989
}
9090

9191
echo "testing $this->test_name : ";
@@ -98,7 +98,11 @@ function showTestResult($debug = 0) {
9898

9999
$ok = $this->result['success'];
100100
if ($ok) {
101-
print "<font color=\"#00cc00\">SUCCESS</font>\n";
101+
if ($html) {
102+
print "<font color=\"#00cc00\">SUCCESS</font>\n";
103+
} else {
104+
print "SUCCESS\n";
105+
}
102106
} else {
103107
$fault = $this->result['fault'];
104108
if ($fault) {
@@ -107,13 +111,25 @@ function showTestResult($debug = 0) {
107111
if ($pos !== false) {
108112
$res = substr($res,$pos+1);
109113
}
110-
print "<font color=\"#ff0000\">FAILED: [$res] {$fault->faultstring}</font>\n";
114+
if ($html) {
115+
print "<font color=\"#ff0000\">FAILED: [$res] {$fault->faultstring}</font>\n";
116+
} else {
117+
print "FAILED: [$res] {$fault->faultstring}\n";
118+
}
111119
} else {
112-
print "<font color=\"#ff0000\">FAILED: ".$this->result['result']."</font>\n";
120+
if ($html) {
121+
print "<font color=\"#ff0000\">FAILED: ".$this->result['result']."</font>\n";
122+
} else {
123+
print "FAILED: ".$this->result['result']."\n";
124+
}
113125
}
114126
}
115127
if ($debug) {
116-
echo "<pre>\n".htmlentities($this->result['wire'])."</pre>\n";
128+
if ($html) {
129+
echo "<pre>\n".htmlentities($this->result['wire'])."</pre>\n";
130+
} else {
131+
echo "\n".htmlentities($this->result['wire'])."\n";
132+
}
117133
}
118134
}
119135
}

ext/soap/interop/client_round2_run.php

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<?php
2-
// this script is usefull for quickly testing stuff, use the 'pretty' file for html output
3-
//
42
// +----------------------------------------------------------------------+
53
// | PHP Version 4 |
64
// +----------------------------------------------------------------------+
@@ -19,25 +17,26 @@
1917
//
2018
// $Id$
2119
//
20+
2221
set_time_limit(0);
2322
require_once 'client_round2_interop.php';
2423

2524
$iop = new Interop_Client();
25+
$iop->html = 0;
26+
2627
// force a fetch of endpoints, this happens irregardless if no endpoints in database
27-
#$iop->fetchEndpoints();
28+
$iop->fetchEndpoints();
2829

2930
// set some options
30-
$iop->currentTest = 'base'; // see $tests above
31-
$iop->paramType = 'php'; // 'php' or 'soapval'
32-
$iop->useWSDL = 0; // 1= do wsdl tests
33-
$iop->numServers = 0; // 0 = all
34-
//$iop->specificEndpoint = '4s4c'; // test only this endpoint
35-
//$iop->testMethod = 'echoString'; // test only this method
36-
37-
#XXX MS SOAP ToolKit 2.0/3.0 crashes php-soap in __getfault!
31+
$iop->currentTest = 'GroupC'; // see $tests above
32+
$iop->paramType = 'php'; // 'php' or 'soapval'
33+
$iop->useWSDL = 1; // 1= do wsdl tests
34+
$iop->numServers = 0; // 0 = all
35+
//$iop->specificEndpoint = 'PHP ext/soap'; // test only this endpoint
36+
//$iop->testMethod = 'echoString'; // test only this method
3837

3938
// endpoints to skip
40-
$iop->skipEndpointList = array('Apache Axis','IONA XMLBus','IONA XMLBus (CORBA)','MS SOAP ToolKit 2.0','MS SOAP ToolKit 3.0','Spheon JSOAP','SQLData SOAP Server','WASP Advanced 3.0');
39+
//$iop->skipEndpointList = array('Apache Axis','IONA XMLBus','IONA XMLBus (CORBA)','MS SOAP ToolKit 2.0','MS SOAP ToolKit 3.0','Spheon JSOAP','SQLData SOAP Server','WASP Advanced 3.0');
4140
$iop->startAt='';
4241
$iop->nosave = 0; // 1= disable saving results to database
4342
// debug output
@@ -49,6 +48,6 @@
4948
#$iop->doGroupTests(); // run a group of tests set in $currentTest
5049
#$iop->doTests(); // run all tests, ignore above options
5150
#$iop->outputTables();
52-
echo "done";
51+
echo "done\n";
5352

5453
?>

ext/soap/interop/config.php.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
22
// configuration items
33
$interopConfig['DSN'] = 'mysql://root@localhost/soapinterop';
4+
$interopConfig['baseURL'] = 'http://localhost/soap/interop';
45
?>

0 commit comments

Comments
 (0)