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;
 }
示例#2
0
 /**
  * Accept the request of the clients
  * 
  * @param string $classname
  */
 public function soap($classname)
 {
     if (empty($classname)) {
         return false;
     }
     list($app, $module, $class) = explode("_", $classname);
     // initialize server and set URI
     $optionsoap = array('location' => "http://" . $_SERVER['HTTP_HOST'] . "/" . strtolower($class) . ".wsld", 'uri' => 'urn:' . $classname);
     $server = new Zend_Soap_Server(null, $optionsoap);
     // set SOAP service class
     $server->setClass($classname);
     // Bind already initialized object to Soap Server
     $server->setObject(new $classname());
     $server->setReturnResponse(false);
     // register exceptions for generating SOAP faults
     $server->registerFaultException(array('Shineisp_Api_Exceptions'));
     // handle request
     $server->handle();
 }
示例#3
0
 public function testFaultWithRegisteredException()
 {
     $server = new Zend_Soap_Server();
     $server->registerFaultException("Exception");
     $fault = $server->fault(new Exception("MyException"));
     $this->assertTrue($fault instanceof SOAPFault);
     $this->assertNotContains("Unknown error", $fault->getMessage());
     $this->assertContains("MyException", $fault->getMessage());
 }
示例#4
0
require_once '../library/Shift8.php';
/**
 * While trying to develop the Soap extension for Shift8, I needed a way to debug
 * the events occuring to the remote asterisk, thus the Debug Listener and the 
 * Syslog debug listener
 */
require_once '../library/Debug/Listener/Syslog.php';
if (isset($_GET['wsdl'])) {
    $autodiscover = new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex');
    $autodiscover->setOperationBodyStyle(array('use' => 'literal', 'namespace' => 'http://' . $_SERVER['HTTP_HOST']));
    /*	
     * Does not work with PHP Soap Client. Might be required for .NET clients
     *
    $autodiscover->setBindingStyle(
    	array(
    		'style'		=> 'document',
    		'transport' 	=> 'http://schemas.xmlsoap.org/soap/http'
    	)
    );
    */
    $autodiscover->setClass('Shift8');
    $autodiscover->handle();
} else {
    session_start();
    $wsdl = sprintf('http://%s%s?wsdl', $_SERVER['HTTP_HOST'], $_SERVER['SCRIPT_NAME']);
    $soap = new Zend_Soap_Server($wsdl);
    $soap->setClass('Shift8', $config['asterisk'], $config['manager'], $config['secret'], false, new Shift8_Debug_Listener_Syslog());
    $soap->setPersistence(SOAP_PERSISTENCE_SESSION);
    $soap->registerFaultException('Shift8_Exception');
    $response = $soap->handle();
}
 /**
  * Defines the document production services
  *
  * @return void
  */
 public function insuranceDocumentAction()
 {
     $params = Zend_Registry::get('params');
     if (isset($_GET['wsdl'])) {
         $fh = fopen(APPLICATION_PATH . '/models/services/Wsdls/Document/insurance-document.wsdl', 'r');
         $wsdldata = fread($fh, filesize(APPLICATION_PATH . '/models/services/Wsdls/Document/insurance-document.wsdl'));
         fclose($fh);
         echo $wsdldata;
     } else {
         $this->enforceSecurity();
         // Only done when talking to the soap service
         $server = new Zend_Soap_Server(APPLICATION_PATH . '/models/services/Wsdls/Document/insurance-document.wsdl', array('uri' => $params->homelet->domain . '/soap/insurance-document', 'features' => SOAP_SINGLE_ELEMENT_ARRAYS));
         // Use the Soap fault exception to raise soap faults back to client.
         $server->registerFaultException('Application_Soap_Fault');
         // set SOAP service class
         $server->setClass('Service_Insurance_Document');
         // handle request
         $server->handle();
     }
 }
示例#6
0
 /**
  * Run Zend SOAP server
  * @global <type> $CFG
  * @global <type> $USER
  */
 public function run()
 {
     $enable = $this->get_enable();
     if (empty($enable)) {
         die;
     }
     global $CFG;
     include "Zend/Loader.php";
     Zend_Loader::registerAutoload();
     // retrieve the token from the url
     // if the token doesn't exist, set a class containing only get_token()
     $token = optional_param('token', null, PARAM_ALPHANUM);
     ///this is a hack, because there is a bug in Zend framework (http://framework.zend.com/issues/browse/ZF-5736)
     if (empty($token)) {
         $relativepath = get_file_argument();
         $args = explode('/', trim($relativepath, '/'));
         if (count($args) == 2) {
             $token = (int) $args[0];
             $classpath = $args[1];
         }
     }
     if (empty($token)) {
         if (isset($_GET['wsdl'])) {
             $autodiscover = new Zend_Soap_AutoDiscover();
             /*
                             $autodiscover->setComplexTypeStrategy('Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex');
                             $autodiscover->setOperationBodyStyle(
                                 array('use' => 'literal',
                                       'namespace' => $CFG->wwwroot)
                             );
                            
                             $autodiscover->setBindingStyle(
                                 array('style' => 'rpc')
                             );
             */
             $autodiscover->setClass('ws_authentication');
             $autodiscover->handle();
         } else {
             $soap = new Zend_Soap_Server($CFG->wwwroot . "/webservice/soap/server.php?wsdl");
             // this current file here
             $soap->registerFaultException('moodle_exception');
             $soap->setClass('ws_authentication');
             $soap->handle();
         }
     } else {
         // if token exist, do the authentication here
         /// TODO: following function will need to be modified
         $user = webservice_lib::mock_check_token($token);
         if (empty($user)) {
             throw new moodle_exception('wrongidentification');
         } else {
             /// TODO: probably change this
             global $USER;
             $USER = $user;
         }
         //retrieve the api name
         if (empty($classpath)) {
             $classpath = optional_param('classpath', null, PARAM_ALPHANUM);
         }
         require_once dirname(__FILE__) . '/../../' . $classpath . '/external.php';
         /// run the server
         if (isset($_GET['wsdl'])) {
             $autodiscover = new Zend_Soap_AutoDiscover();
             //this is a hack, because there is a bug in Zend framework (http://framework.zend.com/issues/browse/ZF-5736)
             $autodiscover->setUri($CFG->wwwroot . "/webservice/soap/server.php/" . $token . "/" . $classpath);
             $autodiscover->setClass($classpath . "_external");
             $autodiscover->handle();
         } else {
             $soap = new Zend_Soap_Server($CFG->wwwroot . "/webservice/soap/server.php?token=" . $token . "&classpath=" . $classpath . "&wsdl");
             // this current file here
             $soap->setClass($classpath . "_external");
             $soap->registerFaultException('moodle_exception');
             $soap->handle();
         }
     }
 }