服务架构(WCF 和 Delphi)
我正在开发一个有两个用户界面的项目。 Web (asp.net MVC) 和桌面 (Delphi 2010)。这是客户要求的,所以我们需要使用Delphi。
我们想到的是面向服务的架构,WCF也是如此。要在 Asp.Net MVC 中访问 WCF 服务很好,但是我需要在 Delphi 中做什么?我的主要疑问是,如何使用 Delphi 访问 WCF 中的服务。有什么办法可以让它变得简单吗?
我的服务方法可以返回 IEnumerable 或 T[] 吗? 有这方面的推荐吗!?
谢谢!
I'm working on a project that will have two user interfaces. Web (asp.net MVC) and Desktop (Delphi 2010). It was requested by the customer, so we need to use Delphi.
We're thinking of architecture oriented by services, and so is WCF. To access WCF Services in Asp.Net MVC it is fine but what Need I do in Delphi? My principal doubt is, how to access a service in WCF using Delphi. Is there any way to make it easy?
Can my methods in service return IEnumerable or T[]?
Are there recommendations for this !?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
WCF 中的 Web 服务支持提供了许多 Delphi 不支持的功能 - MTOM、WS-Addressing、WS-Reliable Messaging 和 WS-Security 仅举几例。如果您正在设计系统的两个部分(Web 服务服务器和客户端),那么您会很高兴,因为您可以选择要使用的功能(只要它们不是由其他方指定的)。
幸运的是,WCF 并没有“强制”使用 SOAP。这篇 Wikipedia 文章中的 互操作性 部分提到了使用标准 XML(或 RSS,或JSON)。还有一个REST 的 WCF 绑定。
规划面向服务的架构是一项艰巨的任务,因此我强烈建议阅读有关该主题的常用文献,并找到一种方法使其尽可能简单且易于测试和发展。
The web services support in WCF provides many features which are not suported by Delphi - MTOM, WS-Addressing, WS-Reliable Messaging and WS-Security just to name a few. If you are designing both parts of the system (web service server and client(s)), you are in the happy situation that you can choose which features to use (as long as they are not dictated by other parties).
WCF fortunately does not 'dictate' to use SOAP. The Interoperability section in this Wikipedia article mentions for example WCF with standard XML (or RSS, or JSON). There is also a WCF binding for REST.
Planning a service oriented architecture is a tough task, so I highly recommend to read through the usual literature for this topic, and find a way to keep it as simple as possible and easy to test and evolve.
也许你可以看看 RemObjects SDK:它是一个类似 WCF 的解决方案,你可以使用它.Net、Delphi、Objective-C、PHP、C++ 等。
因此,您可以使用 RemObjects for .Net 构建服务器,例如 TCP + 二进制消息以获得最佳性能(SOAP/XML 慢得多!),以及 Delphi 2010客户端(甚至支持 FreePascal)。双方(Delphi 和.Net)彼此兼容,甚至对于二进制消息也是如此!
我对 RemObjects 的体验非常好:非常易于使用和构建服务(比 WCF 更容易?),很好支持和质量等。
Maybe you can take a look at RemObjects SDK: it is a WCF-like solution, and you can use it for .Net, Delphi, Objective-C, PHP, C++, etc.
So you can build a server with RemObjects for .Net, for example TCP + Binary message for best performance (SOAP/XML is much slower!), and a Delphi 2010 client (even FreePascal is supported). Both sides (Delphi and .Net) are compatible with each other, even for the binary message!
My experience with RemObjects is very good: very easy to use and to build services (easier than WCF?), good support and quality etc.
Delphi 的最新 SOA 框架之一是我们的开源 mORMot 框架。
您可以使用
接口
来定义您的服务契约,并使用命名管道、GDI 消息或 TCP/HTTP 在本地或远程访问它们。您的合约在客户端和服务器端均如此定义,就像在 WCF 中一样。它实时处理每个呼叫、每个会话、每个用户或每个组实例。请参阅此示例代码。
它是安全的(在 URI 级别使用安全身份验证)、轻便且快速。
它使用 JSON 作为通信(比 XML 更轻)和 RESTful 访问。它已准备好供 AJAX 或 WCF 客户端使用(自定义接口封送之后的最新版本)。它针对速度和可扩展性进行了优化(具有平衡的自定义托管和每个接口/每个方法的访问安全性等高级功能)。
mORMot 框架文档 有 800 多页,以及一些专门的高级解释Delphi 中的面向服务的架构设计模式。它与客户端-服务器 ORM 集成,因此您手头拥有制作适当的 Delphi 中的域驱动应用程序以及其他技术。
One of the latest SOA framework for Delphi, is our Open Source mORMot framework.
You can use
interface
to define your Service contract, and access to them locally or remotely using named pipes, GDI messages, or TCP/HTTP. Your contract is defined as such on both client and server side, just like in WCF.It handles per-call, per-session, per-user or per-group instance live. See this sample code.
It is secure (with secure authentication at URI level), light and fast.
It uses JSON as communication (lighter than XML), and a RESTful access. It is ready to be consumed by AJAX or WCF clients (the latest after custom marshaling of the interfaces). It was optimized for speed and scalability (with advanced features like balanced custom hosting and per-interface/per-method access security).
The mORMot framework documentation has more than 800 pages, and some dedicated high-level explanation of Service Oriented Architecture design pattern in Delphi. It is integrated with a Client-Server ORM, so you have at hand all needed low-level tools to make a proper Domain-Driven application in Delphi, and other technologies.