Module jsonrpc
Provides an JSON-RPC imlementation. It is very similar to the xmlrpc module and shares almost the same interface.public members:▲
InvalidServerResponse()
Exception thrown if a server did not respond with response status 200 (OK).
MalformedJSONRpc()
Exception thrown if an XML-RPC response is not well formed.
JSONRPCError()
Exception thrown if the RPC response is a Fault.
- JSONRPCError::error The error object returned by the rpc call.
marshall(obj)
Marshalls an object to JSON.(see http://json.org)
It just calls the toJSON function of the objcect if it has such method.
So, to customize serialization of objects one just needs to specify/override the toJSON method which should return a string conforming with the JSON spec.
obj The object to marshall
returns An JSON representation of the object.
It just calls the toJSON function of the objcect if it has such method.
So, to customize serialization of objects one just needs to specify/override the toJSON method which should return a string conforming with the JSON spec.
obj The object to marshall
returns An JSON representation of the object.
unmarshall(xml)
Unmarshalls a JSON document to a JavaScript object.
It parses the JSON source and creates a JavaScript object.
xml The source to unmarshall.
returns The JavaScript object created.
It parses the JSON source and creates a JavaScript object.
xml The source to unmarshall.
returns The JavaScript object created.
ServiceProxy(url,methodNames,user,pass)
Class for creating proxy objects which resemble the remote service.
Method calls to this proxy will result in calls to the remote service.
The arguments are interpreted as shown in the examples:
ServerProxy("url", ["methodName1",...])
ServerProxy("url", ["methodName1",...], "user", "pass")
ServerProxy("url", "user", "pass")
Method calls to this proxy will result in calls to the remote service.
The arguments are interpreted as shown in the examples:
ServerProxy("url", ["methodName1",...])
ServerProxy("url", ["methodName1",...], "user", "pass")
ServerProxy("url", "user", "pass")
- url The url of the service.
- methodNames Array of names of methods that can be called on the server.
- user =null The user name to use for HTTP authentication.
- pass =null The password to use for HTTP authentication.
- ServiceProxy::_addMethodNames(methodNames)
Adds new JSONRPCMethods to the proxy server which can then be invoked.
methodNames Array of names of methods that can be called on the server.
- ServiceProxy::_setAuthentication(user,pass)
Sets username and password for HTTP Authentication for all methods of this service.
user The user name.
pass The password.
- ServiceProxy::_url
The url of the service to resemble.
- ServiceProxy::_user
The user used for HTTP authentication.
- ServiceProxy::_password
The password used for HTTP authentication.
- ServiceProxy::_methods
All JSONRPCMethod objects the proxy can call.
JSONRPCMethod(url, name, user, pass)
Class for creating JSON-RPC methods.
Calling the created method will result in an JSON-RPC call to the service.
The return value of this call will be the return value of the RPC call.
JSON-RPC errors will be raised as Exceptions.
If the last parameter passed to the method is an JSONRPCAsyncCallback object,
then the remote method will be called asynchronously.
The results and errors are passed to the callback.
Calling the created method will result in an JSON-RPC call to the service.
The return value of this call will be the return value of the RPC call.
JSON-RPC errors will be raised as Exceptions.
- url The URL of the service providing the method.
- name The name of the method to invoke.
- user =null The user name to use for HTTP authentication.
- pass =null The password to use for HTTP authentication.
If the last parameter passed to the method is an JSONRPCAsyncCallback object,
then the remote method will be called asynchronously.
The results and errors are passed to the callback.
- JSONRPCMethod::notify(...)
Calls the remote method usig async. notification.
This method will never be replied to by the remote service, so no callback is needed.
- JSONRPCMethod::setAuthentication(user,pass)
Sets username and password for HTTP Authentication.
user The user name.
pass The password.
- JSONRPCMethod::methodName
The name of the remote method.
- JSONRPCMethod::url
The url of the remote service containing the method.
- JSONRPCMethod::user
The user name used for HTTP authorization.
- JSONRPCMethod::password
The password used for HTTP authorization.
JSONRPCAsyncCallback(result, err)
The interface of a callback for asynchronous JSON-RPC.
- result The result of the call (null if error)
- err A JSONRPCError if there was one returned otherwise null