JSON-RPC is a very simple protocol. The namespace of an endpoint is FLAT. There aren't classes exposed (let alone multiple classes) from a single endpoint.
When the CoffeeScript client is calling service1.giveMeSomeData
, it's literally asking the PHP web-service to execute an endpoint method with the name service1.giveMeSomeData
. If your web-service then routes that to the giveMeSomeData
method in an instance of some class currently assigned to the instance Service1
, well that's up to it! (the PHP service side). This is NOT a feature of JSON-RPC, it's something made up by the end-point router you're using.
The equivalent call on the PHP client side might be something like $client->call('Service1.giveMeSomeData', array('name'))
It depends on the JSON-RPC library you use. Some PHP client libraries construct an instance of an ad-hoc class, which implements the PHP __call
method, such that any un-recognised method names are re-directed as calls to the generic RPC call method in that class.
To be clear, there are not multiple namespaces being served from the JSON-RPC endpoint, just a single flat namespace which can include methods with .
(dot) characters in their names. How your web-service endpoint routes those calls to PHP functions/methods is completely up to you/it.
PS. You'll get much better help if you explain what client & server libraries you're using in PHP for JSON-RPC (there are many, of varying quality and completeness).