PHP Class Prado\Web\Services\TRpcService
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 {@link TModule} that must subclass {@link TRpcServer}: its role is
to be an intermediate, moving data between the service and the provider. The base
{@link 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 {@link TModule} that must subclass {@link TRpcProtocol}: its role is
to implement the protocol that exposes the rpc api. Prado already implements two
protocols: {@link TXmlRpcProtocol} for Xml-Rpc request and {@link TJsonRpcProtocol} for
JSON-Rpc requests.
A provider is a {@link TModule} that must subclass {@link 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 {@link 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:
An api can be registered adding a proper
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.
Mostra file
Open project: pradosoft/prado
Protected Properties
Property |
Type |
Description |
|
$apiProviders |
|
containing API provider and their configured properties |
|
$protocolHandlers |
|
containing mimetype to protocol handler mappings |
|
Public Methods
Method |
Description |
|
createApiProvider ( TRpcProtocol $protocolHandler, string $providerId ) |
Creates the API provider instance for the current request |
|
init ( TXmlElement $config ) |
Initializes the service |
|
loadConfig ( TXmlElement $xml ) |
Loads the service configuration |
|
run ( ) |
Runs the service |
|
Method Details
createApiProvider()
public method
Creates the API provider instance for the current request
public init ( TXmlElement $config ) |
$config |
Prado\Xml\TXmlElement |
containing the module configuration |
loadConfig()
public method
Loads the service configuration
public loadConfig ( TXmlElement $xml ) |
$xml |
Prado\Xml\TXmlElement |
configuration |
Property Details
$apiProviders protected_oe property
containing API provider and their configured properties
$protocolHandlers protected_oe property
containing mimetype to protocol handler mappings
protected $protocolHandlers |