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.
40 * @param PhpXmlRpc\Request $req
41 * @return PhpXmlRpc\Response
43 public function phpWarningGenerator($req)
45 $a = $undefinedVariable; // this triggers a warning in E_ALL mode, since $undefinedVariable is undefined
46 return new PhpXmlRpc\Response(new Value(1, Value::$xmlrpcBoolean));
50 * Method used to test catching of exceptions in the server.
51 * @param PhpXmlRpc\Request $req
54 public function exceptionGenerator($req)
56 throw new Exception("it's just a test", 1);
62 public function debugMessageGenerator($msg)
64 PhpXmlRpc\Server::xmlrpc_debugmsg($msg);
68 * A PHP version of the state-number server. Send me an integer and i'll sell you a state.
69 * Used to test wrapping of PHP methods into xmlrpc methods.
75 public static function findState($num)
77 return inner_findstate($num);
81 * Returns an instance of stdClass.
82 * Used to test wrapping of PHP objects with class preservation
84 public function returnObject()
86 $obj = new stdClass();
87 $obj->hello = 'world';
92 // a PHP version of the state-number server
93 // send me an integer and i'll sell you a state
96 "Alabama", "Alaska", "Arizona", "Arkansas", "California",
97 "Colorado", "Columbia", "Connecticut", "Delaware", "Florida",
98 "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas",
99 "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan",
100 "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada",
101 "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina",
102 "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island",
103 "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont",
104 "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming",
107 $findstate_sig = array(array(Value::$xmlrpcString, Value::$xmlrpcInt));
108 $findstate_doc = 'When passed an integer between 1 and 51 returns the
109 name of a US state, where the integer is the index of that state name
110 in an alphabetic order.';
112 function findState($req)
117 // get the first param
118 $sno = $req->getParam(0);
120 // param must be there and of the correct type: server object does the validation for us
122 // extract the value of the state number
123 $snv = $sno->scalarval();
124 // look it up in our array (zero-based)
125 if (isset($stateNames[$snv - 1])) {
126 $stateName = $stateNames[$snv - 1];
128 // not there, so complain
129 $err = "I don't have a state for the index '" . $snv . "'";
132 // if we generated an error, create an error return response
134 return new PhpXmlRpc\Response(0, PhpXmlRpc\PhpXmlRpc::$xmlrpcerruser, $err);
136 // otherwise, we create the right response with the state name
137 return new PhpXmlRpc\Response(new Value($stateName));
142 * Inner code of the state-number server.
143 * Used to test wrapping of PHP functions into xmlrpc methods.
145 * @param integer $stateNo the state number
147 * @return string the name of the state (or error description)
149 * @throws Exception if state is not found
151 function inner_findstate($stateNo)
155 if (isset($stateNames[$stateNo - 1])) {
156 return $stateNames[$stateNo - 1];
158 // not, there so complain
159 throw new Exception("I don't have a state for the index '" . $stateNo . "'", PhpXmlRpc\PhpXmlRpc::$xmlrpcerruser);
163 $wrapper = new PhpXmlRpc\Wrapper();
165 $findstate2_sig = $wrapper->wrapPhpFunction('inner_findstate');
167 $findstate3_sig = $wrapper->wrapPhpFunction(array('xmlrpcServerMethodsContainer', 'findState'));
169 $obj = new xmlrpcServerMethodsContainer();
170 $findstate4_sig = $wrapper->wrapPhpFunction(array($obj, 'findstate'));
172 $findstate5_sig = $wrapper->wrapPhpFunction('xmlrpcServerMethodsContainer::findState', '', array('return_source' => true));
173 eval($findstate5_sig['source']);
175 $findstate6_sig = $wrapper->wrapPhpFunction('inner_findstate', '', array('return_source' => true));
176 eval($findstate6_sig['source']);
178 $findstate7_sig = $wrapper->wrapPhpFunction(array('xmlrpcServerMethodsContainer', 'findState'), '', array('return_source' => true));
179 eval($findstate7_sig['source']);
181 $obj = new xmlrpcServerMethodsContainer();
182 $findstate8_sig = $wrapper->wrapPhpFunction(array($obj, 'findstate'), '', array('return_source' => true));
183 eval($findstate8_sig['source']);
185 $findstate9_sig = $wrapper->wrapPhpFunction('xmlrpcServerMethodsContainer::findState', '', array('return_source' => true));
186 eval($findstate9_sig['source']);
188 $findstate10_sig = array(
189 "function" => function ($req) { return findState($req); },
190 "signature" => $findstate_sig,
191 "docstring" => $findstate_doc,
194 $findstate11_sig = $wrapper->wrapPhpFunction(function ($stateNo) { return inner_findstate($stateNo); });
196 $c = new xmlrpcServerMethodsContainer;
197 $moreSignatures = $wrapper->wrapPhpClass($c, array('prefix' => 'tests.', 'method_type' => 'all'));
199 $returnObj_sig = $wrapper->wrapPhpFunction(array($c, 'returnObject'), '', array('encode_php_objs' => true));
201 // used to test signatures with NULL params
202 $findstate12_sig = array(
203 array(Value::$xmlrpcString, Value::$xmlrpcInt, Value::$xmlrpcNull),
204 array(Value::$xmlrpcString, Value::$xmlrpcNull, Value::$xmlrpcInt),
207 function findStateWithNulls($req)
209 $a = $req->getParam(0);
210 $b = $req->getParam(1);
212 if ($a->scalartyp() == Value::$xmlrpcNull)
213 return new PhpXmlRpc\Response(new Value(inner_findstate($b->scalarval())));
215 return new PhpXmlRpc\Response(new Value(inner_findstate($a->scalarval())));
218 $addtwo_sig = array(array(Value::$xmlrpcInt, Value::$xmlrpcInt, Value::$xmlrpcInt));
219 $addtwo_doc = 'Add two integers together and return the result';
220 function addTwo($req)
222 $s = $req->getParam(0);
223 $t = $req->getParam(1);
225 return new PhpXmlRpc\Response(new Value($s->scalarval() + $t->scalarval(), Value::$xmlrpcInt));
228 $addtwodouble_sig = array(array(Value::$xmlrpcDouble, Value::$xmlrpcDouble, Value::$xmlrpcDouble));
229 $addtwodouble_doc = 'Add two doubles together and return the result';
230 function addTwoDouble($req)
232 $s = $req->getParam(0);
233 $t = $req->getParam(1);
235 return new PhpXmlRpc\Response(new Value($s->scalarval() + $t->scalarval(), Value::$xmlrpcDouble));
238 $stringecho_sig = array(array(Value::$xmlrpcString, Value::$xmlrpcString));
239 $stringecho_doc = 'Accepts a string parameter, returns the string.';
240 function stringEcho($req)
242 // just sends back a string
243 return new PhpXmlRpc\Response(new Value($req->getParam(0)->scalarval()));
246 $echoback_sig = array(array(Value::$xmlrpcString, Value::$xmlrpcString));
247 $echoback_doc = 'Accepts a string parameter, returns the entire incoming payload';
248 function echoBack($req)
250 // just sends back a string with what i got sent to me, just escaped, that's all
251 $s = "I got the following message:\n" . $req->serialize();
253 return new PhpXmlRpc\Response(new Value($s));
256 $echosixtyfour_sig = array(array(Value::$xmlrpcString, Value::$xmlrpcBase64));
257 $echosixtyfour_doc = 'Accepts a base64 parameter and returns it decoded as a string';
258 function echoSixtyFour($req)
260 // Accepts an encoded value, but sends it back as a normal string.
261 // This is to test that base64 encoding is working as expected
262 $incoming = $req->getParam(0);
264 return new PhpXmlRpc\Response(new Value($incoming->scalarval(), Value::$xmlrpcString));
267 $bitflipper_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcArray));
268 $bitflipper_doc = 'Accepts an array of booleans, and returns them inverted';
269 function bitFlipper($req)
271 $v = $req->getParam(0);
272 $rv = new Value(array(), Value::$xmlrpcArray);
275 if ($b->scalarval()) {
276 $rv[] = new Value(false, Value::$xmlrpcBoolean);
278 $rv[] = new Value(true, Value::$xmlrpcBoolean);
282 return new PhpXmlRpc\Response($rv);
287 // send me an array of structs thus:
294 // and I'll return it to you in sorted order
296 function agesorter_compare($a, $b)
298 global $agesorter_arr;
300 // don't even ask me _why_ these come padded with hyphens, I couldn't tell you :p
301 $a = str_replace("-", "", $a);
302 $b = str_replace("-", "", $b);
304 if ($agesorter_arr[$a] == $agesorter_arr[$b]) {
308 return ($agesorter_arr[$a] > $agesorter_arr[$b]) ? -1 : 1;
311 $agesorter_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcArray));
312 $agesorter_doc = 'Send this method an array of [string, int] structs, eg:
319 And the array will be returned with the entries sorted by their numbers.
321 function ageSorter($req)
323 global $agesorter_arr, $s;
325 PhpXmlRpc\Server::xmlrpc_debugmsg("Entering 'agesorter'");
327 $sno = $req->getParam(0);
328 // error string for [if|when] things go wrong
332 $max = $sno->count();
333 PhpXmlRpc\Server::xmlrpc_debugmsg("Found $max array elements");
334 foreach ($sno as $i => $rec) {
335 if ($rec->kindOf() != "struct") {
336 $err = "Found non-struct in array at element $i";
339 // extract name and age from struct
342 // $n and $a are xmlrpcvals,
343 // so get the scalarval from them
344 $agar[$n->scalarval()] = $a->scalarval();
347 // create the output value
348 $v = new Value(array(), Value::$xmlrpcArray);
350 $agesorter_arr = $agar;
351 // hack, must make global as uksort() won't
352 // allow us to pass any other auxiliary information
353 uksort($agesorter_arr, 'agesorter_compare');
354 foreach($agesorter_arr as $key => $val) {
355 // recreate each struct element
358 "name" => new Value($key),
359 "age" => new Value($val, "int")
366 return new PhpXmlRpc\Response(0, PhpXmlRpc\PhpXmlRpc::$xmlrpcerruser, $err);
368 return new PhpXmlRpc\Response($v);
372 // signature and instructions, place these in the dispatch map
373 $mailsend_sig = array(array(
374 Value::$xmlrpcBoolean, Value::$xmlrpcString, Value::$xmlrpcString,
375 Value::$xmlrpcString, Value::$xmlrpcString, Value::$xmlrpcString,
376 Value::$xmlrpcString, Value::$xmlrpcString,
378 $mailsend_doc = 'mail.send(recipient, subject, text, sender, cc, bcc, mimetype)<br/>
379 recipient, cc, and bcc are strings, comma-separated lists of email addresses, as described above.<br/>
380 subject is a string, the subject of the message.<br/>
381 sender is a string, it\'s the email address of the person sending the message. This string can not be
382 a comma-separated list, it must contain a single email address only.<br/>
383 text is a string, it contains the body of the message.<br/>
384 mimetype, a string, is a standard MIME type, for example, text/plain.
386 // WARNING; this functionality depends on the sendmail -t option
387 // it may not work with Windows machines properly; particularly
388 // the Bcc option. Sneak on your friends at your own risk!
389 function mailSend($req)
393 $mTo = $req->getParam(0);
394 $mSub = $req->getParam(1);
395 $mBody = $req->getParam(2);
396 $mFrom = $req->getParam(3);
397 $mCc = $req->getParam(4);
398 $mBcc = $req->getParam(5);
399 $mMime = $req->getParam(6);
401 if ($mTo->scalarval() == "") {
402 $err = "Error, no 'To' field specified";
405 if ($mFrom->scalarval() == "") {
406 $err = "Error, no 'From' field specified";
409 $msgHdr = "From: " . $mFrom->scalarval() . "\n";
410 $msgHdr .= "To: " . $mTo->scalarval() . "\n";
412 if ($mCc->scalarval() != "") {
413 $msgHdr .= "Cc: " . $mCc->scalarval() . "\n";
415 if ($mBcc->scalarval() != "") {
416 $msgHdr .= "Bcc: " . $mBcc->scalarval() . "\n";
418 if ($mMime->scalarval() != "") {
419 $msgHdr .= "Content-type: " . $mMime->scalarval() . "\n";
421 $msgHdr .= "X-Mailer: XML-RPC for PHP mailer 1.0";
429 $err = "Error, could not send the mail.";
434 return new PhpXmlRpc\Response(0, PhpXmlRpc\PhpXmlRpc::$xmlrpcerruser, $err);
436 return new PhpXmlRpc\Response(new Value(true, Value::$xmlrpcBoolean));
440 $getallheaders_sig = array(array(Value::$xmlrpcStruct));
441 $getallheaders_doc = 'Returns a struct containing all the HTTP headers received with the request. Provides limited functionality with IIS';
442 function getAllHeaders_xmlrpc($req)
444 $encoder = new PhpXmlRpc\Encoder();
446 if (function_exists('getallheaders')) {
447 return new PhpXmlRpc\Response($encoder->encode(getallheaders()));
450 // IIS: poor man's version of getallheaders
451 foreach ($_SERVER as $key => $val) {
452 if (strpos($key, 'HTTP_') === 0) {
453 $key = ucfirst(str_replace('_', '-', strtolower(substr($key, 5))));
454 $headers[$key] = $val;
458 return new PhpXmlRpc\Response($encoder->encode($headers));
462 $setcookies_sig = array(array(Value::$xmlrpcInt, Value::$xmlrpcStruct));
463 $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)';
464 function setCookies($req)
466 $encoder = new PhpXmlRpc\Encoder();
467 $cookies = $req->getParam(0);
468 foreach ($cookies as $name => $value) {
469 $cookieDesc = $encoder->decode($value);
470 setcookie($name, @$cookieDesc['value'], @$cookieDesc['expires'], @$cookieDesc['path'], @$cookieDesc['domain'], @$cookieDesc['secure']);
473 return new PhpXmlRpc\Response(new Value(1, Value::$xmlrpcInt));
476 $getcookies_sig = array(array(Value::$xmlrpcStruct));
477 $getcookies_doc = 'Sends to client a response containing all http cookies as received in the request (as struct)';
478 function getCookies($req)
480 $encoder = new PhpXmlRpc\Encoder();
481 return new PhpXmlRpc\Response($encoder->encode($_COOKIE));
484 $v1_arrayOfStructs_sig = array(array(Value::$xmlrpcInt, Value::$xmlrpcArray));
485 $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.';
486 function v1_arrayOfStructs($req)
488 $sno = $req->getParam(0);
490 foreach ($sno as $str) {
491 foreach ($str as $key => $val) {
492 if ($key == "curly") {
493 $numCurly += $val->scalarval();
498 return new PhpXmlRpc\Response(new Value($numCurly, Value::$xmlrpcInt));
501 $v1_easyStruct_sig = array(array(Value::$xmlrpcInt, Value::$xmlrpcStruct));
502 $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.';
503 function v1_easyStruct($req)
505 $sno = $req->getParam(0);
507 $larry = $sno["larry"];
508 $curly = $sno["curly"];
509 $num = $moe->scalarval() + $larry->scalarval() + $curly->scalarval();
511 return new PhpXmlRpc\Response(new Value($num, Value::$xmlrpcInt));
514 $v1_echoStruct_sig = array(array(Value::$xmlrpcStruct, Value::$xmlrpcStruct));
515 $v1_echoStruct_doc = 'This handler takes a single parameter, a struct. Your handler must return the struct.';
516 function v1_echoStruct($req)
518 $sno = $req->getParam(0);
520 return new PhpXmlRpc\Response($sno);
523 $v1_manyTypes_sig = array(array(
524 Value::$xmlrpcArray, Value::$xmlrpcInt, Value::$xmlrpcBoolean,
525 Value::$xmlrpcString, Value::$xmlrpcDouble, Value::$xmlrpcDateTime,
526 Value::$xmlrpcBase64,
528 $v1_manyTypes_doc = 'This handler takes six parameters, and returns an array containing all the parameters.';
529 function v1_manyTypes($req)
531 return new PhpXmlRpc\Response(new Value(
544 $v1_moderateSizeArrayCheck_sig = array(array(Value::$xmlrpcString, Value::$xmlrpcArray));
545 $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.';
546 function v1_moderateSizeArrayCheck($req)
548 $ar = $req->getParam(0);
551 $last = $ar[$sz - 1];
553 return new PhpXmlRpc\Response(new Value($first->scalarval() .
554 $last->scalarval(), Value::$xmlrpcString));
557 $v1_simpleStructReturn_sig = array(array(Value::$xmlrpcStruct, Value::$xmlrpcInt));
558 $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.';
559 function v1_simpleStructReturn($req)
561 $sno = $req->getParam(0);
562 $v = $sno->scalarval();
564 return new PhpXmlRpc\Response(new Value(
566 "times10" => new Value($v * 10, Value::$xmlrpcInt),
567 "times100" => new Value($v * 100, Value::$xmlrpcInt),
568 "times1000" => new Value($v * 1000, Value::$xmlrpcInt)
574 $v1_nestedStruct_sig = array(array(Value::$xmlrpcInt, Value::$xmlrpcStruct));
575 $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.';
576 function v1_nestedStruct($req)
578 $sno = $req->getParam(0);
580 $twoK = $sno["2000"];
581 $april = $twoK["04"];
582 $fools = $april["01"];
583 $curly = $fools["curly"];
584 $larry = $fools["larry"];
585 $moe = $fools["moe"];
587 return new PhpXmlRpc\Response(new Value($curly->scalarval() + $larry->scalarval() + $moe->scalarval(), Value::$xmlrpcInt));
590 $v1_countTheEntities_sig = array(array(Value::$xmlrpcStruct, Value::$xmlrpcString));
591 $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.';
592 function v1_countTheEntities($req)
594 $sno = $req->getParam(0);
595 $str = $sno->scalarval();
601 for ($i = 0; $i < strlen($str); $i++) {
602 $c = substr($str, $i, 1);
624 return new PhpXmlRpc\Response(new Value(
626 "ctLeftAngleBrackets" => new Value($lt, Value::$xmlrpcInt),
627 "ctRightAngleBrackets" => new Value($gt, Value::$xmlrpcInt),
628 "ctAmpersands" => new Value($amp, Value::$xmlrpcInt),
629 "ctApostrophes" => new Value($ap, Value::$xmlrpcInt),
630 "ctQuotes" => new Value($qu, Value::$xmlrpcInt)
636 // trivial interop tests
637 // http://www.xmlrpc.com/stories/storyReader$1636
639 $i_echoString_sig = array(array(Value::$xmlrpcString, Value::$xmlrpcString));
640 $i_echoString_doc = "Echoes string.";
642 $i_echoStringArray_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcArray));
643 $i_echoStringArray_doc = "Echoes string array.";
645 $i_echoInteger_sig = array(array(Value::$xmlrpcInt, Value::$xmlrpcInt));
646 $i_echoInteger_doc = "Echoes integer.";
648 $i_echoIntegerArray_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcArray));
649 $i_echoIntegerArray_doc = "Echoes integer array.";
651 $i_echoFloat_sig = array(array(Value::$xmlrpcDouble, Value::$xmlrpcDouble));
652 $i_echoFloat_doc = "Echoes float.";
654 $i_echoFloatArray_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcArray));
655 $i_echoFloatArray_doc = "Echoes float array.";
657 $i_echoStruct_sig = array(array(Value::$xmlrpcStruct, Value::$xmlrpcStruct));
658 $i_echoStruct_doc = "Echoes struct.";
660 $i_echoStructArray_sig = array(array(Value::$xmlrpcArray, Value::$xmlrpcArray));
661 $i_echoStructArray_doc = "Echoes struct array.";
663 $i_echoValue_doc = "Echoes any value back.";
664 $i_echoValue_sig = array(array(Value::$xmlrpcValue, Value::$xmlrpcValue));
666 $i_echoBase64_sig = array(array(Value::$xmlrpcBase64, Value::$xmlrpcBase64));
667 $i_echoBase64_doc = "Echoes base64.";
669 $i_echoDate_sig = array(array(Value::$xmlrpcDateTime, Value::$xmlrpcDateTime));
670 $i_echoDate_doc = "Echoes dateTime.";
672 function i_echoParam($req)
674 $s = $req->getParam(0);
676 return new PhpXmlRpc\Response($s);
679 function i_echoString($req)
681 return i_echoParam($req);
684 function i_echoInteger($req)
686 return i_echoParam($req);
689 function i_echoFloat($req)
691 return i_echoParam($req);
694 function i_echoStruct($req)
696 return i_echoParam($req);
699 function i_echoStringArray($req)
701 return i_echoParam($req);
704 function i_echoIntegerArray($req)
706 return i_echoParam($req);
709 function i_echoFloatArray($req)
711 return i_echoParam($req);
714 function i_echoStructArray($req)
716 return i_echoParam($req);
719 function i_echoValue($req)
721 return i_echoParam($req);
724 function i_echoBase64($req)
726 return i_echoParam($req);
729 function i_echoDate($req)
731 return i_echoParam($req);
734 $i_whichToolkit_sig = array(array(Value::$xmlrpcStruct));
735 $i_whichToolkit_doc = "Returns a struct containing the following strings: toolkitDocsUrl, toolkitName, toolkitVersion, toolkitOperatingSystem.";
737 function i_whichToolkit($req)
739 global $SERVER_SOFTWARE;
741 "toolkitDocsUrl" => "http://phpxmlrpc.sourceforge.net/",
742 "toolkitName" => PhpXmlRpc\PhpXmlRpc::$xmlrpcName,
743 "toolkitVersion" => PhpXmlRpc\PhpXmlRpc::$xmlrpcVersion,
744 "toolkitOperatingSystem" => isset($SERVER_SOFTWARE) ? $SERVER_SOFTWARE : $_SERVER['SERVER_SOFTWARE'],
747 $encoder = new PhpXmlRpc\Encoder();
748 return new PhpXmlRpc\Response($encoder->encode($ret));
751 $object = new xmlrpcServerMethodsContainer();
753 "examples.getStateName" => array(
754 "function" => "findState",
755 "signature" => $findstate_sig,
756 "docstring" => $findstate_doc,
758 "examples.sortByAge" => array(
759 "function" => "ageSorter",
760 "signature" => $agesorter_sig,
761 "docstring" => $agesorter_doc,
763 "examples.addtwo" => array(
764 "function" => "addTwo",
765 "signature" => $addtwo_sig,
766 "docstring" => $addtwo_doc,
768 "examples.addtwodouble" => array(
769 "function" => "addTwoDouble",
770 "signature" => $addtwodouble_sig,
771 "docstring" => $addtwodouble_doc,
773 "examples.stringecho" => array(
774 "function" => "stringEcho",
775 "signature" => $stringecho_sig,
776 "docstring" => $stringecho_doc,
778 "examples.echo" => array(
779 "function" => "echoBack",
780 "signature" => $echoback_sig,
781 "docstring" => $echoback_doc,
783 "examples.decode64" => array(
784 "function" => "echoSixtyFour",
785 "signature" => $echosixtyfour_sig,
786 "docstring" => $echosixtyfour_doc,
788 "examples.invertBooleans" => array(
789 "function" => "bitFlipper",
790 "signature" => $bitflipper_sig,
791 "docstring" => $bitflipper_doc,
793 // signature omitted on purpose
794 "tests.generatePHPWarning" => array(
795 "function" => array($object, "phpWarningGenerator"),
797 // signature omitted on purpose
798 "tests.raiseException" => array(
799 "function" => array($object, "exceptionGenerator"),
801 // Greek word 'kosme'. NB: NOT a valid ISO8859 string!
802 // NB: we can only register this when setting internal encoding to UTF-8, or it will break system.listMethods
803 "tests.utf8methodname." . 'κόσμε' => array(
804 "function" => "stringEcho",
805 "signature" => $stringecho_sig,
806 "docstring" => $stringecho_doc,
808 /*"tests.iso88591methodname." . chr(224) . chr(252) . chr(232) => array(
809 "function" => "stringEcho",
810 "signature" => $stringecho_sig,
811 "docstring" => $stringecho_doc,
813 "examples.getallheaders" => array(
814 "function" => 'getAllHeaders_xmlrpc',
815 "signature" => $getallheaders_sig,
816 "docstring" => $getallheaders_doc,
818 "examples.setcookies" => array(
819 "function" => 'setCookies',
820 "signature" => $setcookies_sig,
821 "docstring" => $setcookies_doc,
823 "examples.getcookies" => array(
824 "function" => 'getCookies',
825 "signature" => $getcookies_sig,
826 "docstring" => $getcookies_doc,
828 "mail.send" => array(
829 "function" => "mailSend",
830 "signature" => $mailsend_sig,
831 "docstring" => $mailsend_doc,
833 "validator1.arrayOfStructsTest" => array(
834 "function" => "v1_arrayOfStructs",
835 "signature" => $v1_arrayOfStructs_sig,
836 "docstring" => $v1_arrayOfStructs_doc,
838 "validator1.easyStructTest" => array(
839 "function" => "v1_easyStruct",
840 "signature" => $v1_easyStruct_sig,
841 "docstring" => $v1_easyStruct_doc,
843 "validator1.echoStructTest" => array(
844 "function" => "v1_echoStruct",
845 "signature" => $v1_echoStruct_sig,
846 "docstring" => $v1_echoStruct_doc,
848 "validator1.manyTypesTest" => array(
849 "function" => "v1_manyTypes",
850 "signature" => $v1_manyTypes_sig,
851 "docstring" => $v1_manyTypes_doc,
853 "validator1.moderateSizeArrayCheck" => array(
854 "function" => "v1_moderateSizeArrayCheck",
855 "signature" => $v1_moderateSizeArrayCheck_sig,
856 "docstring" => $v1_moderateSizeArrayCheck_doc,
858 "validator1.simpleStructReturnTest" => array(
859 "function" => "v1_simpleStructReturn",
860 "signature" => $v1_simpleStructReturn_sig,
861 "docstring" => $v1_simpleStructReturn_doc,
863 "validator1.nestedStructTest" => array(
864 "function" => "v1_nestedStruct",
865 "signature" => $v1_nestedStruct_sig,
866 "docstring" => $v1_nestedStruct_doc,
868 "validator1.countTheEntities" => array(
869 "function" => "v1_countTheEntities",
870 "signature" => $v1_countTheEntities_sig,
871 "docstring" => $v1_countTheEntities_doc,
873 "interopEchoTests.echoString" => array(
874 "function" => "i_echoString",
875 "signature" => $i_echoString_sig,
876 "docstring" => $i_echoString_doc,
878 "interopEchoTests.echoStringArray" => array(
879 "function" => "i_echoStringArray",
880 "signature" => $i_echoStringArray_sig,
881 "docstring" => $i_echoStringArray_doc,
883 "interopEchoTests.echoInteger" => array(
884 "function" => "i_echoInteger",
885 "signature" => $i_echoInteger_sig,
886 "docstring" => $i_echoInteger_doc,
888 "interopEchoTests.echoIntegerArray" => array(
889 "function" => "i_echoIntegerArray",
890 "signature" => $i_echoIntegerArray_sig,
891 "docstring" => $i_echoIntegerArray_doc,
893 "interopEchoTests.echoFloat" => array(
894 "function" => "i_echoFloat",
895 "signature" => $i_echoFloat_sig,
896 "docstring" => $i_echoFloat_doc,
898 "interopEchoTests.echoFloatArray" => array(
899 "function" => "i_echoFloatArray",
900 "signature" => $i_echoFloatArray_sig,
901 "docstring" => $i_echoFloatArray_doc,
903 "interopEchoTests.echoStruct" => array(
904 "function" => "i_echoStruct",
905 "signature" => $i_echoStruct_sig,
906 "docstring" => $i_echoStruct_doc,
908 "interopEchoTests.echoStructArray" => array(
909 "function" => "i_echoStructArray",
910 "signature" => $i_echoStructArray_sig,
911 "docstring" => $i_echoStructArray_doc,
913 "interopEchoTests.echoValue" => array(
914 "function" => "i_echoValue",
915 "signature" => $i_echoValue_sig,
916 "docstring" => $i_echoValue_doc,
918 "interopEchoTests.echoBase64" => array(
919 "function" => "i_echoBase64",
920 "signature" => $i_echoBase64_sig,
921 "docstring" => $i_echoBase64_doc,
923 "interopEchoTests.echoDate" => array(
924 "function" => "i_echoDate",
925 "signature" => $i_echoDate_sig,
926 "docstring" => $i_echoDate_doc,
928 "interopEchoTests.whichToolkit" => array(
929 "function" => "i_whichToolkit",
930 "signature" => $i_whichToolkit_sig,
931 "docstring" => $i_whichToolkit_doc,
934 'tests.getStateName.2' => $findstate2_sig,
935 'tests.getStateName.3' => $findstate3_sig,
936 'tests.getStateName.4' => $findstate4_sig,
937 'tests.getStateName.5' => $findstate5_sig,
938 'tests.getStateName.6' => $findstate6_sig,
939 'tests.getStateName.7' => $findstate7_sig,
940 'tests.getStateName.8' => $findstate8_sig,
941 'tests.getStateName.9' => $findstate9_sig,
942 'tests.getStateName.10' => $findstate10_sig,
943 'tests.getStateName.11' => $findstate11_sig,
945 'tests.getStateName.12' => array(
946 "function" => "findStateWithNulls",
947 "signature" => $findstate12_sig,
948 "docstring" => $findstate_doc,
951 'tests.returnPhpObject' => $returnObj_sig,
954 $signatures = array_merge($signatures, $moreSignatures);
956 // enable support for the NULL extension
957 PhpXmlRpc\PhpXmlRpc::$xmlrpc_null_extension = true;
959 $s = new PhpXmlRpc\Server($signatures, false);
961 $s->compress_response = true;
963 // out-of-band information: let the client manipulate the server operations.
964 // we do this to help the testsuite script: do not reproduce in production!
965 if (isset($_GET['RESPONSE_ENCODING'])) {
966 $s->response_charset_encoding = $_GET['RESPONSE_ENCODING'];
968 if (isset($_GET['DETECT_ENCODINGS'])) {
969 PhpXmlRpc\PhpXmlRpc::$xmlrpc_detectencodings = $_GET['DETECT_ENCODINGS'];
971 if (isset($_GET['EXCEPTION_HANDLING'])) {
972 $s->exception_handling = $_GET['EXCEPTION_HANDLING'];
975 // that should do all we need!
977 // out-of-band information: let the client manipulate the server operations.
978 // we do this to help the testsuite script: do not reproduce in production!
979 if (isset($_COOKIE['PHPUNIT_SELENIUM_TEST_ID']) && extension_loaded('xdebug')) {
980 include_once __DIR__ . "/../../vendor/phpunit/phpunit-selenium/PHPUnit/Extensions/SeleniumCommon/append.php";