Index: Soap/Wsdl.php =================================================================== --- Soap/Wsdl.php (revision 11094) +++ Soap/Wsdl.php (working copy) @@ -363,6 +363,7 @@ */ public function toXML() { + $this->_dom->formatOutput = true; return $this->_dom->saveXML(); } @@ -430,12 +431,59 @@ default: if (class_exists($type) && $this->_extractComplexTypes) return $this->addComplexType($type); + + if (substr($type, -1) == ']' and $this->_extractComplexTypes) + return $this->addComplexTypeArray($type); else return 'xsd:anyType'; } } /** + * Add a {@link http://www.w3.org/TR/wsdl#_types types} data type definition (for arrays) + * + * Specify return types with brackets. E.g. "string[]" or "User[]" + * + * @param string $type Name of the array type to be specified, including [] + * @return string XSD Type for the given PHP type + */ + public function addComplexTypeArray($type) + { + if (preg_match('/^(.*)\[\]$/i', $type, $matches)) { + + $singulartype = $this->getType($matches[1]); + + $wsdltype = substr($singulartype, 4) . 'Array'; // strip prefix + + if (!in_array($type, $this->_includedTypes)) { + + $complexType = $this->_dom->createElement('xsd:complexType'); + $complexType->setAttribute('name', $wsdltype); + + $complexContent = $this->_dom->createElement('xsd:complexContent'); + $complexType->appendChild($complexContent); + + $restriction = $this->_dom->createElement('xsd:restriction'); + $restriction->setAttribute('base', 'soap-enc:Array'); + $complexContent->appendChild($restriction); + + $attribute = $this->_dom->createElement('xsd:attribute'); + $attribute->setAttribute('ref', 'soap-enc:arrayType'); + $attribute->setAttribute('arrayType', $singulartype . '[]'); + $restriction->appendChild($attribute); + + $this->_schema->appendChild($complexType); + + $this->_includedTypes[] = $type; + } + + return "tns:$wsdltype"; + } + + return "xsd:anyType"; + } + + /** * Add a {@link http://www.w3.org/TR/wsdl#_types types} data type definition * * @param string $type Name of the class to be specified