summaryrefslogtreecommitdiff
path: root/demos
diff options
context:
space:
mode:
Diffstat (limited to 'demos')
-rw-r--r--demos/soap/index.php5
-rw-r--r--demos/soap/protected/application.xml10
-rw-r--r--demos/soap/protected/pages/Home.page20
-rw-r--r--demos/soap/protected/pages/Home.php44
-rw-r--r--demos/soap/protected/runtime/global.cache1
-rw-r--r--demos/soap/protected/webservices/SimpleService.php89
6 files changed, 169 insertions, 0 deletions
diff --git a/demos/soap/index.php b/demos/soap/index.php
new file mode 100644
index 00000000..009011f8
--- /dev/null
+++ b/demos/soap/index.php
@@ -0,0 +1,5 @@
+<?php
+require_once '../../framework/prado.php';
+$application = new TApplication();
+$application->run();
+?> \ No newline at end of file
diff --git a/demos/soap/protected/application.xml b/demos/soap/protected/application.xml
new file mode 100644
index 00000000..e59c5b84
--- /dev/null
+++ b/demos/soap/protected/application.xml
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8"?>
+<application id="soap" mode="Debug">
+ <paths>
+ <using namespace="Application.webservices.*" />
+ </paths>
+ <services>
+ <service id="page" class="TPageService"/>
+ <service id="soap" class="System.Web.Services.TSoapService"/>
+ </services>
+</application> \ No newline at end of file
diff --git a/demos/soap/protected/pages/Home.page b/demos/soap/protected/pages/Home.page
new file mode 100644
index 00000000..732022e9
--- /dev/null
+++ b/demos/soap/protected/pages/Home.page
@@ -0,0 +1,20 @@
+<html>
+<head>
+ <title>TSoapService Demo</title>
+</head>
+<body>
+<h1>TSoapService Demo</h1>
+<p>Welcome to the TSoapService demo. See <a href="index.php?soap=SimpleService&wsdl">service description</a>.</p>
+
+<com:TForm>
+<h2>Soap Calculator</h2>
+<com:TTextBox ID="a" Columns="3"/> + <com:TTextBox ID="b" Columns="3"/> = <com:TTextBox ID="result" Columns="3"/> <com:TButton Text="Compute" OnClick="onCompute"/>
+
+<h2>Highlight source code</h2>
+<com:TButton Text="Highlight this" OnClick="onHighlight"/> <br/>
+<br/>
+<com:TLabel ID="SourceCode"/>
+
+</com:TForm>
+</body>
+</html> \ No newline at end of file
diff --git a/demos/soap/protected/pages/Home.php b/demos/soap/protected/pages/Home.php
new file mode 100644
index 00000000..98fbe6c6
--- /dev/null
+++ b/demos/soap/protected/pages/Home.php
@@ -0,0 +1,44 @@
+<?php
+
+class Home extends TPage {
+
+ private $_client;
+
+ public function onInit($param) {
+ // TODO: configure wsdl
+ $wsdl = 'http://localhost/prado/svn/trunk/demos/soap/index.php?soap=SimpleService&wsdl';
+ $location = 'http://localhost/prado/svn/trunk/demos/soap/index.php?soap=SimpleService';
+ // TODO: use TSoapClient
+ //$this->_client = new SoapClient($wsdl, array('soap_version' => SOAP_1_1,
+ //'use' => '',
+ // 'style' => ''));
+
+ // TODO: use classmap
+ $this->_client = new SoapClient(null, array('location' => $location, 'uri' => 'urn:SimpleService', 'soap_version' => SOAP_1_2));
+ }
+
+ public function onCompute($sender, $param) {
+ $a = $this->a->Text;
+ $b = $this->b->Text;
+
+ try {
+ $result = $this->_client->add($a, $b);
+ } catch(SoapFault $e) { // TODO: Prado wrapper for SoapFault (TSoapFaultException)
+ print $e;
+ }
+ //var_dump($result);
+ $this->result->Text = $result;
+ }
+
+ public function onHighlight($sender, $param) {
+ try {
+ $result = $this->_client->__soapCall('highlight', array(file_get_contents(__FILE__)));
+ } catch(SoapFault $e) { // TODO: Prado wrapper for SoapFault (TSoapFaultException)
+ print $e;
+ }
+ $this->SourceCode->Text = $result;
+ }
+
+}
+
+?> \ No newline at end of file
diff --git a/demos/soap/protected/runtime/global.cache b/demos/soap/protected/runtime/global.cache
new file mode 100644
index 00000000..0520dc3a
--- /dev/null
+++ b/demos/soap/protected/runtime/global.cache
@@ -0,0 +1 @@
+a:1:{s:35:"prado:securitymanager:validationkey";s:38:"16373386985182982755332313631333778405";} \ No newline at end of file
diff --git a/demos/soap/protected/webservices/SimpleService.php b/demos/soap/protected/webservices/SimpleService.php
new file mode 100644
index 00000000..e59546bb
--- /dev/null
+++ b/demos/soap/protected/webservices/SimpleService.php
@@ -0,0 +1,89 @@
+<?php
+class SimpleService
+{
+ private $errors = array();
+
+ /**
+ * Highlights a string as php code
+ * @param string $input The php code to highlight
+ * @return string The highlighted text.
+ * @soapmethod
+ */
+ public function highlight($input)
+ {
+ return highlight_string($input, true);
+ }
+
+ /**
+ * Given a left side, operation, and right side of an operation, will
+ * return the result of computing the equation.
+ * @param string $leftSide The left side of an equation
+ * @param string $operation The operation to perform
+ * @param string $rightSide The right side of the equation
+ * @return ComputationResult The result of the computation
+ * @soapmethod
+ */
+ public function compute($leftSide, $operation, $rightSide)
+ {
+ $result = new ComputationResult();
+ $result->equation = "$leftSide $operation $rightSide";
+ $result->result = $this->evaluateExpression($leftSide, $operation, $rightSide);
+ if (count($this->errors)) {
+ $result->success = false;
+ $result->errors = $this->errors;
+ }
+ else {
+ $result->success = true;
+ }
+
+ return $result;
+ }
+
+ /**
+ * Simply add two operands
+ * @param int $a
+ * @param int $b
+ * @return int The result
+ * @soapmethod
+ */
+ public function add($a, $b) {
+ return $a + $b;
+ }
+
+ /**
+ * This method evaluates the expression. It should be capable of handling any $op
+ * passed to it.
+ * @return string the result of the evaluation
+ */
+ private function evaluateExpression($left, $op, $right)
+ {
+ // Now, because we don't want to eval random code on the server that this is running
+ // on, we're just going to highlight the string
+ $evaluation = highlight_string("$left $op $right;", true);
+ return $evaluation;
+ }
+}
+
+class ComputationResult
+{
+ /**
+ * @var string The initial equation
+ */
+ public $equation;
+
+ /**
+ * @var string The computed result
+ */
+ public $result;
+
+ /**
+ * @var boolean Whether the computation succeeded
+ */
+ public $success;
+
+ /**
+ * @var array any errors that occured in the processing.
+ */
+ public $errors;
+}
+?> \ No newline at end of file