예제 #1
0
 /**
  *
  * @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 dump(ServiceProvider $serviceProvider)
 {
     ini_set("soap.wsdl_cache", "0");
     ini_set("soap.wsdl_cache_enabled", "0");
     ini_set('soap.wsdl_cache_ttl', 0);
     $filePath = $serviceProvider->getWsdlPath();
     $autodiscover = new AutoDiscover();
     $autodiscover->setClass($serviceProvider->getServiceClassName())->setComplexTypeStrategy(new \Zend\Soap\Wsdl\ComplexTypeStrategy\DefaultComplexType())->setUri($serviceProvider->getUrlLocation())->setServiceName('MySoapService');
     $autodiscover->dump($filePath);
 }
예제 #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
    /**
     * @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();
    }
예제 #5
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;
 }
예제 #7
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();
 }
예제 #8
0
 /**
  * @runInSeparateProcess
  */
 public function testHandle()
 {
     $scriptUri = 'http://localhost/MyService.php';
     $this->server->setClass('\\ZendTest\\Soap\\TestAsset\\Test');
     ob_start();
     $this->server->handle();
     $actualWsdl = ob_get_clean();
     $this->assertNotEmpty($actualWsdl, "WSDL content was not outputted.");
     $this->assertContains($scriptUri, $actualWsdl, "Script URL was not found in WSDL content.");
 }
예제 #9
0
 public function soapAction()
 {
     //$view = new ViewModel();
     //$view->setTerminal(true);
     if (isset($_GET['wsdl'])) {
         $autodiscover = new AutoDiscover();
         $autodiscover->setClass('Customers\\Model\\SOAPSave')->setUri('http://zf2_soap.loc/customers/SOAP/soap');
         $viewModel = new ViewModel(array('ad' => $autodiscover));
         $viewModel->setTerminal(true);
         return $viewModel;
     } else {
         // pointing to the current file here
         $soap = new Server("http://zf2_soap.loc/customers/SOAP/soap?wsdl");
         $soap->setClass('Customers\\Model\\SOAPSave');
         $soap->handle();
         $viewModel->setTemplate('customers/SOAP/soap_1');
         $viewModel->setTerminal(true);
         return $viewModel;
     }
     //return $view;
 }
예제 #10
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();
 }
예제 #11
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);
 }
예제 #12
0
 /**
  * @group ZF-5736
  */
 public function testAmpersandInUrlIsCorrectlyEncoded()
 {
     $autodiscover = new AutoDiscover();
     $autodiscover->setUri("http://example.com/?a=b&b=c");
     $autodiscover->setClass('\\ZendTest\\Soap\\TestAsset\\Test');
     $wsdl = $autodiscover->toXml();
     $this->assertContains("http://example.com/?a=b&b=c", $wsdl);
 }
예제 #13
0
파일: Action.php 프로젝트: im286er/ent
 /**
  * 创建一个服务
  */
 public function soap($uri, $className, $config = null)
 {
     if (isset($_GET['wsdl'])) {
         $autodiscover = new AutoDiscover();
         $autodiscover->setClass($className)->setUri($uri);
         return $autodiscover->toXml();
     } else {
         $wsdl = strpos($uri, '?') === false ? $uri . '?wsdl' : $uri . '&wsdl';
         $server = new SoapServer($wsdl);
         $obj = $config == null ? new $className() : new $className($config);
         $server->setObject($obj);
         $server->handle();
         $response = $server->getLastRequest();
         if ($response instanceof \SoapFault) {
             $response = exceptionMsg($response);
             $this->log($response);
         }
         return $response;
     }
 }
예제 #14
0
    /**
     * @group ZF-8948
     * @group ZF-5766
     */
    public function testRecursiveWsdlDependencies()
    {
        $autodiscover = new AutoDiscover('\Zend\Soap\Wsdl\Strategy\ArrayOfTypeComplex');
        $autodiscover->setClass('\ZendTest\Soap\TestAsset\Recursion');
        $wsdl = $autodiscover->toXml();

        //  <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"/>


        $path = '//wsdl:types/xsd:schema/xsd:complexType[@name="ZendTest.Soap.TestAsset.Recursion"]/xsd:all/xsd:element[@name="recursion" and @type="tns:ZendTest.Soap.TestAsset.Recursion"]';
        $this->assertWsdlPathExists($wsdl, $path);
    }
예제 #15
0
 public function SOAPServer()
 {
     try {
         if (isset($this->data->wsdl)) {
             $ad = new AutoDiscover();
             $ad->setClass('SOAPService');
             $uri = Manager::getAppURL('exemplos', 'zend/soapServer', true);
             $ad->setURI($uri);
             $wsdl = $ad->toXML();
             $this->renderStream($wsdl);
         } else {
             $uri = Manager::getAppURL('exemplos', 'zend/soapServer?wsdl', true);
             $server = new Server($uri);
             $server->setSoapVersion(SOAP_1_2);
             $server->setClass('SOAPService');
             $server->setReturnResponse(true);
             $response = $server->handle();
             $this->renderBinary($response);
         }
     } catch (Exception $e) {
         mdump($e->getMessage());
         mdump($e->getTraceAsString());
     }
 }
예제 #16
0
 public function WsdlAction()
 {
     $wsdl = new AutoDiscover();
     $wsdl->setClass('\\Application\\Webservices\\gpa')->setUri($this->_WSDL_URI . '/soap');
     //print_r($wsdl);
     $wsdl->handle();
     /* $wsdl = $wsdl->generate();
        $wsdl = $wsdl->toDomDocument();
        // geramos o XML dando um echo no $wsdl->saveXML() 
        echo $wsdl->saveXML();
            
        header('Content-type: application/xml');
        echo $wsdl->toXml();
        exit();*/
     return $this->setTerminal();
 }
예제 #17
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);
 }