oxonlinelicensecheckcaller.php

Go to the documentation of this file.
00001 <?php
00002 
00011 class oxOnlineLicenseCheckCaller extends oxOnlineCaller
00012 {
00013 
00015     const WEB_SERVICE_URL = 'https://olc.oxid-esales.com/check.php';
00016 
00018     const XML_DOCUMENT_NAME = 'olcRequest';
00019 
00025     private $_sResponseElement = 'olc';
00026 
00035     public function doRequest(oxOnlineLicenseCheckRequest $oRequest)
00036     {
00037         $sResponse = $this->call($oRequest);
00038 
00039         return $this->_formResponse($sResponse);
00040     }
00041 
00049     protected function _formEmail($oRequest)
00050     {
00051         $oRequest->keys = null;
00052 
00053         return parent::_formEmail($oRequest);
00054     }
00055 
00065     protected function _formResponse($sRawResponse)
00066     {
00068         $oUtilsXml = oxRegistry::get("oxUtilsXml");
00069         if (empty($sRawResponse) || !($oDomDoc = $oUtilsXml->loadXml($sRawResponse))) {
00070             throw new oxException('OLC_ERROR_RESPONSE_NOT_VALID');
00071         }
00072 
00073         if ($oDomDoc->documentElement->nodeName != $this->_sResponseElement) {
00074             throw new oxException('OLC_ERROR_RESPONSE_UNEXPECTED');
00075         }
00076 
00077         $oResponseNode = $oDomDoc->firstChild;
00078 
00079         if (!$oResponseNode->hasChildNodes()) {
00080             throw new oxException('OLC_ERROR_RESPONSE_NOT_VALID');
00081         }
00082 
00083         $oNodes = $oResponseNode->childNodes;
00084 
00086         $oResponse = oxNew('oxOnlineLicenseCheckResponse');
00087 
00088         // iterate through response node to get response parameters
00089         for ($i = 0; $i < $oNodes->length; $i++) {
00090             $sNodeName = $oNodes->item($i)->nodeName;
00091             $sNodeValue = $oNodes->item($i)->nodeValue;
00092             $oResponse->$sNodeName = $sNodeValue;
00093         }
00094 
00095         return $oResponse;
00096     }
00097 
00103     protected function _getXMLDocumentName()
00104     {
00105         return self::XML_DOCUMENT_NAME;
00106     }
00107 
00113     protected function _getServiceUrl()
00114     {
00115         return self::WEB_SERVICE_URL;
00116     }
00117 }