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.
57 * Used to test wrapping of PHP methods into xmlrpc methods.
63 public static function findState($num)
65 return inner_findstate($num);
69 * Returns an instance of stdClass.
70 * Used to test wrapping of PHP objects with class preservation
72 public function returnObject()
74 $obj = new stdClass();
75 $obj->hello = 'world';
80 // a PHP version of the state-number server
81 // send me an integer and i'll sell you a state
84 "Alabama", "Alaska", "Arizona", "Arkansas", "California",
85 "Colorado", "Columbia", "Connecticut", "Delaware", "Florida",
86 "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas",
87 "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan",
88 "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada",
89 "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina",
90 "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island",
91 "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont",
92 "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming",
95 $findstate_sig = array(array(Value::$xmlrpcString, Value::$xmlrpcInt));
96 $findstate_doc = 'When passed an integer between 1 and 51 returns the
97 name of a US state, where the integer is the index of that state name
98 in an alphabetic order.';
100 function findState($req)
105 // get the first param
106 $sno = $req->getParam(0);
108 // param must be there and of the correct type: server object does the validation for us
110 // extract the value of the state number
111 $snv = $sno->scalarval();
112 // look it up in our array (zero-based)
113 if (isset($stateNames[$snv - 1])) {
114 $stateName = $stateNames[$snv - 1];
116 // not there, so complain
117 $err = "I don't have a state for the index '" . $snv . "'";
120 // if we generated an error, create an error return response
122 return new PhpXmlRpc\Response(0, PhpXmlRpc\PhpXmlRpc::$xmlrpcerruser, $err);
124 // otherwise, we create the right response with the state name
125 return new PhpXmlRpc\Response(new Value($stateName));
130 * Inner code of the state-number server.
131 * Used to test wrapping of PHP functions into xmlrpc methods.
133 * @param integer $stateNo the state number
135 * @return string the name of the state (or error description)
137 * @throws Exception if state is not found
139 function inner_findstate($stateNo)
143 if (isset($stateNames[$stateNo - 1])) {
144 return $stateNames[$stateNo - 1];
146 // not, there so complain
147 throw new Exception("I don't have a state for the index '" . $stateNo . "'", PhpXmlRpc\PhpXmlRpc::$xmlrpcerruser);
151 $wrapper = new PhpXmlRpc\Wrapper();
153 $findstate2_sig = $wrapper->wrap_php_function('inner_findstate');
155 $findstate3_sig = $wrapper->wrap_php_function(array('xmlrpcServerMethodsContainer', 'findState'));
157 $obj = new xmlrpcServerMethodsContainer();
158 $findstate4_sig = $wrapper->wrap_php_function(array($obj, 'findstate'));
160 $findstate5_sig = $wrapper->wrap_php_function('xmlrpcServerMethodsContainer::findState', '', array('return_source' => true));
161 eval($findstate5_sig['source']);
163 $findstate6_sig = $wrapper->wrap_php_function('inner_findstate', '', array('return_source' => true));
164 eval($findstate6_sig['source']);
166 $findstate7_sig = $wrapper->wrap_php_function(array('xmlrpcServerMethodsContainer', 'findState'), '', array('return_source' => true));
167 eval($findstate7_sig['source']);
169 $obj = new xmlrpcServerMethodsContainer();
170 $findstate8_sig = $wrapper->wrap_php_function(array($obj, 'findstate'), '', array('return_source' => true));
171 eval($findstate8_sig['source']);
173 $findstate9_sig = $wrapper->wrap_php_function('xmlrpcServerMethodsContainer::findState', '', array('return_source' => true));
174 eval($findstate9_sig['source']);
176 $findstate10_sig = array(
177 "function" => function ($req) { return findState($req); },
178 "signature" => $findstate_sig,
179 "docstring" => $findstate_doc,
182 $findstate11_sig = $wrapper->wrap_php_function(function ($stateNo) { return inner_findstate($stateNo); });
184 $c = new xmlrpcServerMethodsContainer;
185 $moreSignatures = $wrapper->wrap_php_class($c, array('prefix' => 'tests.', 'method_type' => 'all'));
187 $returnObj_sig = $wrapper->wrap_php_function(array($c, 'returnObject'), '', array('encode_php_objs' => true));
189 $addtwo_sig = array(array(Value::$xmlrpcInt, Value::$xmlrpcInt, Value::$xmlrpcInt));
190 $addtwo_doc = 'Add two integers together and return the result';
191 function addTwo($req)
193 $s = $req->getParam(0);
194 $t = $req->getParam(1);
196 return new PhpXmlRpc\Response(new Value($s->scalarval() + $t->scalarval(), "int"));
199 $addtwodouble_sig = array(array(Value::$xmlrpcDouble, Value::$xmlrpcDouble, Value::$xmlrpcDouble));
200 $addtwodouble_doc = 'Add two doubles together and return the result';
201 function addTwoDouble($req)
203 $s = $req->getParam(0);
204 $t = $req->getParam(1);
206 return new PhpXmlRpc\Response(new Value($s->scalarval() + $t->scalarval(), "double"));
209 $stringecho_sig = array(array(Value::$xmlrpcString, Value::$xmlrpcString));
210 $stringecho_doc = 'Accepts a string parameter, returns the string.';
211 function stringEcho($req)
213 // just sends back a string
214 return new PhpXmlRpc\Response(new Value($req->getParam(0)->scalarval()));
217 $echoback_sig = array(array(Value::$xmlrpcString, Value::$xmlrpcString));
218 $echoback_doc = 'Accepts a string parameter, returns the entire incoming payload';
219 function echoBack($req)
221 // just sends back a string with what i got sent to me, just escaped, that's all
222 $s = "I got the following message:\n" . $req->serialize();
224 return new PhpXmlRpc\Response(new Value($s));
227 $echosixtyfour_sig = array(array(Value::$xmlrpcString, Value::$xmlrpcBase64));
228 $echosixtyfour_doc = 'Accepts a base64 parameter and returns it decoded as a string';
229 function echoSixtyFour($req)
231 // Accepts an encoded value, but sends it back as a normal string.
232 // This is to test that base64 encoding is working as expected
233 $incoming = $req->getParam(0);
235 return new PhpXmlRpc\Response(new Value($incoming->scalarval(), "string"));
238 $bitflipper_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcArray));
239 $bitflipper_doc = 'Accepts an array of booleans, and returns them inverted';
240 function bitFlipper($req)
242 $v = $req->getParam(0);
243 $sz = $v->arraysize();
244 $rv = new Value(array(), Value::$xmlrpcArray);
246 for ($j = 0; $j < $sz; $j++) {
247 $b = $v->arraymem($j);
248 if ($b->scalarval()) {
249 $rv->addScalar(false, "boolean");
251 $rv->addScalar(true, "boolean");
255 return new PhpXmlRpc\Response($rv);
260 // send me an array of structs thus:
267 // and I'll return it to you in sorted order
269 function agesorter_compare($a, $b)
271 global $agesorter_arr;
273 // don't even ask me _why_ these come padded with hyphens, I couldn't tell you :p
274 $a = str_replace("-", "", $a);
275 $b = str_replace("-", "", $b);
277 if ($agesorter_arr[$a] == $agesorter_arr[$b]) {
281 return ($agesorter_arr[$a] > $agesorter_arr[$b]) ? -1 : 1;
284 $agesorter_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcArray));
285 $agesorter_doc = 'Send this method an array of [string, int] structs, eg:
292 And the array will be returned with the entries sorted by their numbers.
294 function ageSorter($req)
296 global $agesorter_arr, $s;
298 PhpXmlRpc\Server::xmlrpc_debugmsg("Entering 'agesorter'");
300 $sno = $req->getParam(0);
301 // error string for [if|when] things go wrong
303 // create the output value
307 $max = $sno->arraysize();
308 PhpXmlRpc\Server::xmlrpc_debugmsg("Found $max array elements");
309 for ($i = 0; $i < $max; $i++) {
310 $rec = $sno->arraymem($i);
311 if ($rec->kindOf() != "struct") {
312 $err = "Found non-struct in array at element $i";
315 // extract name and age from struct
316 $n = $rec->structmem("name");
317 $a = $rec->structmem("age");
318 // $n and $a are xmlrpcvals,
319 // so get the scalarval from them
320 $agar[$n->scalarval()] = $a->scalarval();
323 $agesorter_arr = $agar;
324 // hack, must make global as uksort() won't
325 // allow us to pass any other auxiliary information
326 uksort($agesorter_arr, 'agesorter_compare');
328 while (list($key, $val) = each($agesorter_arr)) {
329 // recreate each struct element
330 $outAr[] = new Value(array("name" => new Value($key),
331 "age" => new Value($val, "int"),), "struct");
333 // add this array to the output value
334 $v->addArray($outAr);
337 return new PhpXmlRpc\Response(0, PhpXmlRpc\PhpXmlRpc::$xmlrpcerruser, $err);
339 return new PhpXmlRpc\Response($v);
343 // signature and instructions, place these in the dispatch map
344 $mailsend_sig = array(array(
345 Value::$xmlrpcBoolean, Value::$xmlrpcString, Value::$xmlrpcString,
346 Value::$xmlrpcString, Value::$xmlrpcString, Value::$xmlrpcString,
347 Value::$xmlrpcString, Value::$xmlrpcString,
349 $mailsend_doc = 'mail.send(recipient, subject, text, sender, cc, bcc, mimetype)<br/>
350 recipient, cc, and bcc are strings, comma-separated lists of email addresses, as described above.<br/>
351 subject is a string, the subject of the message.<br/>
352 sender is a string, it\'s the email address of the person sending the message. This string can not be
353 a comma-separated list, it must contain a single email address only.<br/>
354 text is a string, it contains the body of the message.<br/>
355 mimetype, a string, is a standard MIME type, for example, text/plain.
357 // WARNING; this functionality depends on the sendmail -t option
358 // it may not work with Windows machines properly; particularly
359 // the Bcc option. Sneak on your friends at your own risk!
360 function mailSend($req)
364 $mTo = $req->getParam(0);
365 $mSub = $req->getParam(1);
366 $mBody = $req->getParam(2);
367 $mFrom = $req->getParam(3);
368 $mCc = $req->getParam(4);
369 $mBcc = $req->getParam(5);
370 $mMime = $req->getParam(6);
372 if ($mTo->scalarval() == "") {
373 $err = "Error, no 'To' field specified";
376 if ($mFrom->scalarval() == "") {
377 $err = "Error, no 'From' field specified";
380 $msgHdr = "From: " . $mFrom->scalarval() . "\n";
381 $msgHdr .= "To: " . $mTo->scalarval() . "\n";
383 if ($mCc->scalarval() != "") {
384 $msgHdr .= "Cc: " . $mCc->scalarval() . "\n";
386 if ($mBcc->scalarval() != "") {
387 $msgHdr .= "Bcc: " . $mBcc->scalarval() . "\n";
389 if ($mMime->scalarval() != "") {
390 $msgHdr .= "Content-type: " . $mMime->scalarval() . "\n";
392 $msgHdr .= "X-Mailer: XML-RPC for PHP mailer 1.0";
400 $err = "Error, could not send the mail.";
405 return new PhpXmlRpc\Response(0, PhpXmlRpc\PhpXmlRpc::$xmlrpcerruser, $err);
407 return new PhpXmlRpc\Response(new Value("true", Value::$xmlrpcBoolean));
411 $getallheaders_sig = array(array(Value::$xmlrpcStruct));
412 $getallheaders_doc = 'Returns a struct containing all the HTTP headers received with the request. Provides limited functionality with IIS';
413 function getAllHeaders_xmlrpc($req)
415 $encoder = new PhpXmlRpc\Encoder();
417 if (function_exists('getallheaders')) {
418 return new PhpXmlRpc\Response($encoder->encode(getallheaders()));
421 // IIS: poor man's version of getallheaders
422 foreach ($_SERVER as $key => $val) {
423 if (strpos($key, 'HTTP_') === 0) {
424 $key = ucfirst(str_replace('_', '-', strtolower(substr($key, 5))));
425 $headers[$key] = $val;
429 return new PhpXmlRpc\Response($encoder->encode($headers));
433 $setcookies_sig = array(array(Value::$xmlrpcInt, Value::$xmlrpcStruct));
434 $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)';
435 function setCookies($req)
437 $encoder = new PhpXmlRpc\Encoder();
438 $m = $req->getParam(0);
439 while (list($name, $value) = $m->structeach()) {
440 $cookieDesc = $encoder->decode($value);
441 setcookie($name, @$cookieDesc['value'], @$cookieDesc['expires'], @$cookieDesc['path'], @$cookieDesc['domain'], @$cookieDesc['secure']);
444 return new PhpXmlRpc\Response(new Value(1, 'int'));
447 $getcookies_sig = array(array(Value::$xmlrpcStruct));
448 $getcookies_doc = 'Sends to client a response containing all http cookies as received in the request (as struct)';
449 function getCookies($req)
451 $encoder = new PhpXmlRpc\Encoder();
452 return new PhpXmlRpc\Response($encoder->encode($_COOKIE));
455 $v1_arrayOfStructs_sig = array(array(Value::$xmlrpcInt, Value::$xmlrpcArray));
456 $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.';
457 function v1_arrayOfStructs($req)
459 $sno = $req->getParam(0);
461 for ($i = 0; $i < $sno->arraysize(); $i++) {
462 $str = $sno->arraymem($i);
464 while (list($key, $val) = $str->structeach()) {
465 if ($key == "curly") {
466 $numCurly += $val->scalarval();
471 return new PhpXmlRpc\Response(new Value($numCurly, "int"));
474 $v1_easyStruct_sig = array(array(Value::$xmlrpcInt, Value::$xmlrpcStruct));
475 $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.';
476 function v1_easyStruct($req)
478 $sno = $req->getParam(0);
479 $moe = $sno->structmem("moe");
480 $larry = $sno->structmem("larry");
481 $curly = $sno->structmem("curly");
482 $num = $moe->scalarval() + $larry->scalarval() + $curly->scalarval();
484 return new PhpXmlRpc\Response(new Value($num, "int"));
487 $v1_echoStruct_sig = array(array(Value::$xmlrpcStruct, Value::$xmlrpcStruct));
488 $v1_echoStruct_doc = 'This handler takes a single parameter, a struct. Your handler must return the struct.';
489 function v1_echoStruct($req)
491 $sno = $req->getParam(0);
493 return new PhpXmlRpc\Response($sno);
496 $v1_manyTypes_sig = array(array(
497 Value::$xmlrpcArray, Value::$xmlrpcInt, Value::$xmlrpcBoolean,
498 Value::$xmlrpcString, Value::$xmlrpcDouble, Value::$xmlrpcDateTime,
499 Value::$xmlrpcBase64,
501 $v1_manyTypes_doc = 'This handler takes six parameters, and returns an array containing all the parameters.';
502 function v1_manyTypes($req)
504 return new PhpXmlRpc\Response(new Value(array(
515 $v1_moderateSizeArrayCheck_sig = array(array(Value::$xmlrpcString, Value::$xmlrpcArray));
516 $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.';
517 function v1_moderateSizeArrayCheck($req)
519 $ar = $req->getParam(0);
520 $sz = $ar->arraysize();
521 $first = $ar->arraymem(0);
522 $last = $ar->arraymem($sz - 1);
524 return new PhpXmlRpc\Response(new Value($first->scalarval() .
525 $last->scalarval(), "string"));
528 $v1_simpleStructReturn_sig = array(array(Value::$xmlrpcStruct, Value::$xmlrpcInt));
529 $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.';
530 function v1_simpleStructReturn($req)
532 $sno = $req->getParam(0);
533 $v = $sno->scalarval();
535 return new PhpXmlRpc\Response(new Value(array(
536 "times10" => new Value($v * 10, "int"),
537 "times100" => new Value($v * 100, "int"),
538 "times1000" => new Value($v * 1000, "int"),),
543 $v1_nestedStruct_sig = array(array(Value::$xmlrpcInt, Value::$xmlrpcStruct));
544 $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.';
545 function v1_nestedStruct($req)
547 $sno = $req->getParam(0);
549 $twoK = $sno->structmem("2000");
550 $april = $twoK->structmem("04");
551 $fools = $april->structmem("01");
552 $curly = $fools->structmem("curly");
553 $larry = $fools->structmem("larry");
554 $moe = $fools->structmem("moe");
556 return new PhpXmlRpc\Response(new Value($curly->scalarval() + $larry->scalarval() + $moe->scalarval(), "int"));
559 $v1_countTheEntities_sig = array(array(Value::$xmlrpcStruct, Value::$xmlrpcString));
560 $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.';
561 function v1_countTheEntities($req)
563 $sno = $req->getParam(0);
564 $str = $sno->scalarval();
570 for ($i = 0; $i < strlen($str); $i++) {
571 $c = substr($str, $i, 1);
593 return new PhpXmlRpc\Response(new Value(array(
594 "ctLeftAngleBrackets" => new Value($lt, "int"),
595 "ctRightAngleBrackets" => new Value($gt, "int"),
596 "ctAmpersands" => new Value($amp, "int"),
597 "ctApostrophes" => new Value($ap, "int"),
598 "ctQuotes" => new Value($qu, "int"),),
603 // trivial interop tests
604 // http://www.xmlrpc.com/stories/storyReader$1636
606 $i_echoString_sig = array(array(Value::$xmlrpcString, Value::$xmlrpcString));
607 $i_echoString_doc = "Echoes string.";
609 $i_echoStringArray_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcArray));
610 $i_echoStringArray_doc = "Echoes string array.";
612 $i_echoInteger_sig = array(array(Value::$xmlrpcInt, Value::$xmlrpcInt));
613 $i_echoInteger_doc = "Echoes integer.";
615 $i_echoIntegerArray_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcArray));
616 $i_echoIntegerArray_doc = "Echoes integer array.";
618 $i_echoFloat_sig = array(array(Value::$xmlrpcDouble, Value::$xmlrpcDouble));
619 $i_echoFloat_doc = "Echoes float.";
621 $i_echoFloatArray_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcArray));
622 $i_echoFloatArray_doc = "Echoes float array.";
624 $i_echoStruct_sig = array(array(Value::$xmlrpcStruct, Value::$xmlrpcStruct));
625 $i_echoStruct_doc = "Echoes struct.";
627 $i_echoStructArray_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcArray));
628 $i_echoStructArray_doc = "Echoes struct array.";
630 $i_echoValue_doc = "Echoes any value back.";
631 $i_echoValue_sig = array(array(Value::$xmlrpcValue, Value::$xmlrpcValue));
633 $i_echoBase64_sig = array(array(Value::$xmlrpcBase64, Value::$xmlrpcBase64));
634 $i_echoBase64_doc = "Echoes base64.";
636 $i_echoDate_sig = array(array(Value::$xmlrpcDateTime, Value::$xmlrpcDateTime));
637 $i_echoDate_doc = "Echoes dateTime.";
639 function i_echoParam($req)
641 $s = $req->getParam(0);
643 return new PhpXmlRpc\Response($s);
646 function i_echoString($req)
648 return i_echoParam($req);
651 function i_echoInteger($req)
653 return i_echoParam($req);
656 function i_echoFloat($req)
658 return i_echoParam($req);
661 function i_echoStruct($req)
663 return i_echoParam($req);
666 function i_echoStringArray($req)
668 return i_echoParam($req);
671 function i_echoIntegerArray($req)
673 return i_echoParam($req);
676 function i_echoFloatArray($req)
678 return i_echoParam($req);
681 function i_echoStructArray($req)
683 return i_echoParam($req);
686 function i_echoValue($req)
688 return i_echoParam($req);
691 function i_echoBase64($req)
693 return i_echoParam($req);
696 function i_echoDate($req)
698 return i_echoParam($req);
701 $i_whichToolkit_sig = array(array(Value::$xmlrpcStruct));
702 $i_whichToolkit_doc = "Returns a struct containing the following strings: toolkitDocsUrl, toolkitName, toolkitVersion, toolkitOperatingSystem.";
704 function i_whichToolkit($req)
706 global $SERVER_SOFTWARE;
708 "toolkitDocsUrl" => "http://phpxmlrpc.sourceforge.net/",
709 "toolkitName" => PhpXmlRpc\PhpXmlRpc::$xmlrpcName,
710 "toolkitVersion" => PhpXmlRpc\PhpXmlRpc::$xmlrpcVersion,
711 "toolkitOperatingSystem" => isset($SERVER_SOFTWARE) ? $SERVER_SOFTWARE : $_SERVER['SERVER_SOFTWARE'],
714 $encoder = new PhpXmlRpc\Encoder();
715 return new PhpXmlRpc\Response($encoder->encode($ret));
718 $object = new xmlrpcServerMethodsContainer();
720 "examples.getStateName" => array(
721 "function" => "findState",
722 "signature" => $findstate_sig,
723 "docstring" => $findstate_doc,
725 "examples.sortByAge" => array(
726 "function" => "ageSorter",
727 "signature" => $agesorter_sig,
728 "docstring" => $agesorter_doc,
730 "examples.addtwo" => array(
731 "function" => "addTwo",
732 "signature" => $addtwo_sig,
733 "docstring" => $addtwo_doc,
735 "examples.addtwodouble" => array(
736 "function" => "addTwoDouble",
737 "signature" => $addtwodouble_sig,
738 "docstring" => $addtwodouble_doc,
740 "examples.stringecho" => array(
741 "function" => "stringEcho",
742 "signature" => $stringecho_sig,
743 "docstring" => $stringecho_doc,
745 "examples.echo" => array(
746 "function" => "echoBack",
747 "signature" => $echoback_sig,
748 "docstring" => $echoback_doc,
750 "examples.decode64" => array(
751 "function" => "echoSixtyFour",
752 "signature" => $echosixtyfour_sig,
753 "docstring" => $echosixtyfour_doc,
755 "examples.invertBooleans" => array(
756 "function" => "bitFlipper",
757 "signature" => $bitflipper_sig,
758 "docstring" => $bitflipper_doc,
760 // signature omitted on purpose
761 "tests.generatePHPWarning" => array(
762 "function" => array($object, "phpWarningGenerator"),
764 // signature omitted on purpose
765 "tests.raiseException" => array(
766 "function" => array($object, "exceptionGenerator"),
768 // Greek word 'kosme'. NB: NOT a valid ISO8859 string!
769 // NB: we can only register this when setting internal encoding to UTF-8, or it will break system.listMethods
770 "tests.utf8methodname." . 'κόσμε' => array(
771 "function" => "stringEcho",
772 "signature" => $stringecho_sig,
773 "docstring" => $stringecho_doc,
775 /*"tests.iso88591methodname." . chr(224) . chr(252) . chr(232) => array(
776 "function" => "stringEcho",
777 "signature" => $stringecho_sig,
778 "docstring" => $stringecho_doc,
780 "examples.getallheaders" => array(
781 "function" => 'getAllHeaders_xmlrpc',
782 "signature" => $getallheaders_sig,
783 "docstring" => $getallheaders_doc,
785 "examples.setcookies" => array(
786 "function" => 'setCookies',
787 "signature" => $setcookies_sig,
788 "docstring" => $setcookies_doc,
790 "examples.getcookies" => array(
791 "function" => 'getCookies',
792 "signature" => $getcookies_sig,
793 "docstring" => $getcookies_doc,
795 "mail.send" => array(
796 "function" => "mailSend",
797 "signature" => $mailsend_sig,
798 "docstring" => $mailsend_doc,
800 "validator1.arrayOfStructsTest" => array(
801 "function" => "v1_arrayOfStructs",
802 "signature" => $v1_arrayOfStructs_sig,
803 "docstring" => $v1_arrayOfStructs_doc,
805 "validator1.easyStructTest" => array(
806 "function" => "v1_easyStruct",
807 "signature" => $v1_easyStruct_sig,
808 "docstring" => $v1_easyStruct_doc,
810 "validator1.echoStructTest" => array(
811 "function" => "v1_echoStruct",
812 "signature" => $v1_echoStruct_sig,
813 "docstring" => $v1_echoStruct_doc,
815 "validator1.manyTypesTest" => array(
816 "function" => "v1_manyTypes",
817 "signature" => $v1_manyTypes_sig,
818 "docstring" => $v1_manyTypes_doc,
820 "validator1.moderateSizeArrayCheck" => array(
821 "function" => "v1_moderateSizeArrayCheck",
822 "signature" => $v1_moderateSizeArrayCheck_sig,
823 "docstring" => $v1_moderateSizeArrayCheck_doc,
825 "validator1.simpleStructReturnTest" => array(
826 "function" => "v1_simpleStructReturn",
827 "signature" => $v1_simpleStructReturn_sig,
828 "docstring" => $v1_simpleStructReturn_doc,
830 "validator1.nestedStructTest" => array(
831 "function" => "v1_nestedStruct",
832 "signature" => $v1_nestedStruct_sig,
833 "docstring" => $v1_nestedStruct_doc,
835 "validator1.countTheEntities" => array(
836 "function" => "v1_countTheEntities",
837 "signature" => $v1_countTheEntities_sig,
838 "docstring" => $v1_countTheEntities_doc,
840 "interopEchoTests.echoString" => array(
841 "function" => "i_echoString",
842 "signature" => $i_echoString_sig,
843 "docstring" => $i_echoString_doc,
845 "interopEchoTests.echoStringArray" => array(
846 "function" => "i_echoStringArray",
847 "signature" => $i_echoStringArray_sig,
848 "docstring" => $i_echoStringArray_doc,
850 "interopEchoTests.echoInteger" => array(
851 "function" => "i_echoInteger",
852 "signature" => $i_echoInteger_sig,
853 "docstring" => $i_echoInteger_doc,
855 "interopEchoTests.echoIntegerArray" => array(
856 "function" => "i_echoIntegerArray",
857 "signature" => $i_echoIntegerArray_sig,
858 "docstring" => $i_echoIntegerArray_doc,
860 "interopEchoTests.echoFloat" => array(
861 "function" => "i_echoFloat",
862 "signature" => $i_echoFloat_sig,
863 "docstring" => $i_echoFloat_doc,
865 "interopEchoTests.echoFloatArray" => array(
866 "function" => "i_echoFloatArray",
867 "signature" => $i_echoFloatArray_sig,
868 "docstring" => $i_echoFloatArray_doc,
870 "interopEchoTests.echoStruct" => array(
871 "function" => "i_echoStruct",
872 "signature" => $i_echoStruct_sig,
873 "docstring" => $i_echoStruct_doc,
875 "interopEchoTests.echoStructArray" => array(
876 "function" => "i_echoStructArray",
877 "signature" => $i_echoStructArray_sig,
878 "docstring" => $i_echoStructArray_doc,
880 "interopEchoTests.echoValue" => array(
881 "function" => "i_echoValue",
882 "signature" => $i_echoValue_sig,
883 "docstring" => $i_echoValue_doc,
885 "interopEchoTests.echoBase64" => array(
886 "function" => "i_echoBase64",
887 "signature" => $i_echoBase64_sig,
888 "docstring" => $i_echoBase64_doc,
890 "interopEchoTests.echoDate" => array(
891 "function" => "i_echoDate",
892 "signature" => $i_echoDate_sig,
893 "docstring" => $i_echoDate_doc,
895 "interopEchoTests.whichToolkit" => array(
896 "function" => "i_whichToolkit",
897 "signature" => $i_whichToolkit_sig,
898 "docstring" => $i_whichToolkit_doc,
901 'tests.getStateName.2' => $findstate2_sig,
902 'tests.getStateName.3' => $findstate3_sig,
903 'tests.getStateName.4' => $findstate4_sig,
904 'tests.getStateName.5' => $findstate5_sig,
905 'tests.getStateName.6' => $findstate6_sig,
906 'tests.getStateName.7' => $findstate7_sig,
907 'tests.getStateName.8' => $findstate8_sig,
908 'tests.getStateName.9' => $findstate9_sig,
909 'tests.getStateName.10' => $findstate10_sig,
910 'tests.getStateName.11' => $findstate11_sig,
912 'tests.returnPhpObject' => $returnObj_sig,
915 $signatures = array_merge($signatures, $moreSignatures);
917 $s = new PhpXmlRpc\Server($signatures, false);
919 $s->compress_response = true;
921 // out-of-band information: let the client manipulate the server operations.
922 // we do this to help the testsuite script: do not reproduce in production!
923 if (isset($_GET['RESPONSE_ENCODING'])) {
924 $s->response_charset_encoding = $_GET['RESPONSE_ENCODING'];
926 if (isset($_GET['EXCEPTION_HANDLING'])) {
927 $s->exception_handling = $_GET['EXCEPTION_HANDLING'];
930 // that should do all we need!
932 // out-of-band information: let the client manipulate the server operations.
933 // we do this to help the testsuite script: do not reproduce in production!
934 if (isset($_COOKIE['PHPUNIT_SELENIUM_TEST_ID']) && extension_loaded('xdebug')) {
935 include_once __DIR__ . "/../../vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/SeleniumCommon/append.php";