hi!
is there a way to tell moodle webservice to use a specific wsdl file while generating response?
moodle generates the following code whitout wsdl (snippet)
<ns1:mn_resultWritebackResponse>
<return xsi:type="ns2:Map">
<item>
<key xsi:type="xsd:string">usernames</key>
<value SOAP-ENC:arrayType="xsd:string[2]" xsi:type="SOAP-ENC:Array">
<item xsi:type="xsd:string">user1</item>
<item xsi:type="xsd:string">user2</item>
</value>
</item>
<item>
<key xsi:type="xsd:string">secret</key>
<value xsi:type="xsd:string">hash</value>
</item>
</return>
</ns1:mn_resultWritebackResponse>
and do this way for any array output.
but I want something like this:
<ns1:mn_resultWritebackResponse>
<usernames xsi:type="ns1:usernameList">
<username xsi:type="xsd:string">user1</username>
<username xsi:type="xsd:string">user2</username>
</usernames>
<secret xsi:type="xsd:string">hash</secret>
</ns1:mn_resultWritebackResponse>
which is generated automatically if I enter wsdl file location in lib/Zend/Soap/Server.php line 167:
$wsdl='location/to/wsdl/file.wsdl';
I know that Zend_Soap_Server allow to set wsdl with it's method setWsdl(), but I cannot find any settings in moodle, or any possibility in the webservice 'external_api' and in it's methods.
This option could be set somewhere in webserivce/lib.php line 698, in the public function run, where the zend_soap_server is initalized, if the function or the class (webservice_zend_server and it's derivatives) itself would have such options.e
the corresponding wsdl snippet:
...
<xsd:complexType name="usernameList">
<xsd:sequence>
<xsd:element name="username" type="xsd:string"
maxOccurs="unbounded" />
</xsd:sequence>
</xsd:complexType>
...
<wsdl:message name="resultWritebackResponse">
<wsdl:part name="secret" type="xsd:string" />
<wsdl:part name="usernames" type="tns:usernameList" />
</wsdl:message>
...
and the external_api's _returns() function:
public static function resultWriteback_returns() {
return new external_single_structure(
array('usernames'=>
new external_multiple_structure (
new external_value(PARAM_TEXT,'username')),
'secret'=>new external_value(PARAM_TEXT,'secret')
)
);
}
Any idea? thanks!
Attila