From 6869ac7ae703a8c8c4dcc4bdad4e130489a6ed35 Mon Sep 17 00:00:00 2001 From: gggeek Date: Sat, 7 Jan 2023 21:26:44 +0000 Subject: [PATCH] improve demo files pI: remove useless files; vardemo.php --- demo/demo1.xml | 60 ----------------------------------- demo/demo2.xml | 10 ------ demo/demo3.xml | 21 ------------- demo/vardemo.php | 81 ++++++++++++++++++++++++++---------------------- 4 files changed, 44 insertions(+), 128 deletions(-) delete mode 100644 demo/demo1.xml delete mode 100644 demo/demo2.xml delete mode 100644 demo/demo3.xml diff --git a/demo/demo1.xml b/demo/demo1.xml deleted file mode 100644 index eeb6a69b..00000000 --- a/demo/demo1.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - thearray - - - - - ABCDEFHIJ - - - 1234 - - - 1 - - - - - - - theint - - 23 - - - - thestring - - foobarwhizz - - - - thestruct - - - - one - - 1 - - - - two - - 2 - - - - - - - - - - diff --git a/demo/demo2.xml b/demo/demo2.xml deleted file mode 100644 index 3289caf5..00000000 --- a/demo/demo2.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - South Dakota's own - - - - diff --git a/demo/demo3.xml b/demo/demo3.xml deleted file mode 100644 index ed94aaba..00000000 --- a/demo/demo3.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - faultCode - - 4 - - - - faultString - - Too many parameters. - - - - - - diff --git a/demo/vardemo.php b/demo/vardemo.php index ac7e6786..be748f7f 100644 --- a/demo/vardemo.php +++ b/demo/vardemo.php @@ -1,47 +1,55 @@ +output(' xmlrpc '); -$req = new PhpXmlRpc\Request('examples.getStateName'); - output("

Testing value serialization

\n"); +output("

Please note that in most cases you are better off using `new PhpXmlRpc\Encoder()->encode()` to create nested Value objects

\n"); + +$v = new PhpXmlRpc\Value(1234, 'int'); +output("Int:
" . htmlentities($v->serialize()) . "
"); + +$v = new PhpXmlRpc\Value('Are the following characters escaped? < & >'); +output("String
" . htmlentities($v->serialize()) . "
"); -$v = new PhpXmlRpc\Value(23, "int"); -output("
" . htmlentities($v->serialize()) . "
"); -$v = new PhpXmlRpc\Value("What are you saying? >> << &&"); -output("
" . htmlentities($v->serialize()) . "
"); +$v = new PhpXmlRpc\Value(true, 'boolean'); +output("Boolean:
" . htmlentities($v->serialize()) . "
"); + +$v = new PhpXmlRpc\Value(1234.5678, 'double'); +output("Double:
" . htmlentities($v->serialize()) . "
"); + +$v = new PhpXmlRpc\Value(time(), 'dateTime.iso8601'); +output("Datetime:
" . htmlentities($v->serialize()) . "
"); + +$v = new PhpXmlRpc\Value('hello world', 'base64'); +output("Base64:
" . htmlentities($v->serialize()) . "
"); +output("(value of base64 string is: '" . $v->scalarval() . "')

"); $v = new PhpXmlRpc\Value( array( - new PhpXmlRpc\Value("ABCDEFHIJ"), - new PhpXmlRpc\Value(1234, 'int'), + new PhpXmlRpc\Value('1234', 'i4'), + new PhpXmlRpc\Value("Can you spot the greek letter beta? β", 'string'), new PhpXmlRpc\Value(1, 'boolean'), + new PhpXmlRpc\Value(1234, 'double'), + new PhpXmlRpc\Value(new DateTime(), 'dateTime.iso8601'), + new PhpXmlRpc\Value('', 'base64'), ), "array" ); - -output("
" . htmlentities($v->serialize()) . "
"); +output("Array:
" . htmlentities($v->serialize()) . "
"); $v = new PhpXmlRpc\Value( array( - "thearray" => new PhpXmlRpc\Value( - array( - new PhpXmlRpc\Value("ABCDEFHIJ"), - new PhpXmlRpc\Value(1234, 'int'), - new PhpXmlRpc\Value(1, 'boolean'), - new PhpXmlRpc\Value(0, 'boolean'), - new PhpXmlRpc\Value(true, 'boolean'), - new PhpXmlRpc\Value(false, 'boolean'), - ), + "anInt" => new PhpXmlRpc\Value(23, 'int'), + "aString" => new PhpXmlRpc\Value('foobarwhizz'), + "anEmptyArray" => new PhpXmlRpc\Value( + array(), "array" ), - "theint" => new PhpXmlRpc\Value(23, 'int'), - "thestring" => new PhpXmlRpc\Value("foobarwhizz"), - "thestruct" => new PhpXmlRpc\Value( + "aNestedStruct" => new PhpXmlRpc\Value( array( "one" => new PhpXmlRpc\Value(1, 'int'), "two" => new PhpXmlRpc\Value(2, 'int'), @@ -51,14 +59,12 @@ $v = new PhpXmlRpc\Value( ), "struct" ); +output("Struct:
" . htmlentities($v->serialize()) . "
"); -output("
" . htmlentities($v->serialize()) . "
"); - -$w = new PhpXmlRpc\Value(array($v, new PhpXmlRpc\Value("That was the struct!")), "array"); - -output("
" . htmlentities($w->serialize()) . "
"); +$w = new PhpXmlRpc\Value(array($v), 'array'); +output("Array containing a struct:
" . htmlentities($w->serialize()) . "
"); -$w = new PhpXmlRpc\Value("Mary had a little lamb, +/*$w = new PhpXmlRpc\Value("Mary had a little lamb, Whose fleece was white as snow, And everywhere that Mary went the lamb was sure to go. @@ -69,17 +75,19 @@ Ten thousand volts went down its back And turned it into nylon", "base64" ); output("
" . htmlentities($w->serialize()) . "
"); -output("
Value of base64 string is: '" . $w->scalarval() . "'
"); - -$req->method(''); -$req->addParam(new PhpXmlRpc\Value("41", "int")); +output("
Value of base64 string is: '" . $w->scalarval() . "'
");*/ output("

Testing request serialization

\n"); -$op = $req->serialize(); -output("
" . htmlentities($op) . "
"); +$req = new PhpXmlRpc\Request('examples.getStateName'); +$req->method('examples.getStateName'); +$req->addParam(new PhpXmlRpc\Value(42, 'int')); +output("
" . htmlentities($req->serialize()) . "
"); -output("

Testing ISO date format

\n");
+output("

Testing response serialization

\n"); +$resp = new PhpXmlRpc\Response(new PhpXmlRpc\Value('The meaning of life')); +output("
" . htmlentities($resp->serialize()) . "
"); +output("

Testing ISO date formatting

\n");
 $t = time();
 $date = PhpXmlRpc\Helper\Date::iso8601Encode($t);
 output("Now is $t --> $date\n");
@@ -88,7 +96,6 @@ $tb = PhpXmlRpc\Helper\Date::iso8601Decode($date);
 output("That is to say $date --> $tb\n");
 output("Which comes out at " . PhpXmlRpc\Helper\Date::iso8601Encode($tb) . "\n");
 output("Which was the time in UTC at " . PhpXmlRpc\Helper\Date::iso8601Encode($tb, 1) . "\n");
-
 output("
\n"); output(''); -- 2.47.0