예제 #1
0
 private function loadBinding(Definitions $definitions, DOMElement $node)
 {
     $binding = new Binding($definitions, $node->getAttribute("name"));
     $binding->setDocumentation($this->getDocumentation($node));
     $definitions->addBinding($binding);
     $functions = array();
     foreach ($this->loop($node) as $childNode) {
         switch ($childNode->localName) {
             case 'operation':
                 $functions[] = $this->loadBindingOperation($binding, $childNode);
                 break;
         }
     }
     return function () use($functions, $binding, $definitions, $node) {
         list($name, $ns) = self::splitParts($node, $node->getAttribute("type"));
         $binding->setType($definitions->findPortType($name, $ns));
         $this->dispatcher->dispatch('binding', new BindingEvent($binding, $node));
         foreach ($functions as $function) {
             call_user_func($function);
         }
     };
 }
예제 #2
0
 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'));
 }