/** * * @return \oetas\XML\WSDLReader\Wsdl\Definitions */ public function readNode(\DOMElement $node, $file = 'wsdl.xsd') { $this->loadedFiles[$file] = $rootDefinitions = new Definitions(); $schema = new Schema(); $schema->addSchema($this->reader->getGlobalSchema()); $rootDefinitions->setSchema($schema); $callbacks = $this->rootNode($rootDefinitions, $node); foreach ($callbacks as $callback) { call_user_func($callback); } return $rootDefinitions; }
/** * @param $import \GoetasWebservices\XML\WSDLReader\Wsdl\Definitions */ public function addImport(Definitions $import) { $this->import[] = $import; $this->getSchema()->addSchema($import->getSchema()); return $this; }
protected function makeAssertionsLoad(Definitions $definitions) { $this->assertEquals("foo", $definitions->getName()); $this->assertCount(2, $definitions->getMessages()); $this->assertCount(1, $definitions->getBindings()); $this->assertCount(1, $definitions->getPortTypes()); $this->assertCount(1, $definitions->getServices()); $this->assertEquals('http://www.example.com', $definitions->getTargetNamespace()); // messages $messages = $definitions->getMessages(); $this->assertArrayHasKey('GetQuoteSoapIn', $messages); $this->assertArrayHasKey('GetQuoteSoapOut', $messages); $this->assertInstanceOf('GoetasWebservices\\XML\\WSDLReader\\Wsdl\\Message', $messages['GetQuoteSoapIn']); $this->assertInstanceOf('GoetasWebservices\\XML\\WSDLReader\\Wsdl\\Message', $messages['GetQuoteSoapOut']); $this->assertSame($definitions->getMessage('GetQuoteSoapIn'), $messages['GetQuoteSoapIn']); $this->assertSame($definitions->getMessage('GetQuoteSoapOut'), $messages['GetQuoteSoapOut']); // messsage parts $messageParts = $definitions->getMessage('GetQuoteSoapIn')->getParts(); $this->assertArrayHasKey('parameters', $messageParts); $this->assertInstanceOf('GoetasWebservices\\XML\\WSDLReader\\Wsdl\\Message\\Part', $messageParts['parameters']); $this->assertInstanceOf('GoetasWebservices\\XML\\XSDReader\\Schema\\Element\\ElementDef', $messageParts['parameters']->getElement()); $this->assertNull($messageParts['parameters']->getType()); $messageParts = $definitions->getMessage('GetQuoteSoapOut')->getParts(); $this->assertArrayHasKey('parameters', $messageParts); $this->assertInstanceOf('GoetasWebservices\\XML\\WSDLReader\\Wsdl\\Message\\Part', $messageParts['parameters']); $this->assertInstanceOf('GoetasWebservices\\XML\\XSDReader\\Schema\\Type\\ComplexType', $messageParts['parameters']->getType()); $this->assertNull($messageParts['parameters']->getElement()); //port types $portTypes = $definitions->getPortTypes(); $this->assertArrayHasKey('StockQuoteSoap', $portTypes); $this->assertInstanceOf('GoetasWebservices\\XML\\WSDLReader\\Wsdl\\PortType', $portTypes['StockQuoteSoap']); $this->assertSame($definitions->getPortType('StockQuoteSoap'), $portTypes['StockQuoteSoap']); // port type opertations $portType = $definitions->getPortType('StockQuoteSoap'); $operations = $portType->getOperations(); $this->assertArrayHasKey('GetQuote', $operations); $this->assertArrayHasKey('GetQuoteWithFault', $operations); $this->assertInstanceOf('GoetasWebservices\\XML\\WSDLReader\\Wsdl\\PortType\\Operation', $operations['GetQuote']); $this->assertSame($portType->getOperation('GetQuote'), $operations['GetQuote']); $this->assertInstanceOf('GoetasWebservices\\XML\\WSDLReader\\Wsdl\\PortType\\Param', $operations['GetQuote']->getInput()); $this->assertInstanceOf('GoetasWebservices\\XML\\WSDLReader\\Wsdl\\PortType\\Param', $operations['GetQuote']->getOutput()); $this->assertEmpty($operations['GetQuote']->getFaults()); $this->assertInstanceOf('GoetasWebservices\\XML\\WSDLReader\\Wsdl\\PortType\\Operation', $operations['GetQuoteWithFault']); $this->assertSame($portType->getOperation('GetQuoteWithFault'), $operations['GetQuoteWithFault']); $this->assertInstanceOf('GoetasWebservices\\XML\\WSDLReader\\Wsdl\\PortType\\Param', $operations['GetQuoteWithFault']->getInput()); $this->assertInstanceOf('GoetasWebservices\\XML\\WSDLReader\\Wsdl\\PortType\\Param', $operations['GetQuoteWithFault']->getOutput()); $this->assertCount(1, $operations['GetQuoteWithFault']->getFaults()); $this->assertContainsOnlyInstancesOf('GoetasWebservices\\XML\\WSDLReader\\Wsdl\\PortType\\Fault', $operations['GetQuoteWithFault']->getFaults()); $this->assertArrayHasKey('foo', $operations['GetQuoteWithFault']->getFaults()); //bindings $bindings = $definitions->getBindings(); $this->assertArrayHasKey('StockQuoteSoap', $bindings); $this->assertInstanceOf('GoetasWebservices\\XML\\WSDLReader\\Wsdl\\Binding', $bindings['StockQuoteSoap']); $this->assertSame($definitions->getBinding('StockQuoteSoap'), $bindings['StockQuoteSoap']); //binding operation $binding = $definitions->getBinding('StockQuoteSoap'); $this->assertSame($binding->getType(), $portTypes['StockQuoteSoap']); $operations = $binding->getOperations(); $this->assertArrayHasKey('GetQuote', $operations); $this->assertArrayHasKey('GetQuoteWithFault', $operations); $this->assertInstanceOf('GoetasWebservices\\XML\\WSDLReader\\Wsdl\\Binding\\Operation', $operations['GetQuote']); $this->assertSame($binding->getOperation('GetQuote'), $operations['GetQuote']); $this->assertInstanceOf('GoetasWebservices\\XML\\WSDLReader\\Wsdl\\Binding\\OperationMessage', $operations['GetQuote']->getInput()); $this->assertInstanceOf('GoetasWebservices\\XML\\WSDLReader\\Wsdl\\Binding\\OperationMessage', $operations['GetQuote']->getOutput()); $this->assertEmpty($operations['GetQuote']->getFaults()); $this->assertInstanceOf('GoetasWebservices\\XML\\WSDLReader\\Wsdl\\Binding\\Operation', $operations['GetQuoteWithFault']); $this->assertSame($binding->getOperation('GetQuoteWithFault'), $operations['GetQuoteWithFault']); $this->assertInstanceOf('GoetasWebservices\\XML\\WSDLReader\\Wsdl\\Binding\\OperationMessage', $operations['GetQuoteWithFault']->getInput()); $this->assertInstanceOf('GoetasWebservices\\XML\\WSDLReader\\Wsdl\\Binding\\OperationMessage', $operations['GetQuoteWithFault']->getOutput()); $this->assertCount(2, $operations['GetQuoteWithFault']->getFaults()); $this->assertContainsOnlyInstancesOf('GoetasWebservices\\XML\\WSDLReader\\Wsdl\\Binding\\OperationFault', $operations['GetQuoteWithFault']->getFaults()); $this->assertArrayHasKey('foo', $operations['GetQuoteWithFault']->getFaults()); $this->assertArrayHasKey('bar', $operations['GetQuoteWithFault']->getFaults()); // services $services = $definitions->getServices(); $this->assertArrayHasKey('StockQuote', $services); $this->assertInstanceOf('GoetasWebservices\\XML\\WSDLReader\\Wsdl\\Service', $services['StockQuote']); $this->assertSame($definitions->getService('StockQuote'), $services['StockQuote']); $service = $definitions->getService('StockQuote'); $this->assertEquals("Foo", $service->getDocumentation()); $ports = $service->getPorts(); $this->assertArrayHasKey('StockQuoteSoap', $ports); $this->assertInstanceOf('GoetasWebservices\\XML\\WSDLReader\\Wsdl\\Service\\Port', $ports['StockQuoteSoap']); $this->assertSame($service->getPort('StockQuoteSoap'), $ports['StockQuoteSoap']); // port bindig $this->assertSame($service->getPort('StockQuoteSoap')->getBinding(), $bindings['StockQuoteSoap']); $this->assertSame($bindings['StockQuoteSoap'], $definitions->findBinding('StockQuoteSoap')); $this->assertSame($messages['GetQuoteSoapIn'], $definitions->findMessage('GetQuoteSoapIn')); $this->assertSame($portTypes['StockQuoteSoap'], $definitions->findPortType('StockQuoteSoap')); $this->assertSame($services['StockQuote'], $definitions->findService('StockQuote')); $this->assertSame($bindings['StockQuoteSoap'], $definitions->findBinding('StockQuoteSoap', 'http://www.example.com')); $this->assertSame($messages['GetQuoteSoapIn'], $definitions->findMessage('GetQuoteSoapIn', 'http://www.example.com')); $this->assertSame($portTypes['StockQuoteSoap'], $definitions->findPortType('StockQuoteSoap', 'http://www.example.com')); $this->assertSame($services['StockQuote'], $definitions->findService('StockQuote', 'http://www.example.com')); }