diff options
Diffstat (limited to 'demos/soap/protected/pages')
-rw-r--r-- | demos/soap/protected/pages/Home.page | 50 | ||||
-rw-r--r-- | demos/soap/protected/pages/Home.php | 63 |
2 files changed, 67 insertions, 46 deletions
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__)); + } } |