views:

130

answers:

1

Hi there,

I am used to using soap services where you add a service reference and it creates strong types classes (return types) of each method..

Of course REST doesn't work like this

How do i consume a WCF REST Service?

Is there no way to use strongly typed classes for the return types?

I am using Visual Studio 2010 specifically

Any ideas or thoughts really appreciated

Thanks in advance

+1  A: 

See http://stackoverflow.com/questions/651273/is-there-a-wcf-rest-c-client-generation-tool. If you own both the service and the client, you can reuse the contracts and instantiate an client channel with WebChannelFactory.

larsw
If you are going to use .net contracts and (de)serialize to .net types on both ends of the wire, why would you bother with the REST bindings? Wouldn't the wshttpbinding be a much better choice?
Darrel Miller
My whole point is to get away from SOAP ... I don't use half the stuff it provides so whats the point... I only wanted to be able to return my data into objects rather than going through XML and with the method ReadAsDataContract .. this is now sorted
mark smith
@mark Ok, so you are free to call me pedantic, but what you are trying to do is not REST. I'm not saying it is not a valid a approach, just be aware that when someone says "you can't do that it's not RESTful", you are free to ignore them :-)
Darrel Miller
Ok point taken. I of course wish to hear your comments. Thanks again. I will investigate further.. I understand the way i am doing things is probably not PURE REST but is supported and recommended via WCF (using REST)... that is why the method ReadAsDataContract exists... nothing special happening as far as i can see... Only that the methods takes the XMl from the REST Service and populates some .net classes... no magic really... Again thanks for your comments... much appreciated
mark smith