views:

192

answers:

1

Hi

I'm currently using Zend_Soap_AutoDiscover to generate my WSDL file, the problem is I want this wsdl to handle output of type ArrayOfString ( string[] ). so I changed the complex type strategy to Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence, it works properly but the problem is that the output isn't really an array of string the output xml is somthing like this :

<xsd:complexType name="ArrayOfString">
    <xsd:sequence>
        <xsd:element name="item" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:sequence>
</xsd:complexType>

But I want output like this :

<xsd:complexType name="ArrayOfstring">
    <xsd:complexContent>
        <xsd:restriction base="soapenc:Array">
            <xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]"/>
        </xsd:restriction>
    </xsd:complexContent>
</xsd:complexType>

so ,I used the new strategy , Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex, but the problem is that this strategy does not handle string[].

Finally -> What should I do :D?!

A: 

Try creating a response class that has just one attribute, as follows:

class Response
{
    /** @var string[] */
    public $items;
}

Then define your service class to return an object of type Response, as follows:

class Service
{
    /**
     * @param string
     * @return Response
     */
    public function process( $input )
    {
        $response = new Response();
        // Populate $response->items[] object with strings...
        return $response;
    }
}

Then use the 'Zend_Soap_Wsdl_Strategy_ArrayOfTypeComplex' strategy when using Zend_Soap_Autodiscover to create the WSDL. Although this probably won't produce precisely the output you're after, it should produce something that is semantically closer than what you're currently getting. The key with this approach is to get the PHPDoc right.

If that still doesn't work, post the key bits of your code, as that will help resolve the issue more quickly.

JamesG