public function getType() { if ($this->isComplexType) { if (WsdlType::isArrayTypeClass($this->type)) { return "tns:" . WsdlType::getArrayComplexTypeName($this->type); } return "tns:" . $this->type; } return "xsd:" . $this->type; }
public function classToWsdl() { $className = $this->getClassName(); // Get the Methods from the Class $wsdlMethods = $this->getMethods($className); // Find the Complex Types $complexTypes = WsdlType::getComplexTypes($wsdlMethods); foreach ($complexTypes as &$complexType) { $this->addComplexType($complexType); } // Add Methods to the WSDL File foreach ($wsdlMethods as $wsdlMethod) { if (!$wsdlMethod->getIsHeader()) { $this->addMethod($wsdlMethod); } } $this->doCreateWsdl(); return $this->saveXML(); }
public function createWsdl($classFileName, $nameSpaceUrl, $wsdlFile = null, $endPoint = null) { // Require the Class we are Parsing require_once $classFileName; $this->classDir = dirname($classFileName); // Strip Extension to get Class Name $this->className = $classFileName; $this->className = basename($this->className, ".inc"); $this->className = basename($this->className, ".php"); print "Creating Wsdl for Class: {$this->className}\n"; // Calculate the EndPoint for this service $this->endPoint = $nameSpaceUrl . $endPoint; if (!$endPoint) { $this->endPoint = $nameSpaceUrl . $this->className . ".php"; } // Get the WSDL File Name if (!$wsdlFile) { $wsdlFile = $this->className . ".wsdl"; } // Create a WSDL File $wsdl = new WsdlWriter($wsdlFile, $nameSpaceUrl, $this->endPoint); // Get the Methods from the Class $wsdlMethods = $this->getMethods(); // Find the Complex Types $complexTypes = WsdlType::getComplexTypes($wsdlMethods); foreach ($complexTypes as &$complexType) { $wsdl->addComplexType($complexType); } // Add Methods to the WSDL File foreach ($wsdlMethods as $wsdlMethod) { $wsdl->addMethod($wsdlMethod); } // Write it to Disk $wsdl->save(); return $wsdl->saveXML(); }
/** * Add a WSDL Complex Array Type to the Document * * Creates an Array Complex Type which references another Complex Type * * @param WsdlType $wsdlType The Type to Add * @return void */ private function addArrayType(WsdlType &$wsdlType) { // Create the WSDL Complex Content $complexContent = $this->createElement("complexContent"); // Create WSDL Attribute $attribute = $this->createElement("attribute"); $attribute->setAttribute("ref", "soapenc:arrayType"); if (WsdlType::isPrimitiveType($wsdlType->getBaseName())) { $attribute->setAttribute("wsdl:arrayType", "xsd:" . $wsdlType->getArrayTypeName()); } else { $attribute->setAttribute("wsdl:arrayType", "tns:" . $wsdlType->getArrayTypeName()); } // Create WSDL Restriction $restriction = $this->createElement("restriction"); $restriction->setAttribute("base", "soapenc:Array"); // Create the WSDL ComplexType $complexType = $this->createElement("complexType"); $complexType->setAttribute("name", $wsdlType->getName()); // Create the WSDL XML Nesting... $restriction->appendChild($attribute); $complexContent->appendChild($restriction); $complexType->appendChild($complexContent); // Append the Type WSDL To the WSDL Schema $wsdlSchema = $this->getSchema(); $wsdlSchema->appendChild($complexType); }