Posts Tagged ‘REST’

Understanding REST

March 17, 2010 Leave a comment

Great Video By Dan Rigsby


Categories: Development Tags: , ,

Basic GET REST based support in WCF

March 15, 2010 Leave a comment

I have recently just added support for REST for a client I am doing some work for at the moment. Their was some okay documentation on the net, but I found a lot of it quite fragmented. This is not an introduction into what REST is but just what you need to get it working in a read only manner in WCF. I will also not be covering security or anything along those lines along with WCF basics.

So the first thing you need to get this working is ensuring that you have enabled data contract support on your DTOs. Then you need to add ASPNETCompatability to your service host. You need the following in you app config file inside the services section.

<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>

You also need to tell your class it can use this mode but decorating the CONCRETE class with the following snippet
[AspNetCompatibilityRequirements(RequirementsMode =aspNetCompatibilityRequirementsMode.Allowed)]

You also need a webHttpBinding endpoint as shown here

<endpoint address="RestTestService" binding="webHttpBinding"     contract="Test.WebServices.Services.ITestService" behaviorConfiguration="testWebEndpointBehaviour" >
            <dns value="localhost" />

Create a endpoint behavior to enable web http as shown here:

        <behavior name="testWebEndpointBehaviour">

Lastly on the service interfaces add the WebGet attributes with the URITemplate you want.

[WebGet(UriTemplate = "Projects",ResponseFormat = WebMessageFormat.Json)]

Finally use a browser to test.


Categories: Development Tags: , , , , ,