예제 #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
 function testAddService()
 {
     $wsdl = new Wsdl('MyService', 'http://localhost/MyService.php');
     $wsdl->addPortType('myPortType');
     $wsdl->addBinding('MyServiceBinding', 'myPortType');
     $wsdl->addService('Service1', 'myPortType', 'MyServiceBinding', 'http://localhost/MyService.php');
     $this->assertEquals($this->sanitizeWsdlXmlOutputForOsCompability($wsdl->toXml()), '<?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">' . '<portType name="myPortType"/>' . '<binding name="MyServiceBinding" type="myPortType"/>' . '<service name="Service1">' . '<port name="myPortType" binding="MyServiceBinding">' . '<soap:address location="http://localhost/MyService.php"/>' . '</port>' . '</service>' . '</definitions>');
 }
예제 #3
0
 /**
  * @dataProvider ampersandInUrlDataProvider()
  */
 public function testAddServiceWithAmpersandInUrl($actualUrl, $expectedUrl)
 {
     $wsdl = new Wsdl('MyService', 'http://localhost/MyService.php');
     $wsdl->addPortType('myPortType');
     $wsdl->addBinding('MyServiceBinding', 'myPortType');
     $wsdl->addService('Service1', 'myPortType', 'MyServiceBinding', $actualUrl);
     $expectedXml = '<service name="Service1">' . '<port name="myPortType" binding="MyServiceBinding">' . '<soap:address location="' . $expectedUrl . '"/>' . '</port>' . '</service>';
     $this->assertContains($expectedXml, $wsdl->toXML());
 }
예제 #4
0
 /**
  * Add a Single or Multiple Functions to the WSDL
  *
  * @param string $function Function Name
  * @param string $namespace Function namespace - Not Used
  */
 public function addFunction($function, $namespace = '')
 {
     static $port;
     static $operation;
     static $binding;
     if (!is_array($function)) {
         $function = (array) $function;
     }
     $uri = $this->getUri();
     if (!$this->_wsdl instanceof Wsdl) {
         $parts = explode('.', basename($_SERVER['SCRIPT_NAME']));
         $name = $parts[0];
         $wsdl = new Wsdl($name, $uri, $this->_strategy);
         // The wsdl:types element must precede all other elements (WS-I Basic Profile 1.1 R2023)
         $wsdl->addSchemaTypeSection();
         $port = $wsdl->addPortType($name . 'Port');
         $binding = $wsdl->addBinding($name . 'Binding', 'tns:' . $name . 'Port');
         $wsdl->addSoapBinding($binding, $this->_bindingStyle['style'], $this->_bindingStyle['transport']);
         $wsdl->addService($name . 'Service', $name . 'Port', 'tns:' . $name . 'Binding', $uri);
     } else {
         $wsdl = $this->_wsdl;
     }
     foreach ($function as $func) {
         $method = $this->_reflection->reflectFunction($func);
         $this->_addFunctionToWsdl($method, $wsdl, $port, $binding);
     }
     $this->_wsdl = $wsdl;
 }