This topic uses EGL constructs to indicate how to access an EGL REST-RPC service from a programming language other than EGL.
EGL REST-RPC services use HTTP 1.1 and JSON-encoded data.
Record EGL_REST_RPC_Request //name of the function to be invoked method string; //IN and INOUT parameters in the service parameter-list order params any[]; end
// For a response with one value Record EGLRESTRPCSingleReturnParamResponse result any?; error EGLRESTRPCResponseError?; end // For a response with multiple values, as described later Record EGLRESTRPCMultipleReturnParamResponse result any[]; error EGLRESTRPCResponseError?; end
Record EGLRESTRPCResponseError error JSONRPCError; end Record JSONRPCError name string; code string; message string; error EglRpcException end; Record EglRpcException name string; messageID string; message string; // the next fields are present // if the type is egl.core.ServiceInvocationException source? int; detail1? string; detail2? string; detail3? string; end
Service HelloWorld function emptyParams() ; end function singleReturnParam( p1 string in)returns(string) ; end function multipleReturnParams( p1 string? )returns(Wrapper?) ; end function throwsException() ; end end Record Wrapper text string; length int; end
Here are examples of the content passed when a request succeeds:
No parameters: Request body:{"method" : "emptyParams", "params" : []} Response body:{} One return parameter: Request body:{"method" : "singleReturnParam", "params" : ["Joe"]} Response body:{"result" : "Hello Joe"} Multiple return parameters: Request body:{"method" : "multipleReturnParams", "params" : ["Joe"]} Response body:{"result" : ["Hello Joe", {"text" : "Hello Joe", "length" : 9}]}
The following example gives an abbreviated error message but otherwise shows the content passed when a service throws an exception:
Request body:{"method" : "throwsException", "params" : []} Response body: {"error" : { "name" : "JSONRPCError", "code" : "EGL1539E", "message" : "EGL1539E An exception occurred...", "error" : {"messageID" : "EGL1539E", "message" : "EGL1539E An exception occurred...", "source" : 4, "detail1" : "500", "detail2" : "FAILED", "detail3" : "java.net.ConnectException:Connection refused", "name" : "egl.core.ServiceInvocationException" } } }