Hi forum members,
I've been creating a service layer for an application ...
I need to send an array of structures with data from the server side to the client side.
Please, take a 5 minutes read my code!
//Create the server instance
$server = new soap_server;
//Initialize WSDL support
$server->configureWSDL('cac', 'urn:cac');
$server->register(
'query',
array('request'=>'xsd:string'),
array('return' => 'tns:CacSoapQueryResult'),
'urn:cac',
'urn:cac#query',
'rpc',
'encoded',
'Process a request and execute queries on CAC server'
);
$server->wsdl->addComplexType(
'CacSoapQueryResult',
'complexType',
'struct',
'all',
'',
array(
'recordSet' => array(
'name' => 'recordSet',
'type' => 'tns:ArrayOfCacSoapRecord'),
)
);
$server->wsdl->addComplexType(
'ArrayOfCacSoapRecord',
'complexType',
'array',
'',
'SOAP-ENC:Array',
array(),
array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'tns:CacSoapRecord[]')),
'tns:CacSoapRecord'
);
$server->wsdl->addComplexType(
'CacSoapRecord',
'complexType',
'struct',
'all',
'',
array(
'uid' => array(
'name' => 'uid',
'type' => 'xsd:string'),
'username' => array(
'name' => 'username',
'type' => 'xsd:string'),
'mail' => array(
'name' => 'mail',
'type' => 'xsd:string'),
)
); |
The problem is this:
When I try to send an array with data from the server, the client get this:
Response not of type text / xml: text / html,
When the array is empty, no problems. the client gets:
Array { } , and the rest...
The function that provide the data, is ok and tested.
My question:
Why is this happening if the definition of data types is correct?
Thanks for your help!!!