Kepler framework
The Relativity Kepler framework provides you with the ability to build HTTP services for REST via a .NET interface. You build a Kepler service using standard .NET contracts, which the Kepler framework uses to build HTTP endpoints. Your Kepler service is then deployed in Relativity as part of a custom application built on the Application Deployment System (ADS). Additionally, the Kepler framework includes a client proxy that you can use when interacting with the services through .NET.
Kepler services offer these advantages:
- Easily hosts endpoints for your application.
- A lightweight framework as compared to packaging DLLs used by custom pages and Web API endpoints.
- Ability to create web and C# endpoints simultaneously.
- Endpoints are automatically protected by Relativity authentication.
This page contains the following information:
Basic concepts and implementation workflow for a Kepler service
Use the information in this section to become familiar with the basic concepts and implementation workflow for a Kepler service. The outline of this workflow includes both the server-side implementation of a service, and the client-side interactions with it. See the following sections:
For code samples, see Kepler service structure and components.
Server-side implementation of Kepler service
The implementation of a Kepler service includes defining the service contract, implementing the required functionality, and organizing the service by module. The following sections provide a high-level description of each step in this workflow:
Service module
A service module is a simple unit of code used to organize your services within the Kepler framework. All Kepler services belong to a single Kepler module. For more information, see Kepler service structure and components.
Use the following design guidelines when implementing the module for your service:
Service contract
A contract defines the programming interface for your service. This interface is exposed through .NET and it determines the functionality that your service provides.
Implement your contract as a simple .NET interface. Use the following design guidelines when implementing the interface for your service:
Service implementation
After you define your contract, implement the functionality exposed through your interface. Add your implementation class to its own Visual Studio project and DLL. Follow this best practice because the implementation class runs on the server and shouldn't be visible to other users of your service.
Client-side interactions with a Kepler service
You can interact with a Kepler service by making calls through a .NET client or by submitting HTTP calls similar to those used for other RESTful services. The following sections outline how to make calls to your service:
Kepler .NET client
You can access your Kepler service from any .NET language using the client library provided as part of the Kepler framework. For client code samples, see the documentation for existing services listed on Relativity services in REST.
The following steps provide a high-level overview describing how to configure a .NET proxy used to call the server:
- Add the following DLL references to your client code:
- DLL containing your service interface
- Relativity.Services.ServiceProxy.dll - To reference this DLL, you can install the Relativity.Kepler package in your Visual Studio project. See NuGet package for the Kepler framework.
- Access Kepler services via a proxy object. This proxy object uses the same interface as your DLL. If you have an IFooManager interface, your client-side service proxy is typed as an IFooManager object.
- To get a client proxy, complete these steps:
HTTP clients
You can make calls to a Kepler service using any standard REST or HTTP client, because all Kepler APIs are exposed over the HTTP protocol. By default, Kepler service calls use the POST method, but other HTTP methods are available. For more information, see HTTP headers, verbs, and related information.
Complete these steps to a call to an endpoint:
- Set the required headers for a Kepler service call:
- X-Kepler-Version header - defines the wire protocol version for the Kepler call and defaults to the current standard.
- X-CSRF-header - prevents cross-site request forgery (CSRF) attacks in the browser. You must set this header, but you can assign any value to it. In general, the header value is set to a dash(-). For more information, see X-CSRF-Header.
Note: Don't leave this header value blank. Some browsers remove empty headers.
The Kepler framework returns a 404 status code when the X-CSRF-header isn't submitted. If unexpected 404 status code is returned, make sure that you have included the proper header.
- Content-Type header - indicates the content-type of the request made to the Kepler service. This header must be set to application/json because the Kepler framework only uses JSON payloads.
- Make a call using the URL generated through Kepler framework. It has the following general format:
<host>/Relativity.REST/api/{ModuleName}/{InterfaceName}/{MethodName}
|
This basic URL template includes the following tokens for the endpoints generated by the Kepler framework:
- {ModuleName} - the name of the module that the interface for your service is associated with. See Kepler framework.
- {InterfaceName} - the name of the interface or contract exposed for your service. See Kepler framework.
- {MethodName} - the name of the method on your interface used for the functionality that you want to access.
For detailed route information, see Kepler service structure and components
- Build a JSON payload. When you call a Kepler service, your arguments are sent in the body of a POST call. The arguments are structured as a JSON object that matches the parameters of your service.
For example, you have a service call with the following signature:
Task DoStuffAsync( int a, int b, string name);
|
Your JSON payload would have the following format:
1 2 3 4 5 | {
"a" :42,
"b" :99,
"name" : "Ziggy"
}
|
Use valid JSON with the appropriate data types in the payload. The following formatting rules apply to certain data types:
- Enumeration - represented via their .NET string name instead of an integer value.
- DateTime - represented as a string using ISO8601 format, such as 2009-02-15T00:00:00Z.
- GUID - represented represented as a string with 32 digits separated by hyphens, such as 00000000-0000-0000-0000-000000000000.
- Empty argument - leave the POST body empty.
- Progress and cancellation - use GUIDs at the JSON layer.
NuGet package for the Kepler framework
You can add the assemblies for the Kepler framework as a NuGet package to your Visual Studio projects. For more information about the Kepler API SDKs, see Download the SDKs and NuGet packages.
For installation information, see Quickstart: Install and use a package in Visual Studio on the Microsoft website.
Kepler FAQs
Review these FAQs for answers to general questions related to the Kepler framework.