コード例 #1
0
 public function dumpServiceDefinition(ServiceDefinition $definition, array $options = array())
 {
     Assert::thatArgumentNotNull('definition', $definition);
     $options = array_merge(array('endpoint' => ''), $options);
     $this->definition = $definition;
     $wsdl = new Wsdl($definition->getName(), $definition->getNamespace());
     $port = $wsdl->addPortType($this->getPortTypeName());
     $binding = $wsdl->addBinding($this->getBindingName(), 'tns:' . $this->getPortTypeName());
     $wsdl->addSoapBinding($binding, 'rpc');
     $wsdl->addService($this->getServiceName(), $this->getPortName(), 'tns:' . $this->getBindingName(), $options['endpoint']);
     foreach ($definition->getMethods() as $method) {
         $requestParts = array();
         $responseParts = array();
         foreach ($method->getArguments() as $argument) {
             $requestParts[$argument->getName()] = $wsdl->getType($argument->getType()->getPhpType());
         }
         if ($method->getReturn() !== null) {
             $responseParts['return'] = $wsdl->getType($method->getReturn()->getPhpType());
         }
         $wsdl->addMessage($this->getRequestMessageName($method), $requestParts);
         $wsdl->addMessage($this->getResponseMessageName($method), $responseParts);
         $portOperation = $wsdl->addPortOperation($port, $method->getName(), 'tns:' . $this->getRequestMessageName($method), 'tns:' . $this->getResponseMessageName($method));
         $portOperation->setAttribute('parameterOrder', implode(' ', array_keys($requestParts)));
         $bindingInput = array('parts' => implode(' ', array_keys($requestParts)), 'use' => 'literal', 'namespace' => $definition->getNamespace(), 'encodingStyle' => 'http://schemas.xmlsoap.org/soap/encoding/');
         $bindingOutput = array('parts' => implode(' ', array_keys($responseParts)), 'use' => 'literal', 'namespace' => $definition->getNamespace(), 'encodingStyle' => 'http://schemas.xmlsoap.org/soap/encoding/');
         $bindingOperation = $wsdl->addBindingOperation($binding, $method->getName(), $bindingInput, $bindingOutput);
         $wsdl->addSoapOperation($bindingOperation, $this->getSoapOperationName($method));
     }
     $this->definition = null;
     $wsdl->toDomDocument()->formatOutput = true;
     return $wsdl->toXml();
 }
コード例 #2
0
ファイル: WsdlTest.php プロジェクト: pnaq57/zf2demo
 /**
  * @dataProvider dataProviderForURITesting
  *
  * @param string $uri
  */
 public function testObjectConstructionWithDifferentURI($uri, $expectedUri)
 {
     $wsdl = new Wsdl($this->defaultServiceName, $uri);
     $dom = $this->registerNamespaces($wsdl->toDomDocument(), $uri);
     $this->testDocumentNodes();
     $this->assertEquals($expectedUri, $dom->lookupNamespaceUri('tns'));
     $this->assertEquals($expectedUri, $dom->documentElement->getAttribute('targetNamespace'));
 }
コード例 #3
0
ファイル: WsdlTestHelper.php プロジェクト: pnaq57/zf2demo
 /**
  * @param \DOMElement $element
  */
 public function testDocumentNodes($element = null)
 {
     if (!$this->wsdl instanceof Wsdl) {
         return;
     }
     if (null === $element) {
         $element = $this->wsdl->toDomDocument()->documentElement;
     }
     /** @var $node \DOMElement */
     foreach ($element->childNodes as $node) {
         if (in_array($node->nodeType, array(XML_ELEMENT_NODE))) {
             $this->assertNotEmpty($node->namespaceURI, 'Document element: ' . $node->nodeName . ' has no valid namespace. Line: ' . $node->getLineNo());
             $this->testDocumentNodes($node);
         }
     }
 }
コード例 #4
0
ファイル: WsdlTest.php プロジェクト: heiglandreas/zf2
 function testToDomDocument()
 {
     $wsdl = new Wsdl('MyService', 'http://localhost/MyService.php');
     $dom = $wsdl->toDomDocument();
     $this->assertTrue($dom instanceof \DOMDocument);
     $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($dom->saveXML()), '<?xml version="1.0"?>' . '<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" ' . 'xmlns:tns="http://localhost/MyService.php" ' . 'xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" ' . 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ' . 'xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/" ' . 'xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" ' . 'name="MyService" targetNamespace="http://localhost/MyService.php"/>');
 }