I use Zend_Soap_Server and Zend_Soap_Client. I send / receive an array of complex structure.
First create a class with the structure you want to get.
<?php class PeopleInformation { public $name; public $age; public $family; } class FamilyInformation { public $relation; public $name; } ?>
Then create a service to get this data:
<?php class SoapService { public function getUserData($data) {
Now create an instance of Zend_Soap_Server in the controller at the URL http: // ourhost / soap / :
<?php //disable wsdl caching ini_set('soap.wsdl_cache_enabled', 0); ini_set('soap.wsdl_cache', 0); $wsdl = $_GET['wsdl']; //this generate wsdl from our class SoapService if (!is_null($wsdl)) { $autodiscover = new Zend_Soap_AutoDiscover('Zend_Soap_Wsdl_Strategy_ArrayOfTypeSequence'); $autodiscover->setClass('SoapService'); $autodiscover->handle(); } //handle all soap request else { $wsdlPath = 'http://ourhost/soap/?wsdl'; $soap = new Zend_Soap_Server($wsdlPath, array( 'cache_wsdl' => false )); $soap->registerFaultException('Zend_Soap_Server_Exception'); $soap->setClass('SoapService'); $soap->handle(); } ?>
And now you get wsdl (http: // ourhost / soap /? Wsdl) with your structure and processing request in SoapService :: getUserData. The input parameter in this method is an object of the PeopleInformation class.
source share