WCF Tutorial, Part 5: WCF Service Host and WCF Test Client

01. December 2013 WCF 0

The WCF Service Library project template creates an application configuration file named App.config which needed to be modified to reflect the Service class and interface names. Class names should include the namespace as well.

The typical WCF configuration file has the following schema:


  • system.serviceModel
    • services
      • service ( name = "RoomReservationService.RoomReservationService" )
        • endpoint ( address = "" binding = "basicHttpBinding" contract = "RoomReservationContracts.IRoomService" )
        • endpoint ( address = "mex" binding = "mexHttpBinding" contract = "IMetadataExchange" )
        • host
          • baseAddresses
            • add (baseAddress="http://localhost:8733/RoomReservation/" )


<?xml version="1.0" encoding="utf-8" ?>
    <add name="RoomReservation" connectionString="Server=GAVROCHEPC01;Database=RoomReservation; 
         Trusted_Connection=true; Integrated Security=True; MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
    <compilation debug="true" />
      <service name="RoomReservationService.RoomReservationService">
        <endpoint address="" binding="basicHttpBinding" contract="RoomReservationContracts.IRoomService">
            <dns value="localhost" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
            <add baseAddress="http://localhost:8733/Design_Time_Addresses/RoomReservationservice/RoomReservationService/" />
          <serviceMetadata httpGetEnabled="True" httpsGetEnabled="True"/>
          <serviceDebug includeExceptionDetailInFaults="False" />

Test the WCF Service

By running the project Visual Studio will be automatically runs the service and opens the WCF Test Client application. These default behaviors can be changed via WCF Service Project Properties. In Debug tab
/client:”WcfTestClient.exe” command argument has added to Start Options which will run the WCF Test Client application. In the WCF Options tab you can remove the checkbox where starts the WCF Host when a project starts.

The WCF Test client can be used to test the service.

Take note that the RoomReservation database is created in the SQL Server.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.