OSLC4Net is an SDK and sample applications that help the .NET community adopt Open Services for Lifecycle Collaboration (OSLC, homepage) and build OSLC-conformant tools.
The SDK allows developers to create OSLC servers and clients by adding OSLC annotations to .NET objects to represent them as OSLC resources. It includes a library based on the dotNetRDF package, which assists with representing these resources as RDF and helps parse Turle, RDF/XML, and JSON-LD documents into OSLC .NET objects.
The OSLC4Net.Client package can be used to help create consumer REST requests. On the server side, the project offers an RDF-specific MediaTypeFormatter
that can help process OSLC REST requests within an ASP.NET MVC 5 API. Join the discussion on the .NET Core migration.
If you do not have a .NET development environment, start by downloading VS Code C# Dev Kit. Make sure to install .NET 8 SDK for development. Libraries target NETStandard 2.0 and should run on .NET Framework 4.8 or .NET 6+ (recommended).
Create a new console application targeting .NET 6+, add a NuGet dependency to OSLC4Net.Client
(make sure the Include prerelease is checked if you see an empty list) and add the following code:
private const string OSLC_SERVER_URI = "https://oslc.itm.kth.se/ccm";
static void Main(string[] args)
{
try
{
var helper = new JazzRootServicesHelper(OSLC_SERVER_URI, OSLCConstants.OSLC_CM_V2);
var catUri = helper.GetCatalogUrl();
Console.WriteLine($"The OSLC server has an OSLC Service Provider Catalog at the following URI:\n {catUri}");
} catch (RootServicesException e) {
Console.WriteLine($"Failed to fetch the OSLC RootServices document from:\n {OSLC_SERVER_URI}/rootservices");
}
Console.ReadLine();
}
This should give you a valid response.
Note
Sample StockQuote provider has not yet been migrated to .NET 6+.
Warning
Sample StockQuote provider is a toy implementation and does not correspond to any standards-track OSLC specifications.
OSLC4Net.StockQuoteSample
is a sample OSLC provider which implements one resource type, a StockQuote. This resource is not defined by an OSLC specification, it shows how OSLC4Net can be used to create an experimental OSLC provider.
- Build the
OSLC4Net_SDK\OSLC4Net.Core.sln
solution - Right click the
OSLC4Net.StockQuoteSample
project and run it via Debug->Start new instance
You'll see a web page created - that is currently just a skeleton provided by ASP.NET. Try performing a GET request using Postman (make sure to set the Accept
header to application/rdf+xml
:
- http://localhost:7077/api/stockquote - returns all StockQuotes
- http://localhost:7077/api/stockquote?getShape=true - returns the StockQuote OSLC resource shape
- http://localhost:7077/api/stockquote/nasdaq_goog - returns an individual StockQuote
A request to the first URL using Fiddler should have the following response:
- See the OSLC site for more details on OSLC specifications and community activities.
- See the Eclipse Lyo site for information on OSLC SDKs and samples for other technologies.
OSLC4Net is licensed under the Eclipse Public License 1.0