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(); }
/** * Returns an XSD Type for the given PHP type * * @param string $type PHP Type to get the XSD type for * @return string */ public function getType($type) { if (!$this->_wsdl instanceof Wsdl) { /** @todo Exception throwing may be more correct */ // WSDL is not defined yet, so we can't recognize type in context of current service return ''; } else { return $this->_wsdl->getType($type); } }
/** * @group ZF-3910 */ function testCaseOfDocBlockParamsDosNotMatterForSoapTypeDetectionZf3910() { $wsdl = new Wsdl('MyService', 'http://localhost/MyService.php'); $this->assertEquals("xsd:string", $wsdl->getType("StrIng")); $this->assertEquals("xsd:string", $wsdl->getType("sTr")); $this->assertEquals("xsd:int", $wsdl->getType("iNt")); $this->assertEquals("xsd:int", $wsdl->getType("INTEGER")); $this->assertEquals("xsd:float", $wsdl->getType("FLOAT")); $this->assertEquals("xsd:float", $wsdl->getType("douBLE")); }
/** * @group ZF-11937 */ public function testWsdlGetTypeWillAllowLongType() { $wsdl = new Wsdl('MyService', 'http://localhost/MyService.php'); $this->assertEquals("xsd:long", $wsdl->getType("long")); }
public function testGetComplexTypeBasedOnStrategiesStringNames() { $this->wsdl = new Wsdl($this->defaultServiceName, 'http://localhost/MyService.php', new Wsdl\ComplexTypeStrategy\DefaultComplexType()); $this->assertEquals('tns:WsdlTestClass', $this->wsdl->getType('\\ZendTest\\Soap\\TestAsset\\WsdlTestClass')); $this->assertTrue($this->wsdl->getComplexTypeStrategy() instanceof Wsdl\ComplexTypeStrategy\DefaultComplexType); $wsdl2 = new Wsdl($this->defaultServiceName, $this->defaultServiceUri, new Wsdl\ComplexTypeStrategy\AnyType()); $this->assertEquals('xsd:anyType', $wsdl2->getType('\\ZendTest\\Soap\\TestAsset\\WsdlTestClass')); $this->assertTrue($wsdl2->getComplexTypeStrategy() instanceof Wsdl\ComplexTypeStrategy\AnyType); }