note 103870 deleted from class.soapserver by danbrown
| From: | danbrown@php.net | Date: | Mon, 09 May 2011 16:58:00 +0000 |
| Subject: | note 103870 deleted from class.soapserver by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-179566@lists.php.net to get a copy of this message | ||
Note Submitter: Javier Romero
----
This is to answer bug report: 36155
You can create an Abstract Soap Server by creating a class with the magic method __class() to handle
any request.
Of course, this isn't ideal in a web service world but it's a possible.
SERVER (AbstractSoap.php)
==================
<?php
// class
class AbstractSoap {
function __call($name, $args)
{
return array('Operation'=>$name, 'Arguments' => $args);
}
}
// start server
$server = new SoapServer(null, array('uri'=>'http://jromero.me/AbstractSoap'));
$server->setClass("AbstractSoap");
$server->handle();
?>
CLIENT (client.AbstractSoap.php)
==================
<?php
$client = new SoapClient(null,array(
"uri" => "http://jromero.me/AbstractSoap",
"location" => "http://someurl.com/AbstractSoap.php",
"trace" => 1,
"soap_version" => SOAP_1_1,
"exceptions" => 0)
);
$Authentication = new stdClass();
$Authentication->Username = 'user';
$Authentication->Password = 'password';
$Person = new stdClass();
$Person->FirstName = 'Javier';
$Person->LastName = 'Romero';
$response = $client->AddAccount($Authentication,$Person);
print_r($response);
?>