/**
  *
  * @return multitype:\SplFileInfo \Symfony\Component\Finder\Finder
  *         \Symfony\Component\HttpFoundation\mixed
  */
 protected function getModel()
 {
     $model = parent::getModel();
     $model = $model['model'];
     $bundle = $this->getRequest()->get('bundle', NULL);
     $namespace = $this->getRequest()->get('namespace', NULL);
     $class = $this->getRequest()->get('class', NULL);
     $kernel = $this->get('kernel');
     $bundles = $kernel->getBundles();
     $classWsdl = null;
     $classWsdlDomDocument = null;
     if (NULL !== $bundle && array_key_exists($bundle, $bundles)) {
         $bundle = new BundleReflection($bundles[$bundle]);
         $namespace = $bundle->getNamespace($namespace);
         if (NULL !== $class) {
             try {
                 $class = $namespace->getClassReflection($class);
                 $autodiscover = new AutoDiscover();
                 $autodiscover->setClass($class->getName())->setUri($this->getRequest()->getBaseUrl() . $this->getRequest()->getRequestUri())->setServiceName($class->getName());
                 $classWsdl = $autodiscover->generate();
                 $classWsdlDomDocument = $classWsdl->toDomDocument();
                 $classWsdlDomDocument->formatOutput = true;
             } catch (\Exception $e) {
             }
         }
     }
     $model['bundle'] = $bundle;
     $model['bundles'] = $bundles;
     $model['namespace'] = $namespace;
     $model['class'] = $class;
     $model['classWsdl'] = $classWsdl;
     $model['classWsdlDomDocument'] = $classWsdlDomDocument;
     return array('model' => $model);
 }
示例#2
0
 public function handleWSDL($local)
 {
     header("Content-type: text/xml");
     $autoDiscover = new AutoDiscover(new ArrayOfTypeSequence());
     $autoDiscover->setClass('\\Tesoreria\\Service\\Tesoreria');
     $autoDiscover->setUri(Constants::WSDL_URI_TESORERIA . $local);
     $autoDiscover->setServiceName('Tesoreria');
     $autoDiscover->setOperationBodyStyle(array('use' => 'literal'));
     $wsdl = $autoDiscover->generate();
     $wsdl = $wsdl->toDomDocument();
     echo $wsdl->saveXML();
 }
示例#3
0
 private function handleWSDL()
 {
     $autodiscover = new AutoDiscover();
     //Setamos a classe no autodiscover com o metodo setClass
     $autodiscover->setClass('Calculadora')->setUri(self::SERVER_URI);
     // Configuração do nome do serviço.
     $autodiscover->setServiceName("CodeIgniter com ZF2 SOAP");
     $wsdl = $autodiscover->generate();
     // Geramos o XML dando um echo no $wsdl->saveXML()
     echo $wsdl->toXml();
     // Salvamos fisicamente uma cópia do documento WSDL.
     $wsdl->dump(self::WSDL_FILE);
     $dom = $wsdl->toDomDocument();
 }
示例#4
0
 /**
  * @group ZF-8948
  * @group ZF-5766
  */
 public function testRecursiveWsdlDependencies()
 {
     $this->server->setComplexTypeStrategy(new \Zend\Soap\Wsdl\ComplexTypeStrategy\ArrayOfTypeSequence());
     $this->server->setClass('\\ZendTest\\Soap\\TestAsset\\Recursion');
     $this->bindWsdl($this->server->generate());
     //  <types>
     //      <xsd:schema targetNamespace="http://localhost/my_script.php">
     //          <xsd:complexType name="Zend_Soap_AutoDiscover_Recursion">
     //              <xsd:all>
     //                  <xsd:element name="recursion" type="tns:Zend_Soap_AutoDiscover_Recursion"/>
     $this->assertSpecificNodeNumberInXPath(1, '//wsdl:types/xsd:schema/xsd:complexType[@name="Recursion"]/xsd:all/' . 'xsd:element[@name="recursion" and @type="tns:Recursion"]');
     $this->assertValidWSDL($this->dom);
     $this->testDocumentNodes();
 }
示例#5
0
    /**
     * @param string $uri
     * @throws Exception
     */
    private function handleWsdl($uri)
    {

        // We need to cache the WSDL here!!!

        $autoDiscover = new AutoDiscover();
        $autoDiscover
            ->setClass($this->getHandler())
            ->setUri($uri);

        $wsdl = $autoDiscover->generate();

        header('Content-Type: application/xml');
        echo $wsdl->toXml();
    }
示例#6
0
 /**
  * Exibe o WSDL Description
  * @return xml WSDL
  */
 private function handleWSDL()
 {
     // Objeto do Zend para leitura da classe
     $autodiscover = new Soap\AutoDiscover(new \Zend\Soap\Wsdl\ComplexTypeStrategy\ArrayOfTypeComplex());
     // Informa a classe
     $autodiscover->setClass($this->ws_class);
     // Informa a url do WS
     $autodiscover->setUri($this->ws_url);
     // Gera os dados
     $wsdl = $autodiscover->generate();
     $wsdl = $wsdl->toDomDocument();
     // Manda um cabecalho de XML
     @header('content-type:text/xml');
     // Escreve em XML
     echo $wsdl->saveXML();
     exit;
 }
 /**
  * @Route("/server", name="soap_server")
  *
  * @param Request $request
  */
 public function soapServerAction(Request $request)
 {
     if ($request->query->get('wsdl') !== null) {
         $complexTypeStrategy = new ArrayOfTypeComplex();
         $autoDiscover = new AutoDiscover($complexTypeStrategy);
         $autoDiscover->setClass(SoapProcessor::class);
         $autoDiscover->setUri($this->generateUrl('soap_server', array(), UrlGeneratorInterface::ABSOLUTE_URL));
         $wsdl = $autoDiscover->generate();
         echo $wsdl->toXml();
         exit;
     }
     $soapServerOptions = array('classmap' => array('BusinessObject' => BusinessObject::class));
     $soapServer = new SoapServer($this->generateUrl('soap_server', array('wsdl' => ''), UrlGeneratorInterface::ABSOLUTE_URL), $soapServerOptions);
     $soapServer->setObject(new SoapProcessor());
     $soapServer->handle();
     exit;
 }
