コード例 #1
1
ファイル: SAM_Client.php プロジェクト: psagi/sdo
 /**
  * creates a connection using connection factory
  * @param $connFactory SDO Data object type = msd:ConnectionFactory
  * @return SAMConnection or null
  */
 private function _configConnection($connFactory)
 {
     $optionsarray = array();
     foreach ($connFactory as $key => $value) {
         switch ($key) {
             case "protocol":
                 $protocol = $value;
                 break;
             default:
                 $optionsarray[self::$samOptions[$key]] = $value;
                 break;
         }
     }
     /*check mandatory fields */
     if (!isset($protocol)) {
         throw new SCA_RuntimeException('message binding configuration connectionFactory missing: protocol. ');
     }
     if (self::$test_mode) {
         /*in test mode, use $this::test_queueborker */
         if (is_null(self::$test_queueborker)) {
             self::$test_queueborker = array();
         }
         $connection = null;
     } else {
         /*connecting to a real broker*/
         $connection = new SAMConnection();
         $connection->connect($protocol, $optionsarray);
         if (!$connection) {
             throw new SCA_RuntimeException("SAM connection failed");
         }
     }
     return $connection;
 }
コード例 #2
0
ファイル: ServiceRequestHandler.php プロジェクト: psagi/sdo
 /**
  * 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;
 }
コード例 #3
0
ファイル: MSTest.php プロジェクト: psagi/sdo
 /**
  * Set up the strings representing the expected test outputs
  */
 public function setUp()
 {
     $this->mpd = file_get_contents(dirname(__FILE__) . "/TestServiceCorrectMPD");
     SCA_Bindings_message_SAMClient::$test_mode = true;
     /*preparing test messages for testOperationSelection
            msg1 has 'scaOperationName' property, and = 'hello'
                  wrapper should invoke service's operation hello
       */
     $this->msg1 = new SAMMessage("test message 1");
     $this->msg1->header->SAM_TYPE = SAM_TEXT;
     $this->msg1->header->SAM_MESSAGEID = "id-test0001";
     $this->msg1->header->scaOperationName = "hello";
     /*
          msg2 does have 'scaOperationName' property
                wrapper should invoke 'onMessage' by default
     */
     $this->msg2 = new SAMMessage("test message 2");
     $this->msg2->header->SAM_TYPE = SAM_TEXT;
     $this->msg2->header->SAM_MESSAGEID = "id-test0002";
     /*copy names.xsd to current directory*/
     copy(dirname(__FILE__) . "/names_xsd", "names.xsd");
 }