NuxeoDotNetClient  1.0.0 beta
.NET Client for Nuxeo Automation and REST API
NuxeoDotNetClient Documentation

The Nuxeo .NET Client is a cross-platform client library developed in C# for the Nuxeo Automation and REST API.

Nuxeo .NET Client targets two platforms: net45 and dnxcore50. This allows it to be used to develop apps for not only Windows but also Linux and Mac OS. Bellow follows an app/platform compatibility table for the Nuxeo .NET Client library:

1 +------------------------------------+------------+
2 | | Compatible |
3 +------------------------------------+------------+
4 | Destkop .NET 4.5+ | Yes |
5 | ASP .NET 4.5+ | Yes |
6 | ASP .NET 5 (Native & CoreCLR) | Yes |
7 | DNX Console App (Native & CoreCLR) | Yes |
8 | Windows 8/8.1 Store APP | No |
9 | Windows Phone 8/8.1 | No |
10 | Windows 10 (UWP) | No |
11 | Xamarin.Android | Yes? |
12 | Xamarin.iOS | Yes? |
13 +------------------------------------+------------+

Setup

In order to run Nuxeo .NET Client, you must have installed the .NET Core DNX SDK, version 1.0.0-beta8 or above, or .NET 4.5 on a Windows setup. Installation instructions follow below:

  1. Install .NET Core:
  2. Add the following feeds to NuGet config file:

    If you do not yet have a config file, create it on:

    • For Mac OS & Linux: *~/.config/NuGet/NuGet.config*
    • For Windows: *AppData%/NuGet/NuGet.Config*

    And paste the following contents:

1 <?xml version="1.0" encoding="utf-8"?>
2 <configuration>
3  <packageSources>
4  <add key="AspNetVNext" value="https://www.myget.org/F/aspnetvnext/" />
5  <add key="NuGet" value="https://www.nuget.org/api/v2/" />
6  </packageSources>
7 </configuration>

On Visual Studio 2015

If you are using Visual Studio 2015 on Windows, you will need to download the Microsoft ASP.NET and Web Tools 2015 (Beta8) – Visual Studio. Two setup files must be installed:

Usage

Download the NuxeoClient nupkg file and install it by running dnu install NuxeoClient -s <path-to-nupkg-file-parent-folder>.

Include NuxeClient dependency in your project.json file:

1 {
2  ...,
3  "dependencies": {
4  ...,
5  "NuxeoClient": "1.0.0-*"
6  },
7  ...
8 }

Reference NuxeoClient and NuxeoClient.Wrappers namespaces:

Create a new instance of NuxeoClient:

Client client = new Client(); // server running on localhost:8080

Create a folder named "Test Folder 1" on the root:

client.Operation("Document.Create")
.SetInput("doc:/")
.SetParameter("type", "Folder")
.SetParameter("name", "TestFolder1")
.SetParameter("properties", new ParamProperties { { "dc:title", "Test Folder 1" } })
.Execute();

If you want to do something with the result, you can either wait for it with a .Execute().Result; or continue the async call with .Execute().ContinueWith(...);.

Please check the tests on test/TCK for more usage examples and the tutorial and the end of this document.

Running the Tests

This project includes a Test Compatibility Kit (TCK) covering several tests on the client. In order for the tests to run, there must be an instance of the Nuxeo Server running, loading nuxeo-automation-test-7.10-SNAPSHOT.jar.

Before running the tests, the server's ip address should be updated in the test/TCK/config.json file.

Then, on the solution folder, run:

  1. dnu restore to download all dependencies
  2. cd test/TCK to move to the TCK folder
  1. dnx test to run all tests

On Visual Studio 2015

  1. Open the solution on Visual Studio
  2. Show the Test Explorer, if not displayed already: go to Test > Window > Test Explorer
  3. Build solution, which will automatically discover all tests
  4. On Test Explorer, hit Run All to run all tests

If any errors are displayed regarding missing dependencies:

  1. Open the Package Manager Console: Tools > NuGet Package Manager > Package Manager Console
  2. Run dnu restore

Known Issues

There is currently a bug where DELETE requests are sent as GET on Linux and Mac OS only, which prevents operations such as deleting documents and drop batches from working. This issue was reported here. This bug causes 5 out of 9 tests of the TCK to fail, on the last stage where all temporary files are deleted.

Tutorial

Let's make a quick DNX Console App that creates a folder on the server's root and a child document. This quit tutorial assumes that you have an instance of Nuxeo Server running on your local machine.

1 {
2  "version": "1.0.0-*",
3  "description": "Nuxeo Test App",
4  "authors": [
5  "John Doe"
6  ],
7  "tags": [
8  ""
9  ],
10  "projectUrl": "",
11  "licenseUrl": "",
12  "dependencies": {
13  "System.Console": "4.0.0-beta-23409",
14  "NuxeoClient": "1.0.0-*"
15  },
16  "frameworks": {
17  "dnxcore50": {}
18  }
19 }
using System;
namespace TestNuxeoApp
{
public class Program
{
public static void Main(string[] args)
{
// create a new Nuxeo Client, which is a disposable objects
using(var client = new Client())
{
// perform an async request to create a folder on the root with the title "My Folder"
// let's wait for it to finish so we can see the prints
client.Operation("Document.Create")
.SetInput("doc:/")
.SetParameter("type", "Folder")
.SetParameter("name", "MyFolder")
.SetParameter("properties", new ParamProperties { { "dc:title", "My Folder" } })
.Execute().ContinueWith((folderResponse) => {
Document folder = folderResponse.Result as Document;
// print the returned folder object if it is not null
Console.WriteLine(folder == null ? "Failed to create folder." : "Created " + folder.Path);
// perform an async request to create a child file named "My File"
folder.Create(new Document {
Type = "File",
Name = "MyFile",
Properties = new Properties { { "dc:title", "My File" } }
}).ContinueWith((fileResponse) => {
Document file = fileResponse.Result as Document;
// print the returned file object if it is not null
Console.WriteLine(file == null ? "Failed to create file." : "Created " + file.Path);
}).Wait();
}).Wait();
}
}
}
}