Prev | Current Page 306 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"

./../application/bootstrap.php';
$bootstrap = new Bootstrap('general'); A
$bootstrap->runXmlRpc(); B
A Set the configuration section to use
B Run the xmlrpc function in the bootstrap
Having got all that together we??™re now finally able to get to the main topic of this section; using
Zend_XmlRpc_Server. Listing 11.4 shows a stripped down version of the contents of the bootstrap file which
includes the runXmlRpc() method that was called from our index.php file.
Listing 11.4 Zend_XmlRpc_Server used in our bootstrap file
class Bootstrap
{
public function __construct($deploymentEnvironment)
{
// Set up any configuration settings here A
}
public function runXmlRpc()
{
$server = new Zend_XmlRpc_Server(); B
require_once 'Blogger.php'; C
require_once 'Metaweblog.php';
require_once 'MovableType.php';
$server->setClass('Blogger', 'blogger'); D
$server->setClass('Metaweblog', 'metaWeblog');
$server->setClass('MovableType', 'mt');
$response = $server->handle(); E
$response->setEncoding('UTF-8'); F
header('Content-Type: text/xml; charset=UTF-8');
echo $response; G
}
}
A Application initialisation occurs here
B Initialise the XML-RPC server
C Include any class files that will be attached to the server
D Attach class methods as XMLRPC method handlers together with their namespaces
E Handle the remote procedure call
F Set the character encoding of the response and echo that when setting the HTTP header string
G Output the response
We??™ve intentionally left out the contents of the constructor in this example but have included the method
to show where things like introducing configuration settings, setting include paths, establishing a database
connection and any other application specific initialisation would occur.


Pages:
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318
zakłady bukmacherskie Wczasy nad morzem oferty spa Spa Ciechocinek kolokacja rack