[What's new in WCF4] .svc-less Activation - or: "Look ma: my [REST] URLs look good!"


[Note: all the information was gathered based on a close-to-Beta 1 build of .NET Framework 4.0 and Visual Studio 2010. Details may vary and change]

Another interesting and most wanted feature in WCF4 is .svc-less activation when WAS-hosting WCF services. This essentially means that I do no longer need to have a physical .svc file for each of my services but just can specify the activation path in config.
So, with this simple WAS-hosted WCF project (without any .svc file)...

WCF4 .svc-less activation
...we can have this web.config section for WCF:

<system.serviceModel>
    <serviceHostingEnvironment>      
      <serviceActivations>
        <add relativeAddress="/Hello.svc" service="HelloService"/>
        <add relativeAddress="/Hello" service="HelloService"/>
      </serviceActivations>

    </serviceHostingEnvironment>
    <services>
      <service name="HelloService">
        <endpoint binding="webHttpBinding" contract="IHelloService" />        
      </service>
    </services>
[...]

This means that we now have one endpoint which can be activated (or 'addressed' in the first place) via two URIs, namely
  • http://myserver/myapp/Hello.svc and
  • http://myserver/myapp/Hello
Of course you can just omit the entry for Hello.svc and then you can activate your WAS-hosted service via
  • http://myserver/myapp/Hello.

Pure joy for the REST-afarians :)
(and yes: this also works with any other binding)

That's it for now for a first introduction to .svc-less activation in WCF4.
Stay tuned for more.