示例#1
0
    public function setUp()
    {
        if (!class_exists('SCA_Bindings_soap_Proxy')) {
            $this->markTestSkipped("Cannot execute any SCA soap tests as the SCA soap binding is not loaded");
            return;
        }
        $php = <<<PHP
<?php
require_once 'SCA/SCA.php';

/**
 * @service
 * @binding.soap
 * @types aaa://PersonNamespace person.xsd
*/
class HelloPersonService
{
  /**
    * @param personType \$person aaa://PersonNamespace
    * @return string
    */
    public function hello(\$person)
    {
        return "hello \$person->name, you were born in \$person->pob on \$person->dob";
    }
}
?>
PHP;
        file_put_contents(dirname(__FILE__) . '/HelloPersonService.php', $php);
        $service_description = SCA::constructServiceDescription(dirname(__FILE__) . '/HelloPersonService.php');
        $wsdl = SCA_Bindings_soap_ServiceDescriptionGenerator::generateDocumentLiteralWrappedWsdl($service_description);
        file_put_contents(dirname(__FILE__) . '/HelloPersonService.wsdl', $wsdl);
        $xsd = <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
        targetNamespace="aaa://PersonNamespace"
        xmlns:PersonNamespace="aaa://PersonNamespace">
  <complexType name="personType">
    <sequence>
      <element name="name" type="string"/>
      <element name="dob" type="string"/>
      <element name="pob" type="string"/>
    </sequence>
  </complexType>
</schema>
EOF;
        file_put_contents(dirname(__FILE__) . '/person.xsd', $xsd);
    }
示例#2
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;
 }
示例#3
0
文件: ProxyTest.php 项目: psagi/sdo
    public function setUp()
    {
        if (!class_exists('SCA_Bindings_soap_Proxy')) {
            $this->markTestSkipped("Cannot execute any SCA soap tests as the SCA soap binding is not loaded");
            return;
        }
        $php = <<<PHP
<?php

include_once "SCA/SCA.php";

/**
 * @service
 * @binding.soap
 * @types PersonNamespace person.xsd
 */
class SoapProxyTest
{
}

?>
PHP;
        file_put_contents(dirname(__FILE__) . '/SoapProxyTest.php', $php);
        $service_description = SCA::constructServiceDescription(dirname(__FILE__) . '/SoapProxyTest.php');
        $wsdl = SCA_Bindings_soap_ServiceDescriptionGenerator::generateDocumentLiteralWrappedWsdl($service_description);
        file_put_contents(dirname(__FILE__) . '/SoapProxyTest.wsdl', $wsdl);
        $xsd = <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
        targetNamespace="PersonNamespace"
        xmlns:AuthorNS="PersonNamespace">
  <complexType name="personType">
    <sequence>
      <element name="name" type="string"/>
      <element name="dob" type="string"/>
      <element name="pob" type="string"/>
    </sequence>
  </complexType>
</schema>
EOF;
        file_put_contents(dirname(__FILE__) . '/person.xsd', $xsd);
    }
示例#4
0
 /**
  * Generate
  *
  * @param string $service_description Service Description
  *
  * @return null
  */
 public function generate($service_description)
 {
     SCA::$logger->log("Entering");
     try {
         if (isset($_GET['wsdl'])) {
             /*if request url end with ?wsdl, generate a wsdl file
               using the ServiceDescriptionGenerator from soap binding*/
             $str = SCA_Bindings_soap_ServiceDescriptionGenerator::generateDocumentLiteralWrappedWsdl($service_description);
         } else {
             $str = $this->generateMSD($service_description);
         }
         /* causes a php warning 'Cannot modify header information'
            when executing a phpunit testcase*/
         //header('Content-type: text/xml');
         echo $str;
         SCA::$logger->log('Exiting having generated wsdl');
     } catch (SCA_RuntimeException $se) {
         echo $se . "\n";
     } catch (SDO_DAS_XML_FileException $e) {
         echo "{$e->getMessage()} in {$e->getFile()}";
     }
     return;
 }
