Is there a WCF Rest C# Client Generation Tool?

2019-03-12 02:24发布

问题:

Before I venture down the path of creating one, I was wondering if anyone knows of a utility program which will take the REST Help page of a WCF Rest Service and create the relevant Client for C# consumption.

Similar to what svcutil.exe does for WCF Services or what wsdl.exe did for web services but for WCF REST Services

Kind Regards,

Andrew

EDIT Some more detail:

Please see this link: http://msdn.microsoft.com/en-us/library/dd203052.aspx

In the restful service using the WCF Rest Starter Kit Preview 2, they supply types which will be serialized. But My intention is be able to create clients form the help page which describes schemas. Clients could then be created for C#, JavaScript, ActionScript etc.. shearly as a strongly typed version of the restful service, not a requirement or necessity. It is a program or uitlity I am wondering exists which does this

回答1:

I think you might be looking for the WebChannelFactory. It can generate a channel class based on a WCF-attributed REST interface.



回答2:

Well, there will not be any use even if you would like to abstract. ALL Rest services can use HTTP verbs like GET, POST, PUT, DELETE

So, basically what your client can have is only a static class which can accept the end point, network credentials, a name value collection which needs to be passed and the verb to use.

This would be more of a utility class rather than a client.

I don't remember seeing WSDL or some contract based on which we can write clients for the REST services.



回答3:

I hope you don't spend too much time basing your code on the current help page of a pre-release piece of code. Are you even sure this help page provides all the information you would need to produce clients?

Also, have you seen Prerelease 2 of the WCF REST Starter kit yet? If no, go look. There's new client-side technology in there.



回答4:

Why would you create clients for a RESTful service? You don't need one - you just need to be able to initial HTTP requests. If you would like to call the same operations via SOAP or some other method then create a new endpoint for the service and a new contract and expose mex for it so that svcutil can consume it.



标签: c# wcf rest