Table of Contents

OSLC4Net documentation

NuGet Version GitHub Discussions Discourse forum

OSLC4Net, an OSLC SDK for dotnet

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 (ASP.NET Core 8+ migration is ongoing).

Getting started

Prerequisites

  • .NET 10 SDK
  • Dev environment, e.g. VS Code C# Dev Kit

A simple OSLC Client

Create a new console application targeting .NET 10, add a NuGet dependency to OSLC4Net.Client and add the following code:

var oslcClient = OslcClient.ForBasicAuth(username, password, loggerFactory.CreateLogger<OslcClient>());

var resourceUri =
    "https://jazz.net/sandbox01-ccm/resource/itemName/com.ibm.team.workitem.WorkItem/1300";
OslcResponse<ChangeRequest> response = await oslcClient.GetResourceAsync<ChangeRequest>(resourceUri);
if (response.Resources?.SingleOrDefault() is not null)
{
    var changeRequestResource = response.Resources.Single();
    logger.LogInformation(
        "{shortTitle} {title}", changeRequestResource.GetShortTitle(),
        changeRequestResource.GetTitle());
}
else
{
    var responseStatusCode = response.StatusCode is null ? -1 : (int)response.StatusCode;
    logger.LogError("Something went wrong: {} {}", responseStatusCode,
        response.ResponseMessage?.ReasonPhrase);
}

Replace resourceUri with a valid OSLC resource URI. This should give you a valid response. See full example project for more details.

Tip

Use https://github.com/oslc-op/refimpl to quickly run a few conformant OSLC servers.

Next steps

Check out the Guides in the table of contents.

Contributing

If you would like to contribute to the docs, submit a PR to this repo (or click "Edit this page" on the page you wish to modify).

If you wish to file an issue, please do it on the main OSLC4Net repository.

More information on OSLC

  • 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.