In continuation of previous post regarding WCF, here goes another. In this post I will do step step explanation for hosting service using config file (remember this is the beauty of WCF, we don’t need to recompile to add multiple endpoints).
The assumtion is readers have already implemented the service contract. I will use a dummy class named IService for my explanation
- Create a instance of ServiceHost.
- ServiceHost servicehost = new ServiceHost(typeof(Examples.ServiceImplementation));
- Use the Open to start listening.
- servicehost.Open();
- Now put the following in the App.Config file

Let me explain each of the element
-
The host element declares the base address for the endpoint. In this case its declaring two base address the http address and another one is the tcp address. The host address is used by the ServiceHost to listen on the respective port and address.

-
There are three endpoints
Each endpoint basically is collection of address, contract and binding. Here in the above case the address is not specified as we have already sepcified in the base address. The contract is Examples.IService and the binding is HTTP.
- The second endpoint

is the TCP endpoint for the same service. Smilar to the previous one this definess the endpoint as collection of Examples.IService as contract and binding as TCP and address is not mentioned and taken from the base address.
-
The last endpoint
is used by the client to generate the meta information about the Service. This is standard and ideally should be there for each service.I hope the above helps in understanding this beautiful technology.

I am trying to create a service with two endpoints on one port, one http/text and on http/mtom streaming.
The reason for doing so is to overcome the wcf message size limitation on large database queries, ie tens or hundreds of thousands of rows returned. So, to test two endopoints, i used the new wcf service library example, and added a second interface/contract, leaving as a simple function returning an int. When I have two simple endpoints on seperate contracts, the vs 2008 host tool WcfSVCHost.exe cant load either of them. But If I comment out all references to either, the remaining service/endpoint will load.
Is it just wcfsvchost.exe, or wcf itself?
Comment by BillInPA — Monday, September 8, 2008 @ 11:53 pm |