Jason
Jason

Reputation: 1858

In WCF, what's the relationship between service, host, and client?

Can anyone explain the relationship between service, host, and client in the simplest ways?

Upvotes: 0

Views: 407

Answers (2)

Pankaj Kapare
Pankaj Kapare

Reputation: 7812

Let me explain with some analogy. On very hot day you may want to eat ice-cream and cool off yourself. So you go to ice-cream parlour and gives your order to lady at counter. Lady serves you with ice-cream you ordered. Now lets see how this translates to host, service and client.

Service:

Selling ice-cream is a service in this context. Ice-cream parlor may be providing other services as well. In WCF, "service" is function which performs certain activity and this function can be called remotely across boundaries e.g. SellIceCream or AddProduct or CalculateTax

Client:

Client is one who avails or consumes service. In our ice-cream example you (customer) are consuming service i.e. buying ice-cream, which is a service provided by Ice-Cream parlour owner.

Host:

Ice-Cream parlour owner cannot sell ice-cream in open space. He needs covered place where owner can arrange various equipment, storage units, cash counter etc. It also helps owner to serve customers in better and efficient way. In WCF terminology this Ice-Cream Parlour translates into "Host". Host is where service lives. Host manages lifetime of service.

Upvotes: 3

Phil Wright
Phil Wright

Reputation: 22956

A host is the process that creates one or more services that can then be accessed by clients. A console application or web application or windows service would be possible hosts that can exposes one or more services. Once the services are running then different clients can make requests to them.

Upvotes: 1

Related Questions