I want to generate a data contract class / client model from a wcf rest service. I need this so I can consume a Rest service in a typed way using httpclient in c#. I can’t use my service-side class definition as it contains implementation methods that
I don’t want published to the outside world.
So in a nutshell I want to know how to generate the Contract class from the service metadata.
HttpClient client =
var contacts = client.CreateQuery<Contact>();
I’ve seen a couple of ways of doing this, and have problems with both
Paste as xml type – can’t seem to get this installed on vs2010, win7 64x
Generating a source file from the XML schema using scvUtil.exe /dconly
I can get this working if copy the xml schema from the services help page into a file, and run scvUtil.exe /dconly against it. This is really time consuming , so far from ideal.
Point svcutil at the assembly containing the wcf rest services, with the /dconly option. The data contracts only seem to get generated if the data contract type definition is defined in the same assembly as the service… which mine is not.
Point svcutil at a running instance of the wcf rest service. I can’t get this working as svcutil seems to be expecting a wsdl.
Other people must have had this problem, how have you gotten around this?