用delphi编写客户端-服务器应用程序
在delphi下编写客户端-服务器应用程序的最佳方法是什么?我知道有 DataSnap 技术,但它不是专业版。您有什么经验可以分享吗?
What is the best way to write a client-server application under delphi? I know there's a DataSnap technology, but it's not in Professional version. Do You have any experience that You can share?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
这是一个相当广泛的问题,因为它可能取决于您的数据库决策。
DataSnap 确实允许 N 层解决方案,如果您正在寻找客户端服务器
根据数据库选择,专业版本中几乎提供了您所需的一切。
对于客户端服务器:
客户端服务器架构是客户端直接与服务器通信的情况。
有多种可用的框架,它们都遵循相同的模式。
数据库连接->查询-> (可选提供程序 -> TClientDataset) -> TDataSource->可视化控制
DBX
ADO
通用组件
控件根据数据库选择,还有其他几个可用选项。
但是,您似乎在询问 N 层(中间层)类型的解决方案
对于 N 层
N 层架构是指客户端与中间层通信,然后再与服务器通信。它被称为 N 层,因为您可以选择拥有多个中间层或应用程序服务器。
商业选项(需要额外花费 $$)
我个人不知道有任何免费或开源选项,尽管我怀疑存在一些。
This is fairly wide open question, as it can depend on your database decision.
DataSnap really allows for N-Tier solutions, if your looking for Client Server you have
most everything you need in the professional version depending on the Database Choice.
For Client Server:
Client Server Architecture is when the Client communicates directly with the server.
There are several frameworks available they all follow the same pattern.
DB Connection -> Query -> (Optional Provider -> TClientDataset) -> TDataSource -> Visual Control
DBX
ADO
Common Components
There are several other options available depending on Database Choice.
However, you seem to be asking about N-Tier (Middle-Tier) type solutions
For N-Tier
N-Tier architecture is when the Client communicates with Middle Tier that then communicates with the Server. It's referred to N-Tier as you have option to have multiple Middle Tiers or Application Servers.
Commercial Options (Required additional $$ to be spent)
I personally don't know of any free or open source options, although I suspect some exist.
两种选择:
Two options:
您可以使用
WST 是一个免费开源工具包,用于使用和创建 Web 服务,支持 SOAP、XmlRPC 和 JsonRPC ( JsonRPC 支持仅适用于 FPC)。它与德尔福兼容。最好从 svn 中查看,因为 0.5 版本实际上已经过时了。
You can use
WST is a free and open source toolkit for web services consumption and creation with support for SOAP and XmlRPC and JsonRPC (the JsonRPC support is available only for FPC). It is compatible with Delphi. Better check out from svn as the 0.5 release is actualy outdated.
使用 Delphi Professional,可以编写简单的(没有 WS-* 标准,没有 Soap 1.2 服务器)SOAP 客户端和服务器应用程序。
在许多情况下,Soap 提供了跨平台/跨语言集成、标准化、按合同设计和成熟的实施指南、最佳实践和模式方面的优势。
对于 Soap,有一些很棒的(免费)工具,例如 SoapUI 和用于 Web 服务描述语言 (WSDL) 文档(例如 NetBeans)的 IDE 编辑器。
With Delphi Professional it is possible to write simple (no WS-* standards, no Soap 1.2 servers) SOAP client and server applications.
In many cases, Soap offers advantages regarding cross-platform / cross-language integration, standardization, design-by-contract and mature implementation guidelines, best practices and patterns.
For Soap there are great (and free) tools like SoapUI and IDE editors for Web Service Description Language (WSDL) documents like NetBeans.
看看我们的开源客户端/服务器 ORM。
它是多层兼容的,您可以在客户端和服务器级别拥有 ORM。
ORM 随处可见,JSON 是为客户端/服务器传输选择的格式。
您可以将应用程序作为本地应用程序启动,然后只需更改用于访问数据的类类型,它将成为通过命名管道、HTTP/1.1 或 GDI 消息进行通信的客户端/服务器应用程序。
它被设计为与 SQLite3 一起工作,作为服务器端的一个小型但高效的数据库引擎,但您可以在没有 SQlite3 的情况下使用 ORM。如果您愿意,可以提供纯 Delphi 内存引擎。
该框架尝试自下而上实现N层架构。
即将推出的 1.13 版本将拥有强大的过滤和验证机制,非常适合 N-分层架构。有一些用户界面单元具有完整的报告(和 pdf 生成),能够使用数据的 ORM 布局从代码创建大部分用户界面。
它基于 RESTful 范例,通过 JSON 访问客户端的数据。如果 RESTful 方法是,则有一种简单的方法实现客户端/服务器服务还不够,就像 DataSnap 一样。
它支持 Unicode(在所有内部级别使用 UTF-8),并且适用于每个版本的 IDE,从 Delphi 6 到 XE(甚至是 Starter 版本)。
Take a look at our Open Source Client/Server ORM.
It's multi-tier compatible, and you can have ORM at both Client and Server level.
ORM is used everywhere, and JSON is the format chosen for the Client/Server transmission.
You can start your application as local application, then just by changing the class type used to access to the data, it will become a Client/Server application communicating via Named Pipes, HTTP/1.1 or GDI messages.
It was designed to work with SQLite3 as a small but efficient database engine on the server side, but you can use the ORM without SQlite3. There is a pure Delphi in-memory engine provided, if you prefer.
This framework try to implement N-Tier architecture from the bottom up.
The upcoming 1.13 version will have a powerful filtering and validation mechanism, perfect for N-Tier architecture. There is some User-Interface units, with full reporting (and pdf generation), able to create most of the User Interface from code, using the ORM layout of the data.
It's based on the RESTful paradigm to access the data from the Client, via JSON. And there is a easy way of implementing Client/Server Services if the RESTful approach is not enough, just like DataSnap.
It's Unicode ready (uses UTF-8 at all internal level), and works with every version of the IDE, from Delphi 6 up to XE (even the Starter edition).
从几个月前开始,我停止使用这种基于 Delphis 和特定 DB 技术的架构(n 层、2 层)来实现新项目。我相信这些架构不是未来的教授。我现在使用的架构是 2 墩架构。服务器是一个普通的 HTTP 服务器。它用作应用程序服务器*,并可选择提供 Web 客户端。在德尔福开发客户比较困难,但值得。由于特定工具无法像为数据库连接提供的那样可用,因此我使用 indy 从 HTTP 服务器发送和接收数据。我执行
GET
请求来获取数据,然后解析它以将其显示在 GUI 上。然后是更新或插入新数据的POST
请求。 HTTP 服务器处理所有业务逻辑:-)除了成为未来的教授之外,这种架构更便宜并且独立于平台。如果你分析一下,这与大多数移动应用程序使用的架构相同。因此,如果您打算将来编写移动客户端,请考虑使用脚本语言(Python、PHP、Ruby 等)开发应用服务器。
这是我的建议。不要忘记:伟大的事情需要伟大的承诺!
应用程序服务器
是一种服务,它为您的应用程序(瘦客户端)提供获取和发送数据的接口。它还控制业务逻辑。您的应用程序不关心数据库或控制记录关系和数据约束。这一切都是由应用程序服务器透明地完成的。Since a few months ago I stopped to implement new projects with this kind of architecture (n-tiers, 2-tiers) Based on Delphis and specific DB technologies. I believe these architecture are not future prof. The architecture i'm using now is a 2-pier one. The server is a normal HTTP server. It works as app server* and optionally provides a web client. Developing clients in Delphi it's harder but worth it. Since specif tools are not available as the ones offered for DB connections, I use indy to send and receive data from the HTTP server. I do a
GET
request to fetch data and then parse it to show it on the GUI. Then aPOST
request to update or insert new data. The HTTP server handle all business logic :-)Apart of being future prof, this architecture is cheaper and platform independent. And if you analyze it, this is the same architecture used by most mobile apps. So, if you plan to write a mobile client in the future, consider developing the app server with script languages (Python, PHP, Ruby, etc.).
That's my recommendation. Don't forget: Great things require great commitments!
App Server
is a service which provides your application (thin client) with with an interface to get and send data. Also it control the business logic. Your application don't care about DB's or controlling record relations and data constrains. That's all is transparently done by the app server.对于通用客户端-服务器通信,您可以使用我们的轻量级 MsgConnect 产品。这是一个跨平台的MOM(面向消息的中间件)。
For general-purpose client-server communication you can use our lightweight MsgConnect product. This is a cross-platform MOM (message-oriented-middleware).