示例#8
0
 /**
  * {@inheritdoc}
  */
 public function serve($params = null)
 {
     $uri = $params;
     if (!class_exists('SoapServer')) {
         throw new \Exception('SoapServer is required. Please enable this extension');
         exit;
     }
     if (!class_exists('Zend\\Soap\\Server')) {
         throw new \Exception("Zend\\Soap\\Server is required. " . "Please install it using 'composer require zend/zend-soap'");
         exit;
     }
     $serviceHandler = get_class($this->serviceHandler);
     $obj = new $serviceHandler($this->authentication, $this->connectionStrings, $this->logDir);
     if (null === $uri) {
         $uri = strtok($this->request->getUri(), '?');
         $uri = dirname($uri) . '/' . basename($uri);
     }
     $response = new Response();
     $response->headers->set('Access-Control-Allow-Headers', 'origin, content-type, accept');
     $response->headers->set('Access-Control-Allow-Origin', '*');
     $response->headers->set('Access-Control-Allow-Methods', 'POST, GET, OPTIONS');
     $response->headers->set('Content-type', 'text/xml');
     $cacheFile = dirname($_SERVER['SCRIPT_FILENAME']) . '/dbinstance.wsdl.xml';
     if (isset($_GET['wsdl']) || isset($_GET['WSDL'])) {
         $xml = '';
         if (file_exists($cacheFile)) {
             $xml = file_get_contents($cacheFile);
         } else {
             $autodiscover = new AutoDiscover();
             $autodiscover->setUri($uri);
             $autodiscover->setClass($serviceHandler);
             $autodiscover->setServiceName('DBInstance');
             $wsdl = $autodiscover->generate();
             $xml = $wsdl->toXml();
             $wsdl->dump($cacheFile);
         }
         $response->setContent($xml);
         return $response->send();
     }
     $response->sendHeaders();
     $server = new Server($uri . '?wsdl');
     $server->setObject($obj);
     $server->handle();
 }
示例#9
0
 public function testGetTypes()
 {
     $wsdlFilename = __DIR__ . '/TestAsset/GetTypesWsdlTest.wsdl';
     $autodiscover = new AutoDiscover();
     $autodiscover->setServiceName('ExampleService');
     $autodiscover->setComplexTypeStrategy(new \Zend\Soap\Wsdl\ComplexTypeStrategy\ArrayOfTypeComplex());
     $autodiscover->setClass('\\ZendTest\\Soap\\TestAsset\\AutoDiscoverTestClass2');
     $autodiscover->setUri('http://example.com');
     $wsdl = $autodiscover->generate();
     $wsdl->dump($wsdlFilename);
     $server = new Server($wsdlFilename);
     $server->setClass('\\ZendTest\\Soap\\TestAsset\\AutoDiscoverTestClass2');
     $client = new Client\Local($server, $wsdlFilename);
     $soapClient = $client->getSoapClient();
     $typesArray = $soapClient->__getTypes();
     $this->assertCount(2, $typesArray);
     $count = 0;
     foreach ($typesArray as $element) {
         if (strpos($element, 'struct AutoDiscoverTestClass1') === 0 or strpos($element, 'AutoDiscoverTestClass1 ArrayOfAutoDiscoverTestClass1') === 0) {
             $count++;
         }
     }
     $this->assertEquals(2, $count, 'Invalid types');
     unlink($wsdlFilename);
 }
示例#10
0
 /**
  * @expectedException \SoapFault
  */
 public function testHandlePhpErrors()
 {
     if (headers_sent()) {
         $this->markTestSkipped('Cannot run ' . __METHOD__ . '() when headers have already been sent; enable output buffering to run this test');
         return;
     }
     $wsdlFilename = __DIR__ . '/TestAsset/testHandlePhpErrors.wsdl';
     $autodiscover = new AutoDiscover();
     $autodiscover->setOperationBodyStyle(array('use' => 'literal'));
     $autodiscover->setBindingStyle(array('style' => 'document', 'transport' => 'http://schemas.xmlsoap.org/soap/http'));
     $autodiscover->setServiceName('ExampleService');
     $autodiscover->setUri('http://example.com');
     $autodiscover->setClass('\\ZendTest\\Soap\\TestAsset\\errorClass');
     $wsdl = $autodiscover->generate();
     $wsdl->dump($wsdlFilename);
     $server = new Server($wsdlFilename);
     $server->setClass('\\ZendTest\\Soap\\TestAsset\\errorClass');
     $client = new \Zend\Soap\Client\Local($server, $wsdlFilename);
     $client->triggerError();
     unlink($wsdlFilename);
 }