Esempio n. 1
0
 /**
  * Handle
  *
  * @param string $calling_component_filename Filename
  * @param string $service_description        Service description
  *
  * @return mixed
  */
 public function handle($calling_component_filename, $service_description)
 {
     SCA::$logger->log("Entering");
     SCA::$logger->log("calling from {$calling_component_filename}");
     //var_dump($service_description);
     // Guess a queue name
     if (!isset($service_description->binding_config['destination'])) {
         $service_description->binding_config['destination'] = 'queue://' . $service_description->class_name;
         SCA::$logger->log("Target queue not specified, SCA will use class name as default queue name");
     }
     //Generate a Message Provider Description file.
     $mpd_filename = str_replace('.php', '.msd', $calling_component_filename);
     if (!file_exists($mpd_filename)) {
         file_put_contents($mpd_filename, SCA_Bindings_message_ServiceDescriptionGenerator::generateMSD($service_description));
     }
     /*do we use WSDL schema?*/
     if (isset($service_description->binding_config['wsdl']) && $service_description->binding_config['wsdl'] == 'disabled') {
         /*No!*/
         $mapper = null;
     } else {
         /*Yes, then we'll also need a wsdl file,
           this is generated by the ServiceDescriptionGenerator class of the soap binding*/
         $wsdl_filename = str_replace('.php', '.wsdl', $calling_component_filename);
         if (!file_exists($wsdl_filename)) {
             file_put_contents($wsdl_filename, SCA_Bindings_soap_ServiceDescriptionGenerator::generateDocumentLiteralWrappedWsdl($service_description));
         }
         $mapper = new SCA_Bindings_message_Mapper();
         try {
             SCA::$logger->log("Wsdl Type = {$wsdl_filename}");
             $mapper->setWSDLTypes($wsdl_filename);
         } catch (SCA_RuntimeException $wsdlerror) {
             echo $wsdlerror->exceptionString() . "\n";
         }
     }
     $class_name = SCA_Helper::guessClassName($calling_component_filename);
     //create a wapper
     $service_wrapper = new SCA_Bindings_message_Wrapper($class_name, $service_description, $mapper);
     // create the message listener
     $listener = new SCA_Bindings_message_SAMClient($service_wrapper);
     $msd_config = SCA_Bindings_message_ServiceDescriptionGenerator::parseBindingConfig($service_description->binding_config);
     $listener->config($msd_config);
     $listener->start();
     echo ">> Test END <<";
     SCA::$logger->log("exiting");
     return;
 }
Esempio n. 2
0
File: Proxy.php Progetto: psagi/sdo
 /**
  * Constructor
  */
 public function __construct($path_to_msd, $immediate_caller_directory, $binding_config)
 {
     SCA::$logger->log('entering');
     //check if SAM extensions is loaded
     if (!in_array('sam', get_loaded_extensions())) {
         throw new SCA_RuntimeException("The SAM extension must be loaded");
     }
     if ($binding_config === null) {
         $binding_config = array();
     }
     $binding_config['msd'] = $path_to_msd;
     /*parse MSD file */
     $msd_config = SCA_Bindings_message_ServiceDescriptionGenerator::parseBindingConfig($binding_config);
     if (isset($msd_config->responseTimeout)) {
         $this->waitResponseTimeout = $msd_config->responseTimeout;
     }
     if (!isset($msd_config->wsdl)) {
         throw new SCA_RuntimeException("Path to WSDL file is required to the binding configuration,\n                                            or the 'wsdl' property should be stated as 'disabled' explicitly.");
     } else {
         /*check if wsdl is disabled,
           if not the wsdl schema will be loaded  */
         if ($msd_config->wsdl != 'disabled') {
             $path_to_wsdl = SCA_Helper::constructAbsoluteTarget($msd_config->wsdl, $immediate_caller_directory);
             SCA::$logger->log('The proxy will use wsdl file :' . $path_to_wsdl);
             $this->mapper = new SCA_Bindings_message_Mapper();
             try {
                 $this->mapper->setWSDLTypes($path_to_wsdl);
                 //$xmldas = $this->mapper->getXmlDas();
             } catch (SCA_RuntimeException $se) {
                 if (substr($path_to_wsdl, 0, 5) == 'http:' && strpos($se->getMessage(), 'SDO_Exception') !== false && strpos($se->getMessage(), 'Unable to parse') !== false && strpos($se->getMessage(), 'Document is empty') !== false) {
                     throw new SCA_RuntimeException('A call to SCA specified a URL: ' . $path_to_wsdl . " The document returned was empty. One explanation for this may be apache bug 39662. See http://issues.apache.org/bugzilla/show_bug.cgi?id=36692. You may need to obtain the WSDL in a browser and save it as a local file.");
                 }
                 throw $se;
             }
         }
     }
     /*create and config a SAM client*/
     $this->ms_client = new SCA_Bindings_message_SAMClient($this);
     $this->ms_client->config($msd_config);
     SCA::$logger->log('SAM is ready');
 }