summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--demos/soap/protected/application.xml14
-rw-r--r--demos/soap/protected/pages/Home.page50
-rw-r--r--demos/soap/protected/pages/Home.php63
-rw-r--r--demos/soap/protected/webservices/SimpleService.php11
4 files changed, 79 insertions, 59 deletions
diff --git a/demos/soap/protected/application.xml b/demos/soap/protected/application.xml
index e59c5b84..a107e7a4 100644
--- a/demos/soap/protected/application.xml
+++ b/demos/soap/protected/application.xml
@@ -1,10 +1,8 @@
<?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 id="soap">
+ <services>
+ <service id="soap" class="System.Web.Services.TSoapService">
+ <soap id="calculator" provider="Application.webservices.SimpleService" />
+ </service>
+ </services>
</application> \ No newline at end of file
diff --git a/demos/soap/protected/pages/Home.page b/demos/soap/protected/pages/Home.page
index 732022e9..f0811b30 100644
--- a/demos/soap/protected/pages/Home.page
+++ b/demos/soap/protected/pages/Home.page
@@ -1,19 +1,53 @@
-<html>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
+
<head>
- <title>TSoapService Demo</title>
+<meta http-equiv="Expires" content="Fri, Jan 01 1900 00:00:00 GMT"/>
+<meta http-equiv="Pragma" content="no-cache"/>
+<meta http-equiv="Cache-Control" content="no-cache"/>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+<meta http-equiv="content-language" content="en"/>
+<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>
+<p>
+This demo shows basic usage of TSoapService which provides integrated
+SOAP service for PRADO applications.
+</p>
+<p>
+The demo includes both a SOAP server and a client (this page).
+The SOAP server supports two operations which are provided by <tt>SimpleService</tt> class:
+</p>
+<ul>
+<li><tt>highlight()</tt>: takes a string and returns the highlighted version.</li>
+<li><tt>add()</tt>: takes two numbers and returns the addition of them.</li>
+</ul>
+<p>
+For more details about the server, see its
+<a href="<%=$this->Request->AbsoluteApplicationUrl.'?soap=calculator.wsdl'%>">WSDL specification</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>SOAP Calculator</h2>
+<com:TTextBox ID="Number1" Columns="3"/> +
+<com:TTextBox ID="Number2" Columns="3"/> =
+<com:TTextBox ID="AdditionResult" ReadOnly="true" Columns="3" />
+<com:TButton Text="Compute" OnClick="computeButtonClicked"/>
-<h2>Highlight source code</h2>
-<com:TButton Text="Highlight this" OnClick="onHighlight"/> <br/>
+<h2>Source Code Highlighter</h2>
+<p>
+Click on the button below to show the highlighted source code of
+this page class:
+</p>
+<com:TButton Text="Highlight" OnClick="highlightButtonClicked"/>
<br/>
-<com:TLabel ID="SourceCode"/>
+<div style="background:lightyellow">
+<com:TLiteral ID="HighlightResult" />
+</div>
</com:TForm>
</body>
diff --git a/demos/soap/protected/pages/Home.php b/demos/soap/protected/pages/Home.php
index 98fbe6c6..a52ea384 100644
--- a/demos/soap/protected/pages/Home.php
+++ b/demos/soap/protected/pages/Home.php
@@ -1,43 +1,30 @@
<?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;
- }
+class Home extends TPage
+{
+ private $_client=null;
+
+ protected function getSoapClient()
+ {
+ if($this->_client===null)
+ {
+ $wsdlUri=$this->Request->AbsoluteApplicationUrl.'?soap=calculator.wsdl';
+ $this->_client=new SoapClient($wsdlUri);
+ }
+ return $this->_client;
+ }
+
+ public function computeButtonClicked($sender,$param)
+ {
+ $number1=TPropertyValue::ensureInteger($this->Number1->Text);
+ $number2=TPropertyValue::ensureInteger($this->Number2->Text);
+ $this->AdditionResult->Text=$this->getSoapClient()->add($number1+$number2);
+ }
+
+ public function highlightButtonClicked($sender, $param)
+ {
+ $this->HighlightResult->Text=$this->getSoapClient()->highlight(file_get_contents(__FILE__));
+ }
}
diff --git a/demos/soap/protected/webservices/SimpleService.php b/demos/soap/protected/webservices/SimpleService.php
index 9aecbfad..ca082152 100644
--- a/demos/soap/protected/webservices/SimpleService.php
+++ b/demos/soap/protected/webservices/SimpleService.php
@@ -1,8 +1,7 @@
<?php
+
class SimpleService
{
- private $errors = array();
-
/**
* Highlights a string as php code
* @param string $input The php code to highlight
@@ -13,7 +12,7 @@ class SimpleService
{
return highlight_string($input, true);
}
-
+
/**
* Simply add two operands
* @param int $a
@@ -21,8 +20,10 @@ class SimpleService
* @return int The result
* @soapmethod
*/
- public function add($a, $b) {
- return $a + $b;
+ public function add($a, $b)
+ {
+ return $a + $b;
}
}
+
?> \ No newline at end of file