Legrand / Raritan / Server Technology Xerus™ PDU JSON-RPC API
|
The classes implementing Xerus™ JSON-RPC communication are contained in two separate .NET namespaces: The namespace Com.Raritan.Idl
contains .NET classes for all IDL interfaces, and .NET equivalents for named IDL data types like structures or enumerations. The Com.Raritan.JsonRpc
namespace contains utility classes for performing the JSON-RPC.
IDL interfaces are mapped to .NET classes. Each method defined in IDL maps to three overloaded methods in the corresponding .NET class:
rsp
method callback is called. If there was an error, the fail
method callback is called.rpcCtrl
object.IDL structures are mapped to .NET classes with public members for each structure element. Those classes feature a default constructor and implement the ICloneable
interface.
IDL enumerations are mapped to plain .NET enums. Vectors are mapped to System.Collections.Generic.IEnumerable, and maps are mapped to System.Collections.Generic.IDictionary.
Exceptional error conditions may occur because of communication problems or because of system errors that occur on the server while processing a request. Those "unexpected" error conditions are not a part of the regular IDL signature, so they are handled by using one of the following exceptions:
Com.Raritan.JsonRpc.RpcRequestException
This exception is raised in case of a communication failure. Typical examples for this include an unreachable server, an authentication problem or a wrong resource ID
Com.Raritan.JsonRpc.RpcErrorException
This exception is raised in case the server responded with a JSON-RPC error object instead of the expected method result. This can indicate either an internal problem in the server or a malformed request from the client.
Com.Raritan.JsonRpc.RpcFormatException
This exception is raised in case the JSON-RPC response from the server cannot be decoded. This may indicate an interface version mismatch between client and server.
For synchronous method invocations the exceptions are thrown and can be intercepted with a try/catch block. For asynchronous method invocations the exception object is passed to the fail
method callback.
The .NET bindings contain classes for all IDL interface versions that have been released up to the firmware release the bindings were generated for. Using those classes client programs can be written to be compatible with any firmware version up until the most recent release.
IDL interface names like pdumodel.Pdu_3_1_0
contain three separate version numbers:
Pdu_3_1_0
interface is guaranteed to work with Pdu_3_1_1
or later without modification. Object references returned from an interface with compatible changes can be safely used without additional compatibility checks.See the DumpPdu.cs program distributed with this documentation for an example how to write a client program that supports multiple interface versions.
The Bulk RPC interface allows combining multiple JSON-RPC method calls into a single bulk request that can be sent to the server and processed in a single HTTP request. When using the asynchronous API the .NET client library automatically adds all submitted requests into a bulk request queue. A background thread combines pending requests into a bulk request and sends it to the device. As a result, submitted requests can be delayed by up to 250 Milliseconds while the bulk RPC thread waits for more requests to be queued.
To bypass the bulk request queue, add an rpcCtrl
parameter to the asynchronous method call. The following call will be immediately sent to the device as a dedicated JSON-RPC request:
Creates a new agent.
Parameters:
It is necessary to set the Username/Password or the Token propertybefore the first request.
This property sets or returns the username for HTTP basic authentication.
This property sets or returns the password for HTTP basic authentication.
When this property is set, it enables and disables HTTP authentication using a session token. A session token can be obtained by calling the newSession method of the session.SessionManager class.
Setting Token with a string variable which contains the token will enable token-based authentication.
When setting Token to null, token-based authentication is disabled.