Skip to content
Arxisos edited this page Feb 16, 2012 · 1 revision

Using DTOs to define your web service interface makes it possible to provide strong-typed generic service clients without any code-gen or extra build-steps, leading to a productive end-to-end type-safe communication gateway from client to server.

All REST and ServiceClients share the same interfaces (IServiceClient, IRestClient and IRestClientAsync) so they can easily be replaced (for increased perf/debuggability/etc) with a single line of code.

Here's a list of all built-in clients:


C#/.NET Clients can call the above Hello Service using any of the JSON, JSV, XML or SOAP Service Clients with the code below:

var response = client.Send<HelloResponse>(new Hello { Name = "World!" });
Console.WriteLine(response.Result);

Async Example

client.SendAsync<HelloResponse>(new Hello { Name = "World!" },
    r => Console.WriteLine(r.Result), (r, ex) => { throw ex; });

The service clients use the automatic pre-defined routes for each service.


In addition, the service clients also provide HTTP verbs (Get, Post & PostFile, Put, Delete) letting you call your custom user-defined routes REST-fully e.g:

var response = client.Get<HelloResponse>("/hello/World!");
Console.WriteLine(response.Result);

Async Example

client.GetAsync<HelloResponse>("/hello/World!",
    r => Console.WriteLine(r.Result), (r, ex) => { throw ex; });

Clone this wiki locally