Example #1
0
 public static function getSoapClient()
 {
     ini_set("soap.wsdl_cache_enabled", "0");
     $conf = Zend_Registry::get("pimcore_config_test");
     $user = User::getById($conf->user);
     if (!$user instanceof User) {
         throw new Exception("invalid user id");
     }
     $client = new Zend_Soap_Client($conf->webservice->wsdl . "&username="******"&apikey=" . $user->getPassword(), array("cache_wsdl" => false, "soap_version" => SOAP_1_2, "classmap" => Webservice_Tool::createClassMappings()));
     $client->setLocation($conf->webservice->serviceEndpoint . "?username="******"&apikey=" . $user->getPassword());
     return $client;
 }
 public function endpointAction()
 {
     // disable wsdl cache
     if (PIMCORE_DEVMODE) {
         ini_set("soap.wsdl_cache_enabled", "0");
     }
     // create classmappings
     $classMap = Webservice_Tool::createClassMappings();
     //        p_r($classMap); die();
     // create wsdl
     // @TODO create a cache here
     $strategy = new Zend_Soap_Wsdl_Strategy_Composite(array("object[]" => "Zend_Soap_Wsdl_Strategy_AnyType"), "Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex");
     $autodiscover = new Zend_Soap_AutoDiscover($strategy);
     $autodiscover->setClass('Webservice_Service');
     $wsdl = $autodiscover->toXml();
     //TODO: do we really want to normalize class names since we had to introduce request and response objects anyway?
     $wsdl = str_replace("Webservice_Data_", "", $wsdl);
     // normalize classnames
     $wsdlFile = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/wsdl.xml";
     file_put_contents($wsdlFile, $wsdl);
     chmod($wsdlFile, 0766);
     // let's go
     if (isset($_GET["wsdl"])) {
         header("Content-Type: text/xml; charset=utf8");
         echo $wsdl;
     } else {
         Pimcore::setAdminMode();
         Document::setHideUnpublished(false);
         Object_Abstract::setHideUnpublished(false);
         Object_Abstract::setGetInheritedValues(false);
         try {
             $server = new Zend_Soap_Server($wsdlFile, array("cache_wsdl" => false, "soap_version" => SOAP_1_2, "classmap" => $classMap));
             $server->registerFaultException("Exception");
             $server->setClass("Webservice_Service");
             $server->handle();
         } catch (Exception $e) {
             Logger::log("Soap request failed");
             Logger::log($e);
             throw $e;
         }
     }
     exit;
 }