public function onGet() { parent::onGet(); $version = $this->getUriFragment('version'); $path = $this->getUriFragment('path'); $doc = $this->resourceListing->getDocumentation($path); if ($doc instanceof DocumentationInterface) { if ($version == '*') { $version = $doc->getLatestVersion(); } $resource = $doc->getResource($version); if (!$resource instanceof Resource) { throw new HttpException\NotFoundException('Given version is not available'); } $path = ltrim($resource->getPath(), '/'); $title = $resource->getTitle(); if (empty($title)) { $title = ApiGeneration::generateTitleFromRoute($path); } $endpoint = $this->config['psx_url'] . '/' . $this->config['psx_dispatch'] . $path; $targetNamespace = $this->config['psx_soap_namespace']; $this->response->setHeader('Content-Type', 'text/xml'); $generator = new Generator\Wsdl($title, $endpoint, $targetNamespace); $this->setBody($generator->generate($resource)); } else { throw new HttpException\NotFoundException('Invalid resource'); } }
protected function execute(InputInterface $input, OutputInterface $output) { $version = $input->getArgument('version') ?: '*'; $path = $input->getArgument('path'); $doc = $this->resourceListing->getDocumentation($path); if ($doc instanceof DocumentationInterface) { if ($version == '*') { $version = $doc->getLatestVersion(); } $resource = $doc->getResource($version); if (!$resource instanceof Resource) { throw new RuntimeException('Given version is not available'); } $path = ltrim($resource->getPath(), '/'); $title = $resource->getTitle(); if (empty($title)) { $title = str_replace(' ', '', ucwords(str_replace('/', ' ', $path))); } $endpoint = $this->config['psx_url'] . '/' . $this->config['psx_dispatch'] . $path; $targetNamespace = $this->config['psx_soap_namespace']; $generator = new Generator\Wsdl($title, $endpoint, $targetNamespace); $output->write($generator->generate($resource)); } else { throw new RuntimeException('Invalid resource'); } }
public function testWsdlSchema() { $endpoint = 'http://127.0.0.1/foo/api'; $targetNamespace = 'http://127.0.0.1/wsdl/1/foo/api'; $generator = new Wsdl('foo', $endpoint, $targetNamespace); $dom = new DOMDocument(); $dom->loadXML($generator->generate($this->getResource())); $result = $dom->schemaValidate(__DIR__ . '/Wsdl/wsdl1.xsd'); $this->assertTrue($result); }