Message based webservice framework on the pure WCF
Clone or download
Permalink
Failed to load latest commit information.
.nuget * nuget Jun 15, 2017
Clients/JavaScript + JsonServiceClient.js initial version Sep 20, 2014
Samples updated upload sample Nov 3, 2016
Site Merge branch 'master' of https://github.com/Nelibur/Nelibur Jul 23, 2014
Source added public static IActionVisitor<TBase, TContext> ForWithContext<TB… Aug 15, 2018
Tools - All useless gitignore Nov 22, 2014
packages - All useless gitignore Nov 22, 2014
.gitignore Nelibur.Sword moved to .net core Mar 23, 2018
CONTRIBUTING.markdown + CONTRIBUTING.markdown May 13, 2014
FactTest.msbuild + Root.msbuild Jan 2, 2014
GlobalAssemblyInfo.cs * All added nuget package for .net 4.0 Feb 28, 2015
LICENSE * Nelibur/nelibur.nuspec Jan 28, 2014
Nelibur.Sword.sln Nelibur.Sword moved to .net core Mar 23, 2018
Nelibur.Sword.sln.DotSettings Nelibur.Sword moved to .net core Mar 23, 2018
NuGet.msbuild * All added nuget package for .net 4.0 Feb 28, 2015
README.md * typo Dec 20, 2016
ReleaseNotes.markdown * ReleaseNotes.markdown version 3.0.2 May 25, 2014
Root.msbuild * All added nuget package for .net 4.0 Feb 28, 2015
Solution.sln * option class -> struct Mar 27, 2016
Solution.sln.DotSettings + upload file sample Nov 3, 2016
Solution.sln.GhostDoc.xml * ExtendedThreadPool -> TinyThreadPool Apr 21, 2015
SpecFlowTest.msbuild + SpecFlowTest.msbuild Feb 15, 2014
nuspec.xsd Awsome nuget packaging based on ServiceStack packaging tricks Nov 7, 2014
restore.cmd + restore.cmd restores packages: both for project and tools Nov 8, 2014

README.md

Nelibur - Message based web service framework on the pure WCF

Nuget downloads Source Browser GitHub license GitHub license

Nelibur is message based web service framework on the pure WCF. Nelibur simplifies creating high-performance and message based web services and you certainly have all the power of the WCF

Nelibur on Nuget

What to read

Simple RESTful Message based Client

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

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);

Simple RESTful Message based service on the pure WCF

var service = new WebServiceHost(typeof(JsonServicePerCall));
service.Open();

JsonServicePerCall - is predefined service which implements following interface IJsonService

The IJsonService is flexible, stable and maintainable, we can transfer any data, because the service contract depends only from WCF's Message class. "The Message class is fundamental to Windows Communication Foundation (WCF). All communication between clients and services ultimately results in Message instances being sent and received." (MSDN)

