Monday, March 24, 2014

Basic Elements of WCF Appconfig

All config items should be inside ,

<system.serviceModel>

This is the WCF namespace provided by Microsoft.

Inside the <system.serviceModel> element you have the <services> element. This is where you configure all your services.
For each service you have a <service> element inside <services> element.
A particular service can be exposed using more than one endpoint. (Ex: http , net.tcp etc)
So for each endpoint in a service you configure a <endpoint> element.
An endpoint element will have three essential things,

  1. address
  2. binding
  3. contract  
Here is a  sample config (not complete) to get an idea.

The service name is HelloService (class and namespace both are HelloService) and has two endpoints (http and net.tcp) for the service.


<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.serviceModel>
    <services>
      <service name="HelloService.HelloService">
        <endpoint address="HelloService" binding="basicHttpBinding" contract="HelloService.IHelloService">
        </endpoint>
        <endpoint address="HelloService" binding="netTcpBinding" contract="HelloService.IHelloService">
        </endpoint>
      </service>
    </services>
  </system.serviceModel>
</configuration>

0 comments:

Post a Comment