WCF configuration or Do it yourself

Posted by Marcus Hammarberg on April 10, 2008
Stats
Configuration of WCF-services is a vast area... anyone who looked into the subject are sure to agree on that. The whole idea with WCF-services is that you can via configuration tweak the behavior and appearance of a service without having to change any internal logic of the service.

When I tried my first services I was "tricked" into choosing one of the pre-manufactured project templates that Microsoft ships with Visual Studio 2008. This was bad decision. The number of configuration properties and stuff generated for me was so great that I didn't understand the true important stuff that I needed to know.

However, this Tuesday we had a interesting visitor at Avega - Christan Weyer. He gave an introduction on WCF. From that lecture I got so much more than from what the templates showed me.

So this is what you really need to configure on your service:

  • Name - the name of the service
  • Endpoint
    • Address - where to reach your service
    • Binding - how to reach your service (protocol)
    • Contract - the contract definition of the service

Here is an example:
<system.serviceModel>
<services>
  <service name="Tjanster.ListDataTjanst">
   <endpoint
      address=""
      binding="wsHttpBinding"            
      contract="Tjanster.Contracts.IListData" 
  
/>
  </service>
</services>

</system.serviceModel>

That's it! A bit more easy to read and understand the 50+ attributes that Visual Studio generates for you.

On the client it gets even worse with the number of attributes that Visual Studio generates. The only things you need to do is to configure the endpoint you're using. Like this:

<system.serviceModel>
<client>
   <endpoint
     address="http://localhost:3214/ListData.svc"
     binding="wsHttpBinding"
     contract="svcListData.ListDataTjanst"
   />
</client>
</system.serviceModel>

I am working on some details for how ConfigurationName, Name and Namespace relates to all this but I'll get back to that when i know how it works...



Published by Marcus Hammarberg on Last updated