コード例 #1
0
ファイル: AutoDiscoverTest.php プロジェクト: pnaq57/zf2demo
 /**
  * @dataProvider dataProviderForSetServiceName
  */
 public function testSetServiceName($newName, $shouldBeValid)
 {
     if ($shouldBeValid == false) {
         $this->setExpectedException('InvalidArgumentException');
     }
     $this->server->setServiceName($newName);
     $this->bindWsdl($this->server->generate());
     $this->assertSpecificNodeNumberInXPath(1, '/wsdl:definitions[@name="' . $newName . '"]');
 }
コード例 #2
0
ファイル: SoapController.php プロジェクト: ahumadamob/siris
 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
ファイル: SoapService.php プロジェクト: realboard/dbinstance
 /**
  * {@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();
 }
コード例 #5
0
ファイル: ClientTest.php プロジェクト: pnaq57/zf2demo
 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);
 }
コード例 #6
0
ファイル: AutoDiscoverTest.php プロジェクト: nieldm/zf2
 /**
  * @group ZF-4117
  */
 public function testChangeWsdlUriInConstructor()
 {
     $scriptUri = 'http://localhost/my_script.php';
     $server = new AutoDiscover(null, "http://example.com/service.php");
     $server->setServiceName("TestService");
     $server->addFunction('\\ZendTest\\Soap\\TestAsset\\TestFunc');
     $wsdlOutput = $server->toXml();
     $this->assertNotContains($scriptUri, $wsdlOutput);
     $this->assertContains("http://example.com/service.php", $wsdlOutput);
 }
コード例 #7
0
ファイル: ServerTest.php プロジェクト: pnaq57/zf2demo
 /**
  * @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);
 }