summaryrefslogtreecommitdiff
path: root/demos/soap/protected/pages/Home.php
diff options
context:
space:
mode:
authorxue <>2007-01-02 01:06:20 +0000
committerxue <>2007-01-02 01:06:20 +0000
commitf7c5eb1d28973e7380cc532c6347723b84ab19a5 (patch)
treec6aa733eb0c3196dbbbb7bf9fd5990e5a732106e /demos/soap/protected/pages/Home.php
parente944138b52b1eaffa669a322de5802840cde9387 (diff)
Fixed SOAP demo.
Diffstat (limited to 'demos/soap/protected/pages/Home.php')
-rw-r--r--demos/soap/protected/pages/Home.php63
1 files changed, 25 insertions, 38 deletions
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__));
+ }
}