3 * Demo server for xmlrpc library.
5 * Implements a lot of webservices, including a suite of services used for
6 * interoperability testing (validator1 methods), and some whose only purpose
7 * is to be used for unit-testing the library.
9 * Please do not copy this file verbatim into your production server.
12 // give user a chance to see the source for this server instead of running the services
13 if ($_SERVER['REQUEST_METHOD'] != 'POST' && isset($_GET['showSource'])) {
14 highlight_file(__FILE__);
18 include_once __DIR__ . "/../../vendor/autoload.php";
20 // out-of-band information: let the client manipulate the server operations.
21 // we do this to help the testsuite script: do not reproduce in production!
22 if (isset($_COOKIE['PHPUNIT_SELENIUM_TEST_ID']) && extension_loaded('xdebug')) {
23 $GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'] = '/tmp/phpxmlrpc_coverage';
24 if (!is_dir($GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY'])) {
25 mkdir($GLOBALS['PHPUNIT_COVERAGE_DATA_DIRECTORY']);
28 include_once __DIR__ . "/../../vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/SeleniumCommon/prepend.php";
34 * Used to test usage of object methods in dispatch maps and in wrapper code.
36 class xmlrpcServerMethodsContainer
39 * Method used to test logging of php warnings generated by user functions.
41 public function phpWarningGenerator($req)
43 $a = $undefinedVariable; // this triggers a warning in E_ALL mode, since $undefinedVariable is undefined
44 return new PhpXmlRpc\Response(new Value(1, 'boolean'));
48 * Method used to test catching of exceptions in the server.
50 public function exceptionGenerator($req)
52 throw new Exception("it's just a test", 1);
56 * A PHP version of the state-number server. Send me an integer and i'll sell you a state.
62 public static function findState($num)
64 return inner_findstate($num);
68 // a PHP version of the state-number server
69 // send me an integer and i'll sell you a state
72 "Alabama", "Alaska", "Arizona", "Arkansas", "California",
73 "Colorado", "Columbia", "Connecticut", "Delaware", "Florida",
74 "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas",
75 "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan",
76 "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada",
77 "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina",
78 "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island",
79 "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont",
80 "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming",
83 $findstate_sig = array(array(Value::$xmlrpcString, Value::$xmlrpcInt));
84 $findstate_doc = 'When passed an integer between 1 and 51 returns the
85 name of a US state, where the integer is the index of that state name
86 in an alphabetic order.';
88 function findState($req)
93 // get the first param
94 $sno = $req->getParam(0);
96 // param must be there and of the correct type: server object does the validation for us
98 // extract the value of the state number
99 $snv = $sno->scalarval();
100 // look it up in our array (zero-based)
101 if (isset($stateNames[$snv - 1])) {
102 $stateName = $stateNames[$snv - 1];
104 // not there, so complain
105 $err = "I don't have a state for the index '" . $snv . "'";
108 // if we generated an error, create an error return response
110 return new PhpXmlRpc\Response(0, PhpXmlRpc\PhpXmlRpc::$xmlrpcerruser, $err);
112 // otherwise, we create the right response with the state name
113 return new PhpXmlRpc\Response(new Value($stateName));
118 * Inner code of the state-number server.
119 * Used to test wrapping of PHP functions into xmlrpc methods.
121 * @param integer $stateNo the state number
123 * @return string the name of the state (or error description)
125 * @throws Exception if state is not found
127 function inner_findstate($stateNo)
131 if (isset($stateNames[$stateNo - 1])) {
132 return $stateNames[$stateNo - 1];
134 // not, there so complain
135 throw new Exception("I don't have a state for the index '" . $stateNo . "'", PhpXmlRpc\PhpXmlRpc::$xmlrpcerruser);
139 $wrapper = new PhpXmlRpc\Wrapper();
141 $findstate2_sig = $wrapper->wrap_php_function('inner_findstate');
143 $findstate3_sig = $wrapper->wrap_php_function(array('xmlrpcServerMethodsContainer', 'findState'));
145 $obj = new xmlrpcServerMethodsContainer();
146 $findstate4_sig = $wrapper->wrap_php_function(array($obj, 'findstate'));
148 $findstate5_sig = $wrapper->wrap_php_function('xmlrpcServerMethodsContainer::findState', '', array('return_source' => true));
149 eval($findstate5_sig['source']);
151 $findstate6_sig = $wrapper->wrap_php_function('inner_findstate', '', array('return_source' => true));
152 eval($findstate6_sig['source']);
154 $findstate7_sig = $wrapper->wrap_php_function(array('xmlrpcServerMethodsContainer', 'findState'), '', array('return_source' => true));
155 eval($findstate7_sig['source']);
157 $obj = new xmlrpcServerMethodsContainer();
158 $findstate8_sig = $wrapper->wrap_php_function(array($obj, 'findstate'), '', array('return_source' => true));
159 eval($findstate8_sig['source']);
161 $findstate9_sig = $wrapper->wrap_php_function('xmlrpcServerMethodsContainer::findState', '', array('return_source' => true));
162 eval($findstate9_sig['source']);
164 $findstate10_sig = array(
165 "function" => function ($req) { return findState($req); },
166 "signature" => $findstate_sig,
167 "docstring" => $findstate_doc,
170 $findstate11_sig = $wrapper->wrap_php_function(function ($stateNo) { return inner_findstate($stateNo); });
172 $c = new xmlrpcServerMethodsContainer;
173 $moreSignatures = $wrapper->wrap_php_class($c, array('prefix' => 'tests.', 'method_type' => 'all'));
175 $addtwo_sig = array(array(Value::$xmlrpcInt, Value::$xmlrpcInt, Value::$xmlrpcInt));
176 $addtwo_doc = 'Add two integers together and return the result';
177 function addTwo($req)
179 $s = $req->getParam(0);
180 $t = $req->getParam(1);
182 return new PhpXmlRpc\Response(new Value($s->scalarval() + $t->scalarval(), "int"));
185 $addtwodouble_sig = array(array(Value::$xmlrpcDouble, Value::$xmlrpcDouble, Value::$xmlrpcDouble));
186 $addtwodouble_doc = 'Add two doubles together and return the result';
187 function addTwoDouble($req)
189 $s = $req->getParam(0);
190 $t = $req->getParam(1);
192 return new PhpXmlRpc\Response(new Value($s->scalarval() + $t->scalarval(), "double"));
195 $stringecho_sig = array(array(Value::$xmlrpcString, Value::$xmlrpcString));
196 $stringecho_doc = 'Accepts a string parameter, returns the string.';
197 function stringEcho($req)
199 // just sends back a string
200 return new PhpXmlRpc\Response(new Value($req->getParam(0)->scalarval()));
203 $echoback_sig = array(array(Value::$xmlrpcString, Value::$xmlrpcString));
204 $echoback_doc = 'Accepts a string parameter, returns the entire incoming payload';
205 function echoBack($req)
207 // just sends back a string with what i got sent to me, just escaped, that's all
208 $s = "I got the following message:\n" . $req->serialize();
210 return new PhpXmlRpc\Response(new Value($s));
213 $echosixtyfour_sig = array(array(Value::$xmlrpcString, Value::$xmlrpcBase64));
214 $echosixtyfour_doc = 'Accepts a base64 parameter and returns it decoded as a string';
215 function echoSixtyFour($req)
217 // Accepts an encoded value, but sends it back as a normal string.
218 // This is to test that base64 encoding is working as expected
219 $incoming = $req->getParam(0);
221 return new PhpXmlRpc\Response(new Value($incoming->scalarval(), "string"));
224 $bitflipper_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcArray));
225 $bitflipper_doc = 'Accepts an array of booleans, and returns them inverted';
226 function bitFlipper($req)
228 $v = $req->getParam(0);
229 $sz = $v->arraysize();
230 $rv = new Value(array(), Value::$xmlrpcArray);
232 for ($j = 0; $j < $sz; $j++) {
233 $b = $v->arraymem($j);
234 if ($b->scalarval()) {
235 $rv->addScalar(false, "boolean");
237 $rv->addScalar(true, "boolean");
241 return new PhpXmlRpc\Response($rv);
246 // send me an array of structs thus:
253 // and I'll return it to you in sorted order
255 function agesorter_compare($a, $b)
257 global $agesorter_arr;
259 // don't even ask me _why_ these come padded with hyphens, I couldn't tell you :p
260 $a = str_replace("-", "", $a);
261 $b = str_replace("-", "", $b);
263 if ($agesorter_arr[$a] == $agesorter_arr[$b]) {
267 return ($agesorter_arr[$a] > $agesorter_arr[$b]) ? -1 : 1;
270 $agesorter_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcArray));
271 $agesorter_doc = 'Send this method an array of [string, int] structs, eg:
278 And the array will be returned with the entries sorted by their numbers.
280 function ageSorter($req)
282 global $agesorter_arr, $s;
284 PhpXmlRpc\Server::xmlrpc_debugmsg("Entering 'agesorter'");
286 $sno = $req->getParam(0);
287 // error string for [if|when] things go wrong
289 // create the output value
293 $max = $sno->arraysize();
294 PhpXmlRpc\Server::xmlrpc_debugmsg("Found $max array elements");
295 for ($i = 0; $i < $max; $i++) {
296 $rec = $sno->arraymem($i);
297 if ($rec->kindOf() != "struct") {
298 $err = "Found non-struct in array at element $i";
301 // extract name and age from struct
302 $n = $rec->structmem("name");
303 $a = $rec->structmem("age");
304 // $n and $a are xmlrpcvals,
305 // so get the scalarval from them
306 $agar[$n->scalarval()] = $a->scalarval();
309 $agesorter_arr = $agar;
310 // hack, must make global as uksort() won't
311 // allow us to pass any other auxiliary information
312 uksort($agesorter_arr, 'agesorter_compare');
314 while (list($key, $val) = each($agesorter_arr)) {
315 // recreate each struct element
316 $outAr[] = new Value(array("name" => new Value($key),
317 "age" => new Value($val, "int"),), "struct");
319 // add this array to the output value
320 $v->addArray($outAr);
323 return new PhpXmlRpc\Response(0, PhpXmlRpc\PhpXmlRpc::$xmlrpcerruser, $err);
325 return new PhpXmlRpc\Response($v);
329 // signature and instructions, place these in the dispatch
331 $mailsend_sig = array(array(
332 Value::$xmlrpcBoolean, Value::$xmlrpcString, Value::$xmlrpcString,
333 Value::$xmlrpcString, Value::$xmlrpcString, Value::$xmlrpcString,
334 Value::$xmlrpcString, Value::$xmlrpcString,
336 $mailsend_doc = 'mail.send(recipient, subject, text, sender, cc, bcc, mimetype)<br/>
337 recipient, cc, and bcc are strings, comma-separated lists of email addresses, as described above.<br/>
338 subject is a string, the subject of the message.<br/>
339 sender is a string, it\'s the email address of the person sending the message. This string can not be
340 a comma-separated list, it must contain a single email address only.<br/>
341 text is a string, it contains the body of the message.<br/>
342 mimetype, a string, is a standard MIME type, for example, text/plain.
344 // WARNING; this functionality depends on the sendmail -t option
345 // it may not work with Windows machines properly; particularly
346 // the Bcc option. Sneak on your friends at your own risk!
347 function mailSend($req)
351 $mTo = $req->getParam(0);
352 $mSub = $req->getParam(1);
353 $mBody = $req->getParam(2);
354 $mFrom = $req->getParam(3);
355 $mCc = $req->getParam(4);
356 $mBcc = $req->getParam(5);
357 $mMime = $req->getParam(6);
359 if ($mTo->scalarval() == "") {
360 $err = "Error, no 'To' field specified";
363 if ($mFrom->scalarval() == "") {
364 $err = "Error, no 'From' field specified";
367 $msgHdr = "From: " . $mFrom->scalarval() . "\n";
368 $msgHdr .= "To: " . $mTo->scalarval() . "\n";
370 if ($mCc->scalarval() != "") {
371 $msgHdr .= "Cc: " . $mCc->scalarval() . "\n";
373 if ($mBcc->scalarval() != "") {
374 $msgHdr .= "Bcc: " . $mBcc->scalarval() . "\n";
376 if ($mMime->scalarval() != "") {
377 $msgHdr .= "Content-type: " . $mMime->scalarval() . "\n";
379 $msgHdr .= "X-Mailer: XML-RPC for PHP mailer 1.0";
387 $err = "Error, could not send the mail.";
392 return new PhpXmlRpc\Response(0, PhpXmlRpc\PhpXmlRpc::$xmlrpcerruser, $err);
394 return new PhpXmlRpc\Response(new Value("true", Value::$xmlrpcBoolean));
398 $getallheaders_sig = array(array(Value::$xmlrpcStruct));
399 $getallheaders_doc = 'Returns a struct containing all the HTTP headers received with the request. Provides limited functionality with IIS';
400 function getAllHeaders_xmlrpc($req)
402 $encoder = new PhpXmlRpc\Encoder();
404 if (function_exists('getallheaders')) {
405 return new PhpXmlRpc\Response($encoder->encode(getallheaders()));
408 // IIS: poor man's version of getallheaders
409 foreach ($_SERVER as $key => $val) {
410 if (strpos($key, 'HTTP_') === 0) {
411 $key = ucfirst(str_replace('_', '-', strtolower(substr($key, 5))));
412 $headers[$key] = $val;
416 return new PhpXmlRpc\Response($encoder->encode($headers));
420 $setcookies_sig = array(array(Value::$xmlrpcInt, Value::$xmlrpcStruct));
421 $setcookies_doc = 'Sends to client a response containing a single \'1\' digit, and sets to it http cookies as received in the request (array of structs describing a cookie)';
422 function setCookies($req)
424 $encoder = new PhpXmlRpc\Encoder();
425 $m = $req->getParam(0);
426 while (list($name, $value) = $m->structeach()) {
427 $cookieDesc = $encoder->decode($value);
428 setcookie($name, @$cookieDesc['value'], @$cookieDesc['expires'], @$cookieDesc['path'], @$cookieDesc['domain'], @$cookieDesc['secure']);
431 return new PhpXmlRpc\Response(new Value(1, 'int'));
434 $getcookies_sig = array(array(Value::$xmlrpcStruct));
435 $getcookies_doc = 'Sends to client a response containing all http cookies as received in the request (as struct)';
436 function getCookies($req)
438 $encoder = new PhpXmlRpc\Encoder();
439 return new PhpXmlRpc\Response($encoder->encode($_COOKIE));
442 $v1_arrayOfStructs_sig = array(array(Value::$xmlrpcInt, Value::$xmlrpcArray));
443 $v1_arrayOfStructs_doc = 'This handler takes a single parameter, an array of structs, each of which contains at least three elements named moe, larry and curly, all <i4>s. Your handler must add all the struct elements named curly and return the result.';
444 function v1_arrayOfStructs($req)
446 $sno = $req->getParam(0);
448 for ($i = 0; $i < $sno->arraysize(); $i++) {
449 $str = $sno->arraymem($i);
451 while (list($key, $val) = $str->structeach()) {
452 if ($key == "curly") {
453 $numCurly += $val->scalarval();
458 return new PhpXmlRpc\Response(new Value($numCurly, "int"));
461 $v1_easyStruct_sig = array(array(Value::$xmlrpcInt, Value::$xmlrpcStruct));
462 $v1_easyStruct_doc = 'This handler takes a single parameter, a struct, containing at least three elements named moe, larry and curly, all <i4>s. Your handler must add the three numbers and return the result.';
463 function v1_easyStruct($req)
465 $sno = $req->getParam(0);
466 $moe = $sno->structmem("moe");
467 $larry = $sno->structmem("larry");
468 $curly = $sno->structmem("curly");
469 $num = $moe->scalarval() + $larry->scalarval() + $curly->scalarval();
471 return new PhpXmlRpc\Response(new Value($num, "int"));
474 $v1_echoStruct_sig = array(array(Value::$xmlrpcStruct, Value::$xmlrpcStruct));
475 $v1_echoStruct_doc = 'This handler takes a single parameter, a struct. Your handler must return the struct.';
476 function v1_echoStruct($req)
478 $sno = $req->getParam(0);
480 return new PhpXmlRpc\Response($sno);
483 $v1_manyTypes_sig = array(array(
484 Value::$xmlrpcArray, Value::$xmlrpcInt, Value::$xmlrpcBoolean,
485 Value::$xmlrpcString, Value::$xmlrpcDouble, Value::$xmlrpcDateTime,
486 Value::$xmlrpcBase64,
488 $v1_manyTypes_doc = 'This handler takes six parameters, and returns an array containing all the parameters.';
489 function v1_manyTypes($req)
491 return new PhpXmlRpc\Response(new Value(array(
502 $v1_moderateSizeArrayCheck_sig = array(array(Value::$xmlrpcString, Value::$xmlrpcArray));
503 $v1_moderateSizeArrayCheck_doc = 'This handler takes a single parameter, which is an array containing between 100 and 200 elements. Each of the items is a string, your handler must return a string containing the concatenated text of the first and last elements.';
504 function v1_moderateSizeArrayCheck($req)
506 $ar = $req->getParam(0);
507 $sz = $ar->arraysize();
508 $first = $ar->arraymem(0);
509 $last = $ar->arraymem($sz - 1);
511 return new PhpXmlRpc\Response(new Value($first->scalarval() .
512 $last->scalarval(), "string"));
515 $v1_simpleStructReturn_sig = array(array(Value::$xmlrpcStruct, Value::$xmlrpcInt));
516 $v1_simpleStructReturn_doc = 'This handler takes one parameter, and returns a struct containing three elements, times10, times100 and times1000, the result of multiplying the number by 10, 100 and 1000.';
517 function v1_simpleStructReturn($req)
519 $sno = $req->getParam(0);
520 $v = $sno->scalarval();
522 return new PhpXmlRpc\Response(new Value(array(
523 "times10" => new Value($v * 10, "int"),
524 "times100" => new Value($v * 100, "int"),
525 "times1000" => new Value($v * 1000, "int"),),
530 $v1_nestedStruct_sig = array(array(Value::$xmlrpcInt, Value::$xmlrpcStruct));
531 $v1_nestedStruct_doc = 'This handler takes a single parameter, a struct, that models a daily calendar. At the top level, there is one struct for each year. Each year is broken down into months, and months into days. Most of the days are empty in the struct you receive, but the entry for April 1, 2000 contains a least three elements named moe, larry and curly, all <i4>s. Your handler must add the three numbers and return the result.';
532 function v1_nestedStruct($req)
534 $sno = $req->getParam(0);
536 $twoK = $sno->structmem("2000");
537 $april = $twoK->structmem("04");
538 $fools = $april->structmem("01");
539 $curly = $fools->structmem("curly");
540 $larry = $fools->structmem("larry");
541 $moe = $fools->structmem("moe");
543 return new PhpXmlRpc\Response(new Value($curly->scalarval() + $larry->scalarval() + $moe->scalarval(), "int"));
546 $v1_countTheEntities_sig = array(array(Value::$xmlrpcStruct, Value::$xmlrpcString));
547 $v1_countTheEntities_doc = 'This handler takes a single parameter, a string, that contains any number of predefined entities, namely <, >, & \' and ".<BR>Your handler must return a struct that contains five fields, all numbers: ctLeftAngleBrackets, ctRightAngleBrackets, ctAmpersands, ctApostrophes, ctQuotes.';
548 function v1_countTheEntities($req)
550 $sno = $req->getParam(0);
551 $str = $sno->scalarval();
557 for ($i = 0; $i < strlen($str); $i++) {
558 $c = substr($str, $i, 1);
580 return new PhpXmlRpc\Response(new Value(array(
581 "ctLeftAngleBrackets" => new Value($lt, "int"),
582 "ctRightAngleBrackets" => new Value($gt, "int"),
583 "ctAmpersands" => new Value($amp, "int"),
584 "ctApostrophes" => new Value($ap, "int"),
585 "ctQuotes" => new Value($qu, "int"),),
590 // trivial interop tests
591 // http://www.xmlrpc.com/stories/storyReader$1636
593 $i_echoString_sig = array(array(Value::$xmlrpcString, Value::$xmlrpcString));
594 $i_echoString_doc = "Echoes string.";
596 $i_echoStringArray_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcArray));
597 $i_echoStringArray_doc = "Echoes string array.";
599 $i_echoInteger_sig = array(array(Value::$xmlrpcInt, Value::$xmlrpcInt));
600 $i_echoInteger_doc = "Echoes integer.";
602 $i_echoIntegerArray_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcArray));
603 $i_echoIntegerArray_doc = "Echoes integer array.";
605 $i_echoFloat_sig = array(array(Value::$xmlrpcDouble, Value::$xmlrpcDouble));
606 $i_echoFloat_doc = "Echoes float.";
608 $i_echoFloatArray_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcArray));
609 $i_echoFloatArray_doc = "Echoes float array.";
611 $i_echoStruct_sig = array(array(Value::$xmlrpcStruct, Value::$xmlrpcStruct));
612 $i_echoStruct_doc = "Echoes struct.";
614 $i_echoStructArray_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcArray));
615 $i_echoStructArray_doc = "Echoes struct array.";
617 $i_echoValue_doc = "Echoes any value back.";
618 $i_echoValue_sig = array(array(Value::$xmlrpcValue, Value::$xmlrpcValue));
620 $i_echoBase64_sig = array(array(Value::$xmlrpcBase64, Value::$xmlrpcBase64));
621 $i_echoBase64_doc = "Echoes base64.";
623 $i_echoDate_sig = array(array(Value::$xmlrpcDateTime, Value::$xmlrpcDateTime));
624 $i_echoDate_doc = "Echoes dateTime.";
626 function i_echoParam($req)
628 $s = $req->getParam(0);
630 return new PhpXmlRpc\Response($s);
633 function i_echoString($req)
635 return i_echoParam($req);
638 function i_echoInteger($req)
640 return i_echoParam($req);
643 function i_echoFloat($req)
645 return i_echoParam($req);
648 function i_echoStruct($req)
650 return i_echoParam($req);
653 function i_echoStringArray($req)
655 return i_echoParam($req);
658 function i_echoIntegerArray($req)
660 return i_echoParam($req);
663 function i_echoFloatArray($req)
665 return i_echoParam($req);
668 function i_echoStructArray($req)
670 return i_echoParam($req);
673 function i_echoValue($req)
675 return i_echoParam($req);
678 function i_echoBase64($req)
680 return i_echoParam($req);
683 function i_echoDate($req)
685 return i_echoParam($req);
688 $i_whichToolkit_sig = array(array(Value::$xmlrpcStruct));
689 $i_whichToolkit_doc = "Returns a struct containing the following strings: toolkitDocsUrl, toolkitName, toolkitVersion, toolkitOperatingSystem.";
691 function i_whichToolkit($req)
693 global $SERVER_SOFTWARE;
695 "toolkitDocsUrl" => "http://phpxmlrpc.sourceforge.net/",
696 "toolkitName" => PhpXmlRpc\PhpXmlRpc::$xmlrpcName,
697 "toolkitVersion" => PhpXmlRpc\PhpXmlRpc::$xmlrpcVersion,
698 "toolkitOperatingSystem" => isset($SERVER_SOFTWARE) ? $SERVER_SOFTWARE : $_SERVER['SERVER_SOFTWARE'],
701 $encoder = new PhpXmlRpc\Encoder();
702 return new PhpXmlRpc\Response($encoder->encode($ret));
705 $object = new xmlrpcServerMethodsContainer();
707 "examples.getStateName" => array(
708 "function" => "findState",
709 "signature" => $findstate_sig,
710 "docstring" => $findstate_doc,
712 "examples.sortByAge" => array(
713 "function" => "ageSorter",
714 "signature" => $agesorter_sig,
715 "docstring" => $agesorter_doc,
717 "examples.addtwo" => array(
718 "function" => "addTwo",
719 "signature" => $addtwo_sig,
720 "docstring" => $addtwo_doc,
722 "examples.addtwodouble" => array(
723 "function" => "addTwoDouble",
724 "signature" => $addtwodouble_sig,
725 "docstring" => $addtwodouble_doc,
727 "examples.stringecho" => array(
728 "function" => "stringEcho",
729 "signature" => $stringecho_sig,
730 "docstring" => $stringecho_doc,
732 "examples.echo" => array(
733 "function" => "echoBack",
734 "signature" => $echoback_sig,
735 "docstring" => $echoback_doc,
737 "examples.decode64" => array(
738 "function" => "echoSixtyFour",
739 "signature" => $echosixtyfour_sig,
740 "docstring" => $echosixtyfour_doc,
742 "examples.invertBooleans" => array(
743 "function" => "bitFlipper",
744 "signature" => $bitflipper_sig,
745 "docstring" => $bitflipper_doc,
747 // signature omitted on purpose
748 "tests.generatePHPWarning" => array(
749 "function" => array($object, "phpWarningGenerator"),
751 // signature omitted on purpose
752 "tests.raiseException" => array(
753 "function" => array($object, "exceptionGenerator"),
755 // Greek word 'kosme'. NB: NOT a valid ISO8859 string!
756 // NB: we can only register this when setting internal encoding to UTF-8, or it will break system.listMethods
757 "tests.utf8methodname." . 'κόσμε' => array(
758 "function" => "stringEcho",
759 "signature" => $stringecho_sig,
760 "docstring" => $stringecho_doc,
762 /*"tests.iso88591methodname." . chr(224) . chr(252) . chr(232) => array(
763 "function" => "stringEcho",
764 "signature" => $stringecho_sig,
765 "docstring" => $stringecho_doc,
767 "examples.getallheaders" => array(
768 "function" => 'getAllHeaders_xmlrpc',
769 "signature" => $getallheaders_sig,
770 "docstring" => $getallheaders_doc,
772 "examples.setcookies" => array(
773 "function" => 'setCookies',
774 "signature" => $setcookies_sig,
775 "docstring" => $setcookies_doc,
777 "examples.getcookies" => array(
778 "function" => 'getCookies',
779 "signature" => $getcookies_sig,
780 "docstring" => $getcookies_doc,
782 "mail.send" => array(
783 "function" => "mailSend",
784 "signature" => $mailsend_sig,
785 "docstring" => $mailsend_doc,
787 "validator1.arrayOfStructsTest" => array(
788 "function" => "v1_arrayOfStructs",
789 "signature" => $v1_arrayOfStructs_sig,
790 "docstring" => $v1_arrayOfStructs_doc,
792 "validator1.easyStructTest" => array(
793 "function" => "v1_easyStruct",
794 "signature" => $v1_easyStruct_sig,
795 "docstring" => $v1_easyStruct_doc,
797 "validator1.echoStructTest" => array(
798 "function" => "v1_echoStruct",
799 "signature" => $v1_echoStruct_sig,
800 "docstring" => $v1_echoStruct_doc,
802 "validator1.manyTypesTest" => array(
803 "function" => "v1_manyTypes",
804 "signature" => $v1_manyTypes_sig,
805 "docstring" => $v1_manyTypes_doc,
807 "validator1.moderateSizeArrayCheck" => array(
808 "function" => "v1_moderateSizeArrayCheck",
809 "signature" => $v1_moderateSizeArrayCheck_sig,
810 "docstring" => $v1_moderateSizeArrayCheck_doc,
812 "validator1.simpleStructReturnTest" => array(
813 "function" => "v1_simpleStructReturn",
814 "signature" => $v1_simpleStructReturn_sig,
815 "docstring" => $v1_simpleStructReturn_doc,
817 "validator1.nestedStructTest" => array(
818 "function" => "v1_nestedStruct",
819 "signature" => $v1_nestedStruct_sig,
820 "docstring" => $v1_nestedStruct_doc,
822 "validator1.countTheEntities" => array(
823 "function" => "v1_countTheEntities",
824 "signature" => $v1_countTheEntities_sig,
825 "docstring" => $v1_countTheEntities_doc,
827 "interopEchoTests.echoString" => array(
828 "function" => "i_echoString",
829 "signature" => $i_echoString_sig,
830 "docstring" => $i_echoString_doc,
832 "interopEchoTests.echoStringArray" => array(
833 "function" => "i_echoStringArray",
834 "signature" => $i_echoStringArray_sig,
835 "docstring" => $i_echoStringArray_doc,
837 "interopEchoTests.echoInteger" => array(
838 "function" => "i_echoInteger",
839 "signature" => $i_echoInteger_sig,
840 "docstring" => $i_echoInteger_doc,
842 "interopEchoTests.echoIntegerArray" => array(
843 "function" => "i_echoIntegerArray",
844 "signature" => $i_echoIntegerArray_sig,
845 "docstring" => $i_echoIntegerArray_doc,
847 "interopEchoTests.echoFloat" => array(
848 "function" => "i_echoFloat",
849 "signature" => $i_echoFloat_sig,
850 "docstring" => $i_echoFloat_doc,
852 "interopEchoTests.echoFloatArray" => array(
853 "function" => "i_echoFloatArray",
854 "signature" => $i_echoFloatArray_sig,
855 "docstring" => $i_echoFloatArray_doc,
857 "interopEchoTests.echoStruct" => array(
858 "function" => "i_echoStruct",
859 "signature" => $i_echoStruct_sig,
860 "docstring" => $i_echoStruct_doc,
862 "interopEchoTests.echoStructArray" => array(
863 "function" => "i_echoStructArray",
864 "signature" => $i_echoStructArray_sig,
865 "docstring" => $i_echoStructArray_doc,
867 "interopEchoTests.echoValue" => array(
868 "function" => "i_echoValue",
869 "signature" => $i_echoValue_sig,
870 "docstring" => $i_echoValue_doc,
872 "interopEchoTests.echoBase64" => array(
873 "function" => "i_echoBase64",
874 "signature" => $i_echoBase64_sig,
875 "docstring" => $i_echoBase64_doc,
877 "interopEchoTests.echoDate" => array(
878 "function" => "i_echoDate",
879 "signature" => $i_echoDate_sig,
880 "docstring" => $i_echoDate_doc,
882 "interopEchoTests.whichToolkit" => array(
883 "function" => "i_whichToolkit",
884 "signature" => $i_whichToolkit_sig,
885 "docstring" => $i_whichToolkit_doc,
888 'tests.getStateName.2' => $findstate2_sig,
889 'tests.getStateName.3' => $findstate3_sig,
890 'tests.getStateName.4' => $findstate4_sig,
891 'tests.getStateName.5' => $findstate5_sig,
892 'tests.getStateName.6' => $findstate6_sig,
893 'tests.getStateName.7' => $findstate7_sig,
894 'tests.getStateName.8' => $findstate8_sig,
895 'tests.getStateName.9' => $findstate9_sig,
896 'tests.getStateName.10' => $findstate10_sig,
897 'tests.getStateName.11' => $findstate11_sig,
900 $signatures = array_merge($signatures, $moreSignatures);
902 $s = new PhpXmlRpc\Server($signatures, false);
904 $s->compress_response = true;
906 // out-of-band information: let the client manipulate the server operations.
907 // we do this to help the testsuite script: do not reproduce in production!
908 if (isset($_GET['RESPONSE_ENCODING'])) {
909 $s->response_charset_encoding = $_GET['RESPONSE_ENCODING'];
911 if (isset($_GET['EXCEPTION_HANDLING'])) {
912 $s->exception_handling = $_GET['EXCEPTION_HANDLING'];
915 // that should do all we need!
917 // out-of-band information: let the client manipulate the server operations.
918 // we do this to help the testsuite script: do not reproduce in production!
919 if (isset($_COOKIE['PHPUNIT_SELENIUM_TEST_ID']) && extension_loaded('xdebug')) {
920 include_once __DIR__ . "/../../vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/SeleniumCommon/append.php";