是否有 WCF Rest C# 客户端生成工具?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/651273/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 11:51:34  来源:igfitidea点击:

Is there a WCF Rest C# Client Generation Tool?

c#wcfrest

提问by REA_ANDREW

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.

在我冒险创建一个路径之前,我想知道是否有人知道一个实用程序,该程序将获取 WCF Rest 服务的 REST 帮助页面并创建用于 C# 使用的相关客户端。

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

类似于 svcutil.exe 为 WCF 服务所做的事情或 wsdl.exe 为 Web 服务所做的事情,但对于 WCF REST 服务

Kind Regards,

亲切的问候,

Andrew

安德鲁

EDIT Some more detail:

编辑一些更多细节:

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

请参阅此链接: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

在使用 WCF Rest Starter Kit Preview 2 的 restful 服务中,它们提供将被序列化的类型。但我的意图是能够从描述模式的帮助页面创建客户端。然后可以为 C#、JavaScript、ActionScript 等创建客户端。作为 RESTful 服务的强类型版本,不是必需的或必需的。这是一个程序或实用程序,我想知道是否存在执行此操作的程序

回答by Andrew Hare

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 mexfor it so that svcutil can consume it.

为什么要为 RESTful 服务创建客户端?你不需要 - 你只需要能够初始 HTTP 请求。如果您想通过 SOAP 或其他一些方法调用相同的操作,则为该服务创建一个新的端点和一个新的契约并mex为其公开,以便 svcutil 可以使用它。

回答by Ramesh

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

好吧,即使你想抽象也没有任何用处。所有 Rest 服务都可以使用 HTTP 动词,如 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.

我不记得看到 WSDL 或一些我们可以为 REST 服务编写客户端的契约。

回答by John Saunders

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.

另外,您看过 WCF REST Starter 套件的 Prerelease 2 了吗?如果没有,去看看。那里有新的客户端技术。

回答by GuyBehindtheGuy

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

我想您可能正在寻找WebChannelFactory。它可以基于 WCF 属性的 REST 接口生成通道类。