WCF Data Service svc file less activation

Following my previous thread about WCF Data Services 5.0, here is how to activate your service without svc file.

With .NET 4.0 we can activate our WCF services directly from the web.config without svc file, which is quite nice and handy since I like having a class library for my service implementation and a host project (Web App, Win App) to expose my services…

So far, nothing really new, these posts already cover this:

My here was how to activate my WCF Data Service… and for this use the factory attribute of the serviceActivations/add element with the DataServiceHostFactory available in the Microsoft.Data.Services.dll installed by WCF Data Services 5.0.

1. Add the Microsoft.Data.Services DLL to the list of assembly names that are used during compilation:

Use sn.exe -T  Microsoft.Data.Services.dll to get the PublicKeyToken

<system.web>
<compilation debug="true" targetFramework="4.0">

<assemblies>

<add assembly="Microsoft.Data.Services, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</assemblies>

</compilation>

</system.web>

2. Activate your WCF Data Service:

<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true">

<serviceActivations>

<add service="MyNamespace.MyService" relativeAddress="./myservice.svc" factory="System.Data.Services.DataServiceHostFactory" />

</serviceActivations>

</serviceHostingEnvironment>

3. Test you service:

Navigate to your service url: http://localhost/myapp/myservice.svc

Advertisements
Categories CodeTags , , ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this:
search previous next tag category expand menu location phone mail time cart zoom edit close