TechBubbles Microsoft Technology BLOG

Hosting the WCF Service in .NET Executable

Introduction

This post explains how to host a WCF service that we defined in the previous article WCF sample in VS 2008. Specifically we host the WCF service in .NET console application.

1. Add the Console application project called, Host, to the solution

2. Add System.ServiceModel .NET, System.Configuration Assemblies to the

    Host  Project.

3. Add the WCF Service project to the Host project

Solution

4. Write the following code which needed to provide a host for the WCFEmployee service

Host

5. The above code retrieves the base addresses from the configuration file and the addresses of WCF endpoints are relative to the base addresses.

6. Add the application configuration file named app.config to the Host project

    Modify the content as follows

App

appSettings section provides the address for the HTTP and TCP protocols.

System.serviceModel section for configuring the WCF endpoints. Here we add the address, binding and contract which constitutes an endpoint.

7. Run the Host Project it shows the following window

EmpHost 

8. You can test the host service by clicking the http://localhost:8000/EmployeeService/ and you will see the following window

Empservice

About the author

Kalyan Bandarupalli

My name is kalyan, I am a software architect and builds the applications using Microsoft .NET technologies. Here I am trying to share what I feel and what I think with whoever comes along wandering to Internet home of mine.I hope that this page and its contents will speak for me and that is the reason I am not going to say anything specially about my self here.

1 Comment

  • Using Visual Studio 2010 Beta 1 when I open this in the browser it displays “Metadata publishing for this service is currently disabled.” It helpfuly provides the xml tags to be added to the app.config.

TechBubbles Microsoft Technology BLOG

Follow me

Archives

Tag Cloud