示例#5
0
文件: HandlerTest.php 项目: psagi/sdo
    public function setUp()
    {
        if (!class_exists('SCA_Bindings_soap_Proxy')) {
            $this->markTestSkipped("Cannot execute any SCA soap tests as the SCA soap binding is not loaded");
            return;
        }
        $php = <<<PHP
<?php

require_once "SCA/SCA.php";

/**
 * @service
 * @binding.soap
 */

class SoapHandlerTestComponent {

\t/**
\t * Reverse a string
\t *
\t * @param string \$in (comment)
\t * @return string (comment)
\t */
\tfunction reverse(\$in)
\t{
\t\treturn strrev (\$in);
\t}
}

?>
PHP;
        file_put_contents(dirname(__FILE__) . '/SoapHandlerTestComponent.php', $php);
        $service_description = SCA::constructServiceDescription(dirname(__FILE__) . '/SoapHandlerTestComponent.php');
        $wsdl = SCA_Bindings_soap_ServiceDescriptionGenerator::generateDocumentLiteralWrappedWsdl($service_description);
        file_put_contents(dirname(__FILE__) . '/SoapHandlerTestComponent.wsdl', $wsdl);
    }
示例#6
0
文件: WSDLTest.php 项目: psagi/sdo
 public function testMagicMethodsDontGetGeneratedIntoWsdl()
 {
     $service_description = SCA::constructServiceDescription(dirname(__FILE__) . "/Class5.php");
     $wsdl = SCA_Bindings_soap_ServiceDescriptionGenerator::generateDocumentLiteralWrappedWsdl($service_description);
     $this->assertNotContains('<operation name="__construct">', $wsdl);
     $this->assertNotContains('<operation name="__destruct">', $wsdl);
     $this->assertNotContains('<operation name="__call">', $wsdl);
     $this->assertNotContains('<operation name="__get">', $wsdl);
     $this->assertNotContains('<operation name="__set">', $wsdl);
     $this->assertNotContains('<operation name="__isset">', $wsdl);
     $this->assertNotContains('<operation name="__unset">', $wsdl);
     $this->assertNotContains('<operation name="__sleep">', $wsdl);
     $this->assertNotContains('<operation name="__wakeup">', $wsdl);
     $this->assertNotContains('<operation name="__toString">', $wsdl);
     $this->assertNotContains('<operation name="__set_state">', $wsdl);
     $this->assertNotContains('<operation name="__clone">', $wsdl);
     $this->assertNotContains('<operation name="__autoload">', $wsdl);
 }
示例#7
0
文件: MapperTest.php 项目: psagi/sdo
    public function setUp()
    {
        if (!class_exists('SCA_Bindings_soap_Proxy')) {
            $this->markTestSkipped("Cannot execute any SCA soap tests as the SCA soap binding is not loaded");
            return;
        }
        $xsd = <<<EOF
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
        targetNamespace="PersonNamespace"
        xmlns:AuthorNS="PersonNamespace">
  <complexType name="personType">
    <sequence>
      <element name="name" type="string"/>
      <element name="dob" type="string"/>
      <element name="pob" type="string"/>
    </sequence>
  </complexType>
</schema>
EOF;
        file_put_contents('person.xsd', $xsd);
        $php = <<<EOF
<?php
/**
 * @service
 * @binding.soap
 */
class TypeHandlerTest1 {
    /**
     * @param string \$a
     * @param float \$b
     * @param integer \$c
     * @param boolean \$d
     * @return string
     */
    public function fourargs() {}
}
?>
EOF;
        $class_file = './TypeHandlerTest1.php';
        file_put_contents($class_file, $php);
        $service_description = SCA::constructServiceDescription($class_file);
        $wsdl = SCA_Bindings_soap_ServiceDescriptionGenerator::generateDocumentLiteralWrappedWsdl($service_description);
        file_put_contents('TypeHandlerTest1.wsdl', $wsdl);
        $php = <<<EOF
<?php
/**
 * @service
 * @binding.soap
 * @types PersonNamespace person.xsd
 */
class TypeHandlerTest2 {
    /**
     * @param personType \$p1 PersonNamespace
     * @return personType PersonNamespace
     */
    public function myMethod() {}
}
?>
EOF;
        $class_file = './TypeHandlerTest2.php';
        file_put_contents($class_file, $php);
        $service_description = SCA::constructServiceDescription($class_file);
        $wsdl = SCA_Bindings_soap_ServiceDescriptionGenerator::generateDocumentLiteralWrappedWsdl($service_description);
        file_put_contents('TypeHandlerTest2.wsdl', $wsdl);
    }