Basic example of WCF Services with Mono. WCF is Windows Communication Foundation. Some terminology explained:
Service
- class that does business logic. .NET considers a class a WCF service when inherits from aService Contract
- interface annotated withServiceContract
attribute and each exposed method withOperationContract
attribute. Those are available in theSystem.ServiceModel
assembly and namespace.Host
- application that hosts the WCF Service. Typically this is IIS. You can tell IIS "This DLL has a WCF Service - host it for me" and it will. But .NET includes necessary classes for you to host it in another application (like in this repository).ServiceHost
- .NET class fromSystem.ServiceModel
that can start hosting specified services. It's used to run the service in custom applications, like this.Binding
- The way (protocol) the service is exposed and consumed. E.g. HTTP, TCP, etc. This example runs with HTTP binding. ABinding
object is passed to theServiceHost
constructor. In IIS you can configure which binding to use for your service.
- Open the
WCF.sln
file with either MonoDevelop, Xamarin Studio or Visual Studio. - Build the solution
- Start the solution
It should start two console applications - client and host. In the client console you can type your name and the service will greet you.
Client/
Console application - consumes the service.GreeterWcfService/
Class Library - the service itself. Includes business logic + contracts (interfaces) for the service.Host/
Console application - hosts the WCF service via HTTP binding.