Re: [SOAP] Sample Server Code Please
| From: | Shane Caraveo | Date: | Sun, 18 May 2003 01:45:06 +0000 |
| Subject: | Re: [SOAP] Sample Server Code Please | ||
| References: | 1 | Groups: | php.soap |
| Request: | Send a blank email to php-soap+get-598@lists.php.net to get a copy of this message | ||
David Busby wrote:
List,Here's a simple script to show how to produce arrays of objects. This isn't server code, but it's done the same way. include 'SOAP/Client.php'; class Person {I'm looking for a sample of how to return an array of object/datasets.Heres what I mean <array:(......)> <item1><id>1</id> <name>Jean</name></item1> <item2><id>8</id> <name>James</name></item> </array> Like that...ideas/samples?
var $id;
var $name;
function Person($id=0, $name='') {
$this->id = $id;
$this->name = $name;
}
}
# with the type People defined in schema
$people = array(
new SOAP_Value('item','{urn:MySchema}Person',new Person(0,'shane')),
new SOAP_Value('item','{urn:MySchema}Person',new Person(1,'beth'))
);
$sval = new SOAP_Value('myarray',NULL,$people);
$base = new SOAP_Base();
$x = $sval->serialize($base);
print $x;
# without the type People defined in schema
$people = array(
new Person(0,'shane'),
new Person(1,'beth')
);
$sval = new SOAP_Value('myarray',NULL,$people);
$base = new SOAP_Base();
# set this to true if you want client/server to use
# PHP classes when deserializing
$base->_auto_translation = true;
$x = $sval->serialize($base);
print $x;