[ServiceContract]
public interface IJsonService
{
    [OperationContract]
    [WebInvoke(Method = OperationType.Delete,
        UriTemplate = RestServiceMetadata.Path.Delete,
        RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
    Message Delete(Message message);

    [OperationContract]
    [WebInvoke(Method = OperationType.Delete,
        UriTemplate = RestServiceMetadata.Path.DeleteOneWay,
        RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
    void DeleteOneWay(Message message);

    [OperationContract]
    [WebGet(UriTemplate = RestServiceMetadata.Path.Get,
        RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
    Message Get(Message message);

    [OperationContract]
    [WebGet(UriTemplate = RestServiceMetadata.Path.GetOneWay,
        RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
    void GetOneWay(Message message);

    [OperationContract]
    [WebInvoke(Method = OperationType.Post,
        UriTemplate = RestServiceMetadata.Path.Post,
        RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
    Message Post(Message message);

    [OperationContract]
    [WebInvoke(Method = OperationType.Post,
        UriTemplate = RestServiceMetadata.Path.PostOneWay,
        RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
    void PostOneWay(Message message);

    [OperationContract]
    [WebInvoke(Method = OperationType.Put,
        UriTemplate = RestServiceMetadata.Path.Put,
        RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
    Message Put(Message message);

    [OperationContract]
    [WebInvoke(Method = OperationType.Put,
        UriTemplate = RestServiceMetadata.Path.PutOneWay,
        RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
    void PutOneWay(Message message);
}

Performance of CRUD operations - JsonServiceClient

Method Duration Remarks
Get 3767 ms 10 000 messages. Default WebServiceHost settings. JsonServiceClient sends messages in one thread. Win x64. Intel Core i7-2600 3.4 GHz.
Post with void return 4546 ms
Post 5323 ms
Put with void return 4521 ms
Put 5334 ms
Delete with void return 3243 ms
Delete 3807 ms

WCF's RESTful service

Nelibur already contains JsonServicePerCall service, but you can create your own custom Service, for instance

[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
public sealed class SampleWebService : IJsonService
{
    public void DeleteOneWay(Message message)
    {
        NeliburRestService.ProcessOneWay(message);
    }

    public Message Delete(Message message)
    {
        return NeliburRestService.Process(message);
    }

    public void GetOneWay(Message message)
    {
        NeliburRestService.ProcessOneWay(message);
    }

    public Message Get(Message message)
    {
        return NeliburRestService.Process(message);
    }

    public void PostOneWay(Message message)
    {
        NeliburRestService.ProcessOneWay(message);
    }

    public Message Post(Message message)
    {
        return NeliburRestService.Process(message);
    }

    public void PutOneWay(Message message)
    {
        NeliburRestService.ProcessOneWay(message);
    }

    public Message Put(Message message)
    {
        return NeliburRestService.Process(message);
    }
}

Request binding on appropriate Processor

NeliburRestService.Configure(x =>
{
    x.Bind<CreateClientRequest, ClientProcessor>();
    x.Bind<UpdateClientRequest, ClientProcessor>();
    x.Bind<DeleteClientRequest, ClientProcessor>();
    x.Bind<GetClientRequest, ClientProcessor>();
});

ClientProcessor example

public sealed class ClientProcessor : IPost<CreateClientRequest>,
									 IGet<GetClientRequest>,
									 IDeleteOneWay<DeleteClientRequest>,
									 IPut<UpdateClientRequest>
{
    private static List<Client> _clients = new List<Client>();

    public void DeleteOneWay(DeleteClientRequest request)
    {
        _clients = _clients.Where(x => x.Id != request.Id).ToList();
    }

    public object Get(GetClientRequest request)
    {
        Client client = _clients.Single(x => x.Id == request.Id);
        return new ClientResponse { Id = client.Id, Email = client.Email };
    }

    public object Post(CreateClientRequest request)
    {
        var client = new Client
        {
            Id = Guid.NewGuid(),
            Email = request.Email
        };
        _clients.Add(client);
        return new ClientResponse { Id = client.Id, Email = client.Email };
    }

    public object Put(UpdateClientRequest request)
    {
        Client client = _clients.Single(x => x.Id == request.Id);
        client.Email = request.Email;
        return new ClientResponse { Id = client.Id, Email = client.Email };
    }
}

Simple SOAP Message based Client

var client = new SoapServiceClient("NeliburSoapService");

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);

Simple SOAP Message based service on the pure WCF

WCF's ServiceContract

[ServiceContract]
public interface ISoapService
{

    [OperationContract(Action = SoapServiceMetadata.Action.Process,
        ReplyAction = SoapServiceMetadata.Action.ProcessResponse)]
    Message Process(Message message);

    [OperationContract(Action = SoapServiceMetadata.Action.ProcessOneWay)]
    void ProcessOneWay(Message message);
}

WCF's SOAP service

[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
public sealed class SampleSoapService : ISoapService
{
    public Message Process(Message message)
    {
        return NeliburSoapService.Process(message);
    }

    public void ProcessOneWay(Message message)
    {
        NeliburSoapService.ProcessOneWay(message);
    }
}

Request binding on appropriate Processor

NeliburSoapService.Configure(x =>
{
    x.Bind<CreateClientRequest, ClientProcessor>();
    x.Bind<UpdateClientRequest, ClientProcessor>();
    x.Bind<DeleteClientRequest, ClientProcessor>();
    x.Bind<GetClientRequest, ClientProcessor>();
});

ClientProcessor is the same as for RESTful

public sealed class ClientProcessor : IPost<CreateClientRequest>,
									 IGet<GetClientRequest>,
									 IDeleteOneWay<DeleteClientRequest>,
									 IPut<UpdateClientRequest>
{
    private static List<Client> _clients = new List<Client>();

    public void DeleteOneWay(DeleteClientRequest request)
    {
        _clients = _clients.Where(x => x.Id != request.Id).ToList();
    }

    public object Get(GetClientRequest request)
    {
        Client client = _clients.Single(x => x.Id == request.Id);
        return new ClientResponse { Id = client.Id, Email = client.Email };
    }

    public object Post(CreateClientRequest request)
    {
        var client = new Client
        {
            Id = Guid.NewGuid(),
            Email = request.Email
        };
        _clients.Add(client);
        return new ClientResponse { Id = client.Id, Email = client.Email };
    }

    public object Put(UpdateClientRequest request)
    {
        Client client = _clients.Single(x => x.Id == request.Id);
        client.Email = request.Email;
        return new ClientResponse { Id = client.Id, Email = client.Email };
    }
}

Contributing

To contribute please follow these guidelines:

  • Fork the project
  • Spaces, not Tabs and no regions
  • Make a branch for each thing you want to do
  • Send a pull request

Contributors

A big thanks to all of Nelibur's contributors: