Skip to content

Commit 5b4cde9

Browse files
committed
demo code improvements
1 parent 9d9f5aa commit 5b4cde9

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

demo/client/which.php

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<body>
77
<h1>Which toolkit demo</h1>
88
<h2>Query server for toolkit information</h2>
9-
<h3>The code demonstrates support for http redirects, the `interopEchoTests.whichToolkit` xml-rpc methods, request compression and use of pre-built xml</h3>
9+
<h3>The code demonstrates support for http redirects, the `interopEchoTests.whichToolkit` xml-rpc method, request compression and use of pre-built xml</h3>
1010
<p>You can see the source to this page here: <a href="which.php?showSource=1">which.php</a></p>
1111
');
1212

@@ -45,20 +45,24 @@
4545
$encoder = new Encoder();
4646
// from xml to xml-rpc Response
4747
$response = $encoder->decodeXml($xml);
48-
// from Response to Value
49-
$value = $response->value();
50-
// from Value to php
51-
$value = $encoder->decode($value);
48+
if ($response !== false) {
49+
// from Response to Value
50+
$value = $response->value();
51+
// from Value to php
52+
$value = $encoder->decode($value);
5253

53-
output("Toolkit info:<br/>\n");
54-
output("<pre>");
55-
output("name: " . htmlspecialchars($value["toolkitName"]) . "\n");
56-
output("version: " . htmlspecialchars($value["toolkitVersion"]) . "\n");
57-
output("docs: " . htmlspecialchars($value["toolkitDocsUrl"]) . "\n");
58-
output("os: " . htmlspecialchars($value["toolkitOperatingSystem"]) . "\n");
59-
output("</pre>");
54+
output("Toolkit info:<br/>\n");
55+
output("<pre>");
56+
output("name: " . htmlspecialchars($value["toolkitName"]) . "\n");
57+
output("version: " . htmlspecialchars($value["toolkitVersion"]) . "\n");
58+
output("docs: " . htmlspecialchars($value["toolkitDocsUrl"]) . "\n");
59+
output("os: " . htmlspecialchars($value["toolkitOperatingSystem"]) . "\n");
60+
output("</pre>");
61+
} else {
62+
output("An xml-rpc error occurred");
63+
}
6064
} else {
61-
output("An error occurred: ");
65+
output("An http error occurred: ");
6266
output("Code: " . htmlspecialchars($resp->faultCode()) . " Reason: '" . htmlspecialchars($resp->faultString()) . "'\n");
6367
}
6468

0 commit comments

Comments
 (0)