Skip to content

How to use REST message based Client

Sergey Morenko edited this page May 10, 2014 · 4 revisions

Note - Nelibur's based on WCF and you certainly have all the power of the WCF

Step 0: Install Nelibur

Step 1: Create instance of JsonServiceClient

JsonServiceClient requires the same paramas as HttpClient

For example:

var serviceAddress = "http://localhost:9092/webhost"
var client = new JsonServiceClient(serviceAddress);

Final Step: Use it

var serviceAddress = "http://localhost:9092/webhost"
var client = new JsonServiceClient(serviceAddress);

var createRequest = new CreateClientRequest
    {
        Email = "email@email.com"
    };
ClientResponse response = client.Post<ClientResponse>(createRequest);

var updateRequest = new UpdateClientRequest
    {
        Email = "new@email.com",
        Id = response.Id
    };
response = client.Put<ClientResponse>(updateRequest);

var getClientRequest = new GetClientRequest
    {
        Id = response.Id
    };
response = client.Get<ClientResponse>(getClientRequest);

var deleteRequest = new DeleteClientRequest
    {
        Id = response.Id
    };
client.Delete(deleteRequest);

Note: SoapServiceClient've appropriate Async operations: DeleteAsync, GetAsync, PostAsync, PutAsync