Example #1
0
 /**
  * Try to instantiate Zend_Soap_Server
  * If schema import error is caught, it will retry in 1 second.
  *
  * @throws Zend_Soap_Server_Exception
  */
 protected function _instantiateServer()
 {
     $apiConfigCharset = Mage::getStoreConfig('api/config/charset');
     $wsdlCacheEnabled = (bool) Mage::getStoreConfig('api/config/wsdl_cache_enabled');
     if ($wsdlCacheEnabled) {
         ini_set('soap.wsdl_cache_enabled', '1');
     } else {
         ini_set('soap.wsdl_cache_enabled', '0');
     }
     $tries = 0;
     do {
         $retry = false;
         try {
             $this->_soap = new Zend_Soap_Server($this->getWsdlUrl(array("wsdl" => 1)), array('encoding' => $apiConfigCharset));
         } catch (SoapFault $e) {
             if (false !== strpos($e->getMessage(), "can't import schema from 'http://schemas.xmlsoap.org/soap/encoding/'")) {
                 $retry = true;
                 sleep(1);
             } else {
                 throw $e;
             }
             $tries++;
         }
     } while ($retry && $tries < 5);
     use_soap_error_handler(false);
     $this->_soap->setReturnResponse(true)->setClass($this->getHandler());
 }