Index: Wsdl.php =================================================================== --- Wsdl.php (revision 11217) +++ Wsdl.php (working copy) @@ -430,12 +430,57 @@ 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); + + $sequence = $this->_dom->createElement('xsd:sequence'); + + $element = $this->_dom->createElement('xsd:element'); + $element->setAttribute('name', 'item'); + $element->setAttribute('type', $singulartype); + $element->setAttribute('minOccurs', 0); + $element->setAttribute('maxOccurs', 'unbounded'); + $sequence->appendChild($element); + + $complexType->appendChild($sequence); + $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