Mage_Api_Model_Server_Adapter_Soap Class Reference

Inheritance diagram for Mage_Api_Model_Server_Adapter_Soap:

Varien_Object Mage_Api_Model_Server_Adapter_Interface Mage_Api_Model_Server_V2_Adapter_Soap

List of all members.

Public Member Functions

 setHandler ($handler)
 getHandler ()
 setController (Mage_Api_Controller_Action $controller)
 getController ()
 run ()
 fault ($code, $message)

Protected Member Functions

 _extensionLoaded ()

Protected Attributes

 $_soap = null


Detailed Description

Definition at line 34 of file Soap.php.


Member Function Documentation

_extensionLoaded (  )  [protected]

Check whether Soap extension is loaded

Returns:
boolean

Definition at line 167 of file Soap.php.

00168     {
00169         return class_exists('SoapServer', false);
00170     }

fault ( code,
message 
)

Dispatch webservice fault

Parameters:
int $code
string $message

Implements Mage_Api_Model_Server_Adapter_Interface.

Definition at line 145 of file Soap.php.

00146     {
00147         if ($this->_extensionLoaded()) {
00148             throw new SoapFault($code, $message);
00149         } else {
00150             die('<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
00151                 <SOAP-ENV:Body>
00152                 <SOAP-ENV:Fault>
00153                 <faultcode>' . $code . '</faultcode>
00154                 <faultstring>' . $message . '</faultstring>
00155                 </SOAP-ENV:Fault>
00156                 </SOAP-ENV:Body>
00157                 </SOAP-ENV:Envelope>');
00158         }
00159 
00160     }

getController (  ) 

Retrive webservice api controller

Returns:
Mage_Api_Controller_Action

Implements Mage_Api_Model_Server_Adapter_Interface.

Definition at line 84 of file Soap.php.

00085     {
00086         return $this->getData('controller');
00087     }

getHandler (  ) 

Retrive handler class name for webservice

Returns:
string

Implements Mage_Api_Model_Server_Adapter_Interface.

Definition at line 62 of file Soap.php.

00063     {
00064         return $this->getData('handler');
00065     }

run (  ) 

Run webservice

Parameters:
Mage_Api_Controller_Action $controller
Returns:
Mage_Api_Model_Server_Adapter_Soap

Implements Mage_Api_Model_Server_Adapter_Interface.

Reimplemented in Mage_Api_Model_Server_V2_Adapter_Soap.

Definition at line 95 of file Soap.php.

00096     {
00097         $urlModel = Mage::getModel('core/url')
00098             ->setUseSession(false);
00099         if ($this->getController()->getRequest()->getParam('wsdl') !== null) {
00100             // Generating wsdl content from template
00101             $io   = new Varien_Io_File();
00102             $io->open(array('path'=>Mage::getModuleDir('etc', 'Mage_Api')));
00103 
00104             $wsdlContent = $io->read('wsdl.xml');
00105 
00106             $template = Mage::getModel('core/email_template_filter');
00107 
00108             $wsdlConfig = new Varien_Object();
00109             $queryParams = $this->getController()->getRequest()->getQuery();
00110             if (isset($queryParams['wsdl'])) {
00111                 unset($queryParams['wsdl']);
00112             }
00113 
00114             $wsdlConfig->setUrl(
00115                 htmlspecialchars($urlModel->getUrl('*/*/*', array('_query'=>$queryParams)))
00116             );
00117             $wsdlConfig->setName('Magento');
00118             $wsdlConfig->setHandler($this->getHandler());
00119 
00120             $template->setVariables(array('wsdl'=>$wsdlConfig));
00121 
00122             $this->getController()->getResponse()
00123                 ->setHeader('Content-Type','text/xml')
00124                 ->setBody($template->filter($wsdlContent));
00125         } elseif ($this->_extensionLoaded()) {
00126             $this->_soap = new SoapServer($urlModel->getUrl('*/*/*', array('wsdl'=>1)));
00127             use_soap_error_handler(false);
00128             $this->_soap->setClass($this->getHandler());
00129             $this->getController()->getResponse()
00130                 ->setHeader('Content-Type', 'text/xml')
00131                 ->setBody($this->_soap->handle());
00132 
00133         } else {
00134             $this->fault('0', 'Unable to load Soap extension on the server');
00135         }
00136         return $this;
00137     }

setController ( Mage_Api_Controller_Action controller  ) 

Set webservice api controller

Parameters:
Mage_Api_Controller_Action $controller
Returns:
Mage_Api_Model_Server_Adapter_Soap

Implements Mage_Api_Model_Server_Adapter_Interface.

Definition at line 73 of file Soap.php.

00074     {
00075          $this->setData('controller', $controller);
00076          return $this;
00077     }

setHandler ( handler  ) 

Set handler class name for webservice

Parameters:
string $handler
Returns:
Mage_Api_Model_Server_Adapter_Soap

Implements Mage_Api_Model_Server_Adapter_Interface.

Definition at line 51 of file Soap.php.

00052     {
00053         $this->setData('handler', $handler);
00054         return $this;
00055     }


Member Data Documentation

$_soap = null [protected]

Definition at line 43 of file Soap.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:23:33 2009 for Magento by  doxygen 1.5.8