-
Notifications
You must be signed in to change notification settings - Fork 25
Description
Hi Dragos,
sorry for opening a new issue, but I don't found your contact email, otherwise I had contacted you directly. First, thanks for your fast support. Unfortunately your changes don't work for my scenario.
Now arrays of basic data types are not resulting in complex types anymore, as they are handled as basic array.
<message name="testMethodIn">
<part name="para1" type="soap-enc:Array"/>
<part name="para2" type="soap-enc:Array"/>
</message>
<message name="testMethodOut">
<part name="return" type="soap-enc:Array"/>
</message>That's ok for php and his dynamic typing, but are more strict languages would like to know what data type is stored within the array.
My corresponding method for this example:
/**
* @param string[] $para1
* @param bool[] $para2
* @return string[]
*/
public function testMethod($para1, $para2){
return array("ret1","ret2");
}I think the resulting wsdl parts It should look something like that:
- the data definition
<xsd:complexType name="ArrayOfString">
<xsd:complexContent>
<xsd:restriction base="soap-enc:Array">
<xsd:attribute ref="soap-enc:arrayType" wsdl:arrayType="xsd:string[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
<xsd:complexType name="ArrayOfBool">
<xsd:complexContent>
<xsd:restriction base="soap-enc:Array">
<xsd:attribute ref="soap-enc:arrayType" wsdl:arrayType="xsd:bool[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>- the message definitions
<message name="testMethodIn">
<part name="para1" type="tns:ArrayOfString"/>
<part name="para2" type="tns:ArrayOfBool"/>
</message>
<message name="testMethodOut">
<part name="return" type="tns:ArrayOfString"/>
</message>I have changed the addComplexTypeArray method to achieve this.
protected function addComplexTypeArray($singularType, $type)
{
$isBasicDataType = isset(self::$XSDTypes[strtolower($singularType)]);
$nsPrefix = $isBasicDataType ? 'xsd' : 'tns';
$xsdComplexTypeName = 'ArrayOf' . ucfirst(static::typeToQName($singularType));
$xsdComplexType = 'tns:' . $xsdComplexTypeName;
// Register type here to avoid recursion.
$this->addType($type, $xsdComplexType);
// Process singular type using DefaultComplexType strategy.
if(!$isBasicDataType){
$this->addComplexType($singularType);
}
// Add array type structure to WSDL document.
$complexType = $this->dom->createElement('xsd:complexType');
$complexType->setAttribute('name', $xsdComplexTypeName);
$complexContent = $this->dom->createElement('xsd:complexContent');
$complexType->appendChild($complexContent);
$xsdRestriction = $this->dom->createElement('xsd:restriction');
$xsdRestriction->setAttribute('base', 'soap-enc:Array');
$complexContent->appendChild($xsdRestriction);
$xsdAttribute = $this->dom->createElement('xsd:attribute');
$xsdAttribute->setAttribute('ref', 'soap-enc:arrayType');
$xsdAttribute->setAttribute('wsdl:arrayType', $nsPrefix.':' . static::typeToQName($singularType) . '[]');
$xsdRestriction->appendChild($xsdAttribute);
$this->schema->appendChild($complexType);
return $xsdComplexType;
}Hopefully it also works as desired with objects.
If you have any example for an object, that is not working properly with this changes feel free to inform me.