Class TRpcService
TRpcService class
The TRpcService class is a generic class that can be extended and used to implement rpc services using different servers and protocols.
A server is a TModule
that must subclass TRpcServer
: its role
is to be an intermediate, moving data between the service and the provider. The
base TRpcServer
class should suit the most common needs, but can be
sublassed for logging and debugging purposes, or to filter and modify the
request/response on the fly.
A protocol is a TModule
that must subclass TRpcProtocol
: its
role is to implement the protocol that exposes the rpc api. Prado already
implements two protocols: TXmlRpcProtocol
for Xml-Rpc request and TJsonRpcProtocol
for JSON-Rpc requests.
A provider is a TModule
that must subclass TRpcApiProvider
:
its role is to implement the methods that are available through the api. Each
defined api must be a sublass of the abstract class TRpcApiProvider
and
implement its methods.
The flow of requests and reponses is the following: Request <-> TRpcService <-> TRpcServer <-> TRpcProtocol <-> TRpcApiProvider <-> Response
To define an rpc service, add the proper application configuration:
<service id="rpc" class="System.Web.Services.TRpcService"> <rpcapi id="customers" class="Application.Api.CustomersApi" /> <modules> <!-- register any module needed by the service here --> </modules> </service>
An api can be registered adding a proper <rpcapi ..> definition inside the service configuration. Each api definition must contain an id property and a class name expressed in namespace format. When the service receives a request for that api, the specified class will be instanciated in order to satisfy the request.
- TComponent
-
TApplicationComponent
-
TService implements IService
-
TRpcService
Copyright: 2010 Bigpoint GmbH
License: http://www.pradosoft.com/license/
Author: Robin J. Rogge <rrogge@bigpoint.net>
Version: $Id$
Since: 3.2
Located at Web/Services/TRpcService.php
public
|
#
createApiProvider(
Creates the API provider instance for the current request |
public
|
|
public
|
|
public
|
getEnabled(),
getID(),
setEnabled(),
setID()
|
getApplication(),
getRequest(),
getResponse(),
getService(),
getSession(),
getUser(),
publishAsset(),
publishFilePath()
|
string |
BASE_API_PROVIDER |
'TRpcApiProvider' |
#
const string base api provider class which every API must extend |
string |
BASE_RPC_SERVER |
'TRpcServer' |
#
const string base RPC server implementation |
GLOBAL_RAISE_EVENT_LISTENER
|
protected
array
|
$protocolHandlers | array(
'application/json' => 'TJsonRpcProtocol',
'text/xml' => 'TXmlRpcProtocol'
) |
#
containing mimetype to protocol handler mappings |
protected
array
|
$apiProviders | array() |
#
containing API provider and their configured properties |