Esempio n. 1
0
 /**
  * @return string The WSDL document for this structure
  */
 public function generateDocument()
 {
     $this->addToDebug("Generating document");
     //add all definitions
     $definitions = $this->definitions;
     $definitions->setAttribute("xmlns", self::NS_WSDL);
     $definitions->setAttribute("xmlns:soap", self::NS_SOAP);
     $definitions->setAttribute("xmlns:SOAP-ENC", self::NS_ENC);
     $definitions->setAttribute("xmlns:wsdl", self::NS_WSDL);
     $definitions->setAttribute("xmlns:xsd", self::NS_XSD);
     $definitions->setAttribute("xmlns:apache", self::NS_APACHE);
     $definitions->setAttribute("xmlns:tns", $this->tns);
     $definitions->setAttribute("targetNamespace", $this->tns);
     //add all the services
     foreach ((array) $this->services as $serviceName => $service) {
         //add the portType
         $portType = $this->addPortType($serviceName);
         //add binding
         $binding = $this->addBinding($serviceName);
         //loop the operations
         foreach ((array) $service->methods as $operation) {
             $operationName = $operation->name;
             $operationTag = $this->addOperation($operationName, $serviceName);
             //input
             //only when to operation needs arguments
             $parameters = $operation->getParameters();
             if (count($parameters) > 0 || self::CREATE_EMPTY_INPUTS) {
                 $messageName = $operationName . "Request";
                 $input = $this->addElement("wsdl:input", $operationTag);
                 $input->setAttribute("message", "tns:" . $messageName);
                 $para = array();
                 foreach ((array) $parameters as $parameterName => $parameter) {
                     $para[$parameterName] = $parameter->type;
                 }
                 $this->addMessage($messageName, $para);
                 $this->addInput($this->bindingOperationTags[$serviceName][$operationName]);
             }
             //output
             //only when the operation returns something
             if (!$operation->return || trim($operation->return) == "") {
                 throw new WSDLException('No return type for ' . $operationName);
             }
             if (strtolower(trim($operation->return)) != 'void') {
                 $messageName = $operationName . "Response";
                 $output = $this->addElement("wsdl:output", $operationTag);
                 $output->setAttribute("message", "tns:" . $messageName);
                 $this->addOutput($this->bindingOperationTags[$serviceName][$operationName]);
                 $this->addMessage($messageName, array($operation->name . "Return" => $operation->return));
             }
         }
         // SH. now add the portType and binding
         $this->definitions->AppendChild($portType);
         $this->definitions->AppendChild($binding);
         //add the service
         $this->addService($serviceName);
     }
     return $this->doc->saveXML();
 }
Esempio n. 2
0
/**
 * @name getArray
 * @desc Converts a domElement into an array
 * @param domelement $node
 * @return array OR false
 */
function getArray($node)
{
    $array = false;
    if ($node->hasAttributes()) {
        foreach ($node->attributes as $attr) {
            $array[$attr->nodeName] = $attr->nodeValue;
        }
    }
    if ($node->hasChildNodes()) {
        if ($node->childNodes->length == 1) {
            $array[$node->firstChild->nodeName] = $node->firstChild->nodeValue;
        } else {
            foreach ($node->childNodes as $childNode) {
                if ($childNode->nodeType != XML_TEXT_NODE) {
                    $array[$childNode->nodeName][] = getArray($childNode);
                }
            }
        }
    }
    return $array;
}