From 6dae236ec5528522de472637f9d70a98158b9a5d Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Thu, 5 Feb 2015 11:45:26 +0100 Subject: Renamed 3rdparty directory to vendor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Php namespaces can’t begin with a number --- framework/Vendor/WsdlGen/WsdlOperation.php | 135 +++++++++++++++++++++++++++++ 1 file changed, 135 insertions(+) create mode 100644 framework/Vendor/WsdlGen/WsdlOperation.php (limited to 'framework/Vendor/WsdlGen/WsdlOperation.php') diff --git a/framework/Vendor/WsdlGen/WsdlOperation.php b/framework/Vendor/WsdlGen/WsdlOperation.php new file mode 100644 index 00000000..91adbda4 --- /dev/null +++ b/framework/Vendor/WsdlGen/WsdlOperation.php @@ -0,0 +1,135 @@ + + * @author Wei Zhuo + * @package System.Web.Services.SOAP + */ + +/** + * Represents a WSDL Operation. This is exported for the portTypes and bindings + * section of the soap service + * @author Marcus Nyeholt + * @author Wei Zhuo + * @version $Revision$ + */ +class WsdlOperation +{ + /** + * The name of the operation + */ + private $operationName; + + /** + * Documentation for the operation + */ + private $documentation; + + /** + * The input wsdl message + */ + private $inputMessage; + + /** + * The output wsdl message + */ + private $outputMessage; + + public function __construct($name, $doc='') + { + $this->operationName = $name; + $this->documentation = $doc; + } + + public function setInputMessage(WsdlMessage $msg) + { + $this->inputMessage = $msg; + } + + public function setOutputMessage(WsdlMessage $msg) + { + $this->outputMessage = $msg; + } + + /** + * Sets the message elements for this operation into the wsdl document + * @param DOMElement $wsdl The parent domelement for the messages + * @param DomDocument $dom The dom document to create the messages as children of + */ + public function setMessageElements(DOMElement $wsdl, DOMDocument $dom) + { + + $input = $this->inputMessage->getMessageElement($dom); + $output = $this->outputMessage->getMessageElement($dom); + + $wsdl->appendChild($input); + $wsdl->appendChild($output); + } + + /** + * Get the port operations for this operation + * @param DomDocument $dom The dom document to create the messages as children of + * @return DomElement The dom element representing this port. + */ + public function getPortOperation(DomDocument $dom) + { + $operation = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:operation'); + $operation->setAttribute('name', $this->operationName); + + $documentation = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:documentation', htmlentities($this->documentation)); + $input = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:input'); + $input->setAttribute('message', 'tns:'.$this->inputMessage->getName()); + $output = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:output'); + $output->setAttribute('message', 'tns:'.$this->outputMessage->getName()); + + $operation->appendChild($documentation); + $operation->appendChild($input); + $operation->appendChild($output); + + return $operation; + } + + /** + * Build the binding operations. + * TODO: Still quite incomplete with all the things being stuck in, I don't understand + * a lot of it, and it's mostly copied from the output of nusoap's wsdl output. + * @param DomDocument $dom The dom document to create the binding as children of + * @param string $namespace The namespace this binding is in. + * @return DomElement The dom element representing this binding. + */ + public function getBindingOperation(DomDocument $dom, $namespace, $style='rpc') + { + $operation = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:operation'); + $operation->setAttribute('name', $this->operationName); + + $soapOperation = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/soap/', 'soap:operation'); + $method = $this->operationName; + $soapOperation->setAttribute('soapAction', $namespace.'#'.$method); + $soapOperation->setAttribute('style', $style); + + $input = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:input'); + $output = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/', 'wsdl:output'); + + $soapBody = $dom->createElementNS('http://schemas.xmlsoap.org/wsdl/soap/', 'soap:body'); + $soapBody->setAttribute('use', 'encoded'); + $soapBody->setAttribute('namespace', $namespace); + $soapBody->setAttribute('encodingStyle', 'http://schemas.xmlsoap.org/soap/encoding/'); + $input->appendChild($soapBody); + $output->appendChild(clone $soapBody); + + $operation->appendChild($soapOperation); + $operation->appendChild($input); + $operation->appendChild($output); + + return $operation; + } +} -- cgit v1.2.3