- What is address in WCF and how many types of transport schemas are there in WCF?
Address is a way of letting client know that where a service is located. In WCF, every service is associated with a unique address. This contains the location of the service and transport schemas. WCF supports following transport schemas
1. HTTP
2. TCP
3. Peer network
4. IPC (Inter-Process Communication over named pipes)
5. MSMQ
The sample address for above transport schema may look like
http://localhost:81
http://localhost:81/MyService
net.tcp://localhost:82/MyService
net.pipe://localhost/MyPipeService
net.msmq://localhost/private/MyMsMqService
net.msmq://localhost/MyMsMqService - What is the difference WCF and Web services?
1. Web services can only be invoked by HTTP. While Service or a WCF component can be invoked by any protocol and any transport type.
2. Second web services are not flexible. But Services are flexible. If you make a new version of the service then you need to just expose a new end point. So services are agile and which is a very practical approach looking at the current business trends. - How can we host a service on two different protocols on a single server?
Let’s first understand what this question actually means. Let’s say we have made a service and we want to host this service using HTTP as well as TCP.
You must be wondering why to ever host services on two different types of protocol. When we host a service it’s consumed by multiple types of client and it’s very much possible that they have there own protocol of communication. A good service has the capability to downgrade or upgrade its protocol according the client who is consuming him.
Let’s do a small sample in which we will host the ServiceGetCost on TCP and HTTP protocol.
Once we are done the server side coding its time to see make a client by which we can switch between the protocols and see the results. Below is the code snippet of the client side for multi-protocol hosting - How does WCF work?
Follows the 'software as a service' model, where all units of functionality are defined as services.
A WCF Service is a program that exposes a collection of Endpoints. Each Endpoint is a portal (connection) for communication with either clients (applications) or other services.
Enables greater design flexibility and extensibility of distributed systems architectures.
A WCF application is represented as a collection of services with multiple entry points for communications. - What are the main components of WCF?
1.Service: The working logic or offering, implemented using any .Net Language(C#).
2.Host: The environment where the service is parked. E.g. exe, process, windows service
3.Endpoints: The way a service is exposed to outside world.
Following figure shows us all the core components.