Returning an array of complex type in SOAP
| From: | Ville Mattila | Date: | Mon, 17 Jul 2006 15:52:37 +0000 |
| Subject: | Returning an array of complex type in SOAP | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-24668@lists.php.net to get a copy of this message | ||
Hello there,
I'm learning to build a web service with the excellent SOAP Package.
However, I can't get my server class to return an array of a complex
custom defined type. In the returning XML the arrayType is set
"anyType[]" even (in my opinion) it should be myType[]. In this case,
myType should be phoneBookEntry.
I have attached my test class and the response of the class in the end
of this message.
Any help would be nice! =)
Thanks,
Ville
===============================================
My test service class in server side follows:
===
define(TNS, 'phoneBookTest');
class testService {
var $__dispatch_map = array();
var $__typedef = array();
function __construct() {
$this->__dispatch_map = array(
'search' => array(
'in' => array(
'name' => 'string'
),
'out' => array(
'return' => '{urn:'.TNS.'}searchResults'
)
),
);
$this->__typedef = array(
'phoneBookEntry' => array(
'name' => 'string',
'phone' => 'string'
),
'searchResults' => array(
array('{urn:'.TNS.'}phoneBookEntry')
//array('string')
),
);
}
function search($searchString) {
$s = new SOAP_Value('{urn:'.TNS.'}phoneBookEntry',false,
array(
'name' => 'Ville Mattila',
'phone' => '+358-40-8497506'
)
);
return array($s);
}
}
===
The response XML looks like this (only part of it is pasted):
<ns4:searchResponse>
<return xsi:type="SOAP-ENC:Array" SOAP-ENC:arrayType="xsd:anyType[1]"
SOAP-ENC:offset="[0]">
<ns4:phoneBookEntry>
<name xsi:type="xsd:string">Ville Mattila</name>
<phone
xsi:type="xsd:string">+358-40-8497506</phone></ns4:phoneBookEntry></return></ns4:searchResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>