Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/moimhossain/wcfserver
A handy class to host and consume WCF service with basic net tcp or ws http binding
https://github.com/moimhossain/wcfserver
Last synced: about 9 hours ago
JSON representation
A handy class to host and consume WCF service with basic net tcp or ws http binding
- Host: GitHub
- URL: https://github.com/moimhossain/wcfserver
- Owner: MoimHossain
- Created: 2014-02-05T13:36:42.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2015-01-07T11:34:06.000Z (almost 10 years ago)
- Last Synced: 2024-05-29T17:13:22.418Z (5 months ago)
- Language: C#
- Size: 144 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
WcfServer
=========A handy class to host and consume WCF service with basic net tcp or ws http binding.
The class "WcfService" is the main class that encapsulates all the details and allows users to host
any POCO classes (with a service contract) as WCF and create client side proxies for them to invoke.A typical way to host a service is as follows
var hosts = WcfService.DefaultFactory.CreateServers(
new List { typeof(MyService) },
(t) => { return t.Name; },
(t) => { return typeof(IWcf); },
"WcfServices",
8789,
(sender, exception) => { Trace.Write(exception); },
(msg) => { Trace.Write(msg); },
(msg) => { Trace.Write(msg); },
(msg) => { Trace.Write(msg); });
This above code hosts the MyService class as a WCF service on a given port (8789) with a NetTcpBinding.
Once this service is hosted it can be invoked from a client applicatiojn using the following sample code
using (var wcf =
WcfService.DefaultFactory.CreateChannel(Environment.MachineName, 8789, (t) => { return "MyService"; }, "WcfServices"))
{
var result = wcf.Client.Greet("Moim");Console.WriteLine(result);
}
That's it.