soap code
| From: | Rudi Starcevic | Date: | Tue, 10 Sep 2002 11:04:15 +0000 |
| Subject: | soap code | ||
| Groups: | php.soap | ||
| Request: | Send a blank email to php-soap+get-243@lists.php.net to get a copy of this message | ||
Hello,
I have some very simple client and server code I would like your
opinion of please.
It's based 100% on the SOAP code from Pear.
It's all working very well.
But I'm wondering if I've chopped out too much.
For now I just want a very simple call that returns an xml packet.
I don't have any namespace set in my client code. Is this Bad ?
Here is my client code:
$soapclient = new SOAP_Client("http://192.186.0.2/soap/demo/server1.php");
$ret = $soapclient->call("getStatsAll");
print_r($ret);echo "<br>\n";
Here is my server code :
$server = new SOAP_Server;
// create a class for soap functions
class SOAP_Example_Server {
var $method_namespace = 'urn:SOAP_Example_Server';
function SOAP_Example_Server() {
$this->dispatch_map['echoStructAsSimpleTypes'] =
array(
'in' => array('inputStruct' => 'SOAPStruct'),
'out' => array('outputString' => 'string',
'outputInteger' => 'int', 'outputFloat' => 'float')
);
}
// a simple function
function getStatsAll()
{
return "<stats><stat>Rudi is cool.</stat></stats>";
)
}
$soapclass = new SOAP_Example_Server();
$server->addObjectMap($soapclass);
$server->service($HTTP_RAW_POST_DATA);
It all works very well. I'm just wondering if it's too simple and I've
chopped out something important.
Is it correct that the SOAP_Example_Server() function is the only function
I must have ?
Thanks
Rudi.