예제 #1
0
 /**
  * Generate the WSDL
  *
  */
 public function createWSDL()
 {
     $this->classes = $this->PHPParser->getClasses();
     foreach ($this->classes as $class => $methods) {
         $pbs = array();
         ksort($methods);
         foreach ($methods as $method => $components) {
             if ($components["type"] == "public" || $components["type"] == "") {
                 if (array_key_exists("params", $components)) {
                     $this->createMessage($method, $components["returnType"], $components["params"]);
                 } else {
                     $this->createMessage($method, $components["returnType"]);
                 }
                 $pbs[$class][$method]["documentation"] = $components["description"];
                 $pbs[$class][$method]["input"] = $method;
                 $pbs[$class][$method]["output"] = $method;
             }
         }
         $this->createPortType($pbs);
         $this->createBinding($pbs);
         $this->createService($pbs);
     }
     // adding typens
     foreach ($this->typens as $typenNo => $url) {
         $this->WSDLXML->setAttribute("xmlns:" . $typenNo, $url);
     }
     // add types
     if (is_array($this->typensDefined) && count($this->typensDefined) > 0) {
         $types = new XMLCreator("types");
         $xsdSchema = new XMLCreator("xsd:schema");
         $xsdSchema->setAttribute("xmlns", "http://www.w3.org/2001/XMLSchema");
         $xsdSchema->setAttribute("targetNamespace", "urn:" . $this->name);
         $vars = $this->PHPParser->getClassesVars();
         foreach ($this->typensDefined as $typensDefined) {
             $complexType = new XMLCreator("xsd:complexType");
             $complexType->setAttribute("name", $typensDefined);
             $all = new XMLCreator("xsd:all");
             if (isset($vars[$typensDefined]) && is_array($vars[$typensDefined])) {
                 ksort($vars[$typensDefined]);
                 foreach ($vars[$typensDefined] as $varName => $varType) {
                     $element = new XMLCreator("xsd:element");
                     $element->setAttribute("name", $varName);
                     $varType = isset($this->xsd[$varType]) ? "xsd:" . $this->xsd[$varType] : "anyType";
                     $element->setAttribute("type", $this->xsd[$varType]);
                     $all->addChild($element);
                 }
             }
             $complexType->addChild($all);
             $xsdSchema->addChild($complexType);
         }
         $types->addChild($xsdSchema);
         $this->WSDLXML->addChild($types);
     }
     // adding messages
     foreach ($this->messages as $message) {
         $this->WSDLXML->addChild($message);
     }
     // adding port types
     foreach ($this->portTypes as $portType) {
         $this->WSDLXML->addChild($portType);
     }
     // adding bindings
     foreach ($this->bindings as $binding) {
         $this->WSDLXML->addChild($binding);
     }
     // adding services
     $s = new XMLCreator("service");
     $s->setAttribute("name", $this->name . "Service");
     foreach ($this->services as $service) {
         $s->addChild($service);
     }
     $this->WSDLXML->addChild($s);
     $this->WSDL = "<?xml version='1.0' encoding='UTF-8'?>\n";
     $this->WSDL .= "<!-- WSDL file generated by PHP WSDLCreator (http://www.protung.ro) -->\n";
     $this->WSDL .= $this->WSDLXML->getXML();
 }