Remote method invocation with WCF
Remote method invocation -Example with WCF
Windows Communication Foundation (WCF) is a framework for building service-oriented applications in .NET.
It supports various communication protocols and various ways for clients to access the services, with or without using proxies.
The following example (the StockMarket example) is realised in 2 variants, using 2 different communication protocols: NetTcpBinding and WebHttpBinding.
clients can access the services in different ways, with or without using proxies.
For clients that acces the remote service by method invocation on a proxy object, we can have 2 different kinds of proxies:
- transparent proxy, dynamically generated at runtime. The application derveloper does not need to do anything.
- proxy generated by the application developer using the svcutil tool
The StockMarket example
The application developer must provide:
- IStockMarket.cs - the interface of the remote service
- StockMarket.cs - the implementation of the service interface
- the server main program. It tells the framework that a there is a StockMarket implementation available for the IStockMarket interface. it uses ServiceHost to do this. The ServiceHost instantiates a StockMarket object and listens for client requests.
- the client main program. It accesses the remote StockMarket by invoking methods on a proxy obtained from the framework.