From fac69c59fab801bdc793cd500492f23d69427c33 Mon Sep 17 00:00:00 2001 From: xue <> Date: Mon, 1 Jan 2007 17:09:55 +0000 Subject: added TSoapService and TSoapServer. --- framework/3rdParty/WsdlGen/Wsdl.php | 102 ++++++++++++++++++------------------ 1 file changed, 51 insertions(+), 51 deletions(-) (limited to 'framework/3rdParty/WsdlGen/Wsdl.php') diff --git a/framework/3rdParty/WsdlGen/Wsdl.php b/framework/3rdParty/WsdlGen/Wsdl.php index dcccc5cd..55694438 100644 --- a/framework/3rdParty/WsdlGen/Wsdl.php +++ b/framework/3rdParty/WsdlGen/Wsdl.php @@ -16,7 +16,7 @@ */ /** - * Contains the dom object used to build up the wsdl. The + * Contains the dom object used to build up the wsdl. The * operations generated by the generator are stored in here until the getWsdl() * method is called which builds and returns the generated XML string. * @author Marcus Nyeholt @@ -29,51 +29,51 @@ class Wsdl * @var string */ private $serviceName; - + /** * The URI to find the service at. If empty, the current * uri will be used (minus any query string) */ private $serviceUri; - + /** * The complex types declarations * @var ArrayObject */ private $types; - - + + /** * A collection of SOAP operations - * @var ArrayObject + * @var array */ - private $operations; - + private $operations=array(); + /** * Wsdl DOMDocument that's generated. */ private $wsdl = null; - + /** * The definitions created for the WSDL */ private $definitions = null; - + /** * The target namespace variable? */ private $targetNamespace =''; - + /** * The binding style (default at the moment) */ private $bindingStyle = 'rpc'; - + /** * The binding uri */ private $bindingTransport = 'http://schemas.xmlsoap.org/soap/http'; - + /** * Creates a new Wsdl thing * @param string $name the name of the service. @@ -87,13 +87,13 @@ class Wsdl $this->types = new ArrayObject(); $this->targetNamespace = 'urn:'.$name.'wsdl'; } - + public function getWsdl() { $this->buildWsdl(); return $this->wsdl; } - + /** * Generates the WSDL file into the $this->wsdl variable */ @@ -105,37 +105,37 @@ class Wsdl xmlns:tns="'.$this->targetNamespace.'" 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:soap-enc="http://schemas.xmlsoap.org/soap/encoding/">'; $dom = DOMDocument::loadXml($xml); $this->definitions = $dom->documentElement; - + $this->addTypes($dom); - + $this->addMessages($dom); $this->addPortTypes($dom); $this->addBindings($dom); $this->addService($dom); - + $this->wsdl = $dom->saveXML(); } - + /** * Adds complexType definitions to the document * @param DomDocument $dom The document to add to */ public function addTypes(DomDocument $dom) { - if (!count($this->types)) return; - $types = $dom->createElement('types'); + if (!count($this->types)) return; + $types = $dom->createElement('types'); $schema = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:schema'); $schema->setAttribute('targetNamespace', $this->targetNamespace); - foreach($this->types as $type => $elements) + foreach($this->types as $type => $elements) { $complexType = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:complexType'); - $complexType->setAttribute('name', $type); + $complexType->setAttribute('name', $type); if(substr($type, strlen($type) - 5, 5) == 'Array') // if it's an array - { + { $complexContent = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:complexContent'); $restriction = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:restriction'); $restriction->setAttribute('base', 'SOAP-ENC:Array'); @@ -144,27 +144,27 @@ class Wsdl $attribute->setAttribute('arrayType', 'tns:' . substr($type, 0, strlen($type) - 5) . '[]'); $restriction->appendChild($attribute); $complexContent->appendChild($restriction); - $complexType->appendChild($complexContent); - } - else + $complexType->appendChild($complexContent); + } + else { $all = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:all'); - foreach($elements as $elem) + foreach($elements as $elem) { $e = $dom->createElementNS('http://www.w3.org/2001/XMLSchema', 'xsd:element'); - $e->setAttribute('name', $elem['name']); + $e->setAttribute('name', $elem['name']); $e->setAttribute('type', $elem['type']); - $all->appendChild($e); + $all->appendChild($e); } $complexType->appendChild($all); - } + } $schema->appendChild($complexType); - $types->appendChild($schema); + $types->appendChild($schema); } - + $this->definitions->appendChild($types); } - + /** * Add messages for the service * @param DomDocument $dom The document to add to @@ -175,7 +175,7 @@ class Wsdl $operation->setMessageElements($this->definitions, $dom); } } - + /** * Add the port types for the service * @param DomDocument $dom The document to add to @@ -184,14 +184,14 @@ class Wsdl { $portType = $dom->createElement('portType'); $portType->setAttribute('name', $this->serviceName.'PortType'); - + $this->definitions->appendChild($portType); foreach ($this->operations as $operation) { $portOperation = $operation->getPortOperation($dom); $portType->appendChild($portOperation); } } - + /** * Add the bindings for the service * @param DomDocument $dom The document to add to @@ -201,20 +201,20 @@ class Wsdl $binding = $dom->createElement('binding'); $binding->setAttribute('name', $this->serviceName.'Binding'); $binding->setAttribute('type', 'tns:'.$this->serviceName.'PortType'); - + $soapBinding = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/soap/', 'soap:binding'); $soapBinding->setAttribute('style', $this->bindingStyle); $soapBinding->setAttribute('transport', $this->bindingTransport); $binding->appendChild($soapBinding); - + $this->definitions->appendChild($binding); - + foreach ($this->operations as $operation) { $bindingOperation = $operation->getBindingOperation($dom, $this->targetNamespace, $this->bindingStyle); $binding->appendChild($bindingOperation); } } - + /** * Add the service definition * @param DomDocument $dom The document to add to @@ -223,20 +223,20 @@ class Wsdl { $service = $dom->createElement('service'); $service->setAttribute('name', $this->serviceName.'Service'); - + $port = $dom->createElement('port'); $port->setAttribute('name', $this->serviceName.'Port'); $port->setAttribute('binding', 'tns:'.$this->serviceName.'Binding'); - + $soapAddress = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/soap/', 'soap:address'); $soapAddress->setAttribute('location', $this->serviceUri); $port->appendChild($soapAddress); - + $service->appendChild($port); - - $this->definitions->appendChild($service); + + $this->definitions->appendChild($service); } - + /** * Adds an operation to have port types and bindings output * @param WsdlOperation $operation The operation to add @@ -245,15 +245,15 @@ class Wsdl { $this->operations[] = $operation; } - + /** * Adds complexTypes to the wsdl * @param string $type Name of the type - * @param Array $elements Elements of the type (each one is an associative array('name','type')) + * @param Array $elements Elements of the type (each one is an associative array('name','type')) */ public function addComplexType($type, $elements) { - $this->types[$type] = $elements; + $this->types[$type] = $elements; } } ?> \ No newline at end of file -- cgit v1.2.3