Delphi:基于互联网的数据源
我有一个数据库客户端应用程序,它在连接到网络上的 SQL Server 数据库的 LAN 上运行。我现在想将数据库在线移动到托管 Internet 服务器,但是,通过 Web 继续与数据库建立正常的 SQL ADO 连接充满了问题。
你们用什么来在网络上公开数据,并且最好仍然能够使用数据库控件客户端?
I have a database client application that runs on a LAN connected to a SQL Server database on the network. I now want to move the database online to a hosted internet server, however, continuing a normal SQL ADO connection to it over the web is full of problems.
What to you guys use to expose the data over the web and preferably still be able to use database controls client side?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
Web 服务(SOAP 和 WSDL)。 Delphi 的最新版本能够创建和使用 Web 服务。
DataSnap 也很有价值,但我认为它是数据库架构中的“中间层”,并且您的中间层可能通过肥皂与您的 Web 和桌面客户端通信,尽管您可以直接访问 datasnap,并且两者都有好处一。直接自定义 Soap 实现(而不是使用基于 SOAP 的 DataSnap 架构)受到许多人的青睐,因为使用它进行通信的语言和平台数量众多。虽然它能够“通过网络”工作,但有些人抱怨它不支持 SSL,至少不是很好(您必须做大量工作才能添加 SSL)。还有来自 RemObjects 的竞争性第三方框架,很多人认为值得,它们是商业的,虽然不便宜,但很划算。
更新:直接让你的SQL数据库直接连接到互联网显然是愚蠢的。但这几乎正是您所要求的。您要么构建一个中间层,并通过一个接口仅公开您想要公开的内容,该接口只允许您想要允许的内容进入您的数据库,要么您退回到 100%“直接攻击我的数据库” ,你这个不友好的互联网,你”。我真的怀疑即使是微软自己也会建议你直接通过互联网公开 SQL 连接。因此,这是您的选择,即中间层或直接层。如果您想在解决方案中使用数据感知控件,您可以做到,并且我建议使用 SOAP 的 DATASnap。
Web Services (SOAP and WSDL). Delphi recent versions are capable of creating and consuming web services.
DataSnap is also valuable, but I think of it as a "middle tier" in your database architecture, and your middle tier probably talks to your web and desktop clients over soap, although you could go directly to datasnap, and there are benefits to either one. Direct Custom Soap implementations (as opposed to using DataSnap architecture over SOAP) is preferred by many because of the sheer number of languages and platforms that communicate using it. While it is capable of working "over the web", there is a valid complaint among some, that it doesn't support SSL, at least not very well (you have to do a lot of work to add SSL). There are also competing third party frameworks from RemObjects, which many people find worthwhile, which are commercial, and while not cheap, are a good deal.
Update: It would obviously be foolish to directly make your SQL database directly connected to the internet. But that's almost exactly what you're asking for. You either build a middle tier, and expose only what you want to expose via an interface that only allows exactly what you want into your database, from exactly those you want to allow in, or you fall back to 100% "attack my database directly, you unfriendly internet, you". I really doubt even Microsoft themselves would recommend you directly expose SQL connectivity over the internet. So it's middle tier, or direct, your choice. If you want to use data aware controls with your solution, you can do it, and I would recommend DATASnap using SOAP.
如果您需要/希望使用标准的数据库感知控件,则需要使用能够将数据映射到 TCustomDataset 后代客户端的框架。 Delphi 中的这个框架是 Datasnap,尽管还有其他框架(即 RemObjects)。通过 SOAP 的纯 Web 服务将允许您从服务器请求数据,但整个接口由您决定,SOAP 让您调用远程函数,仅此而已,它不支持“面向数据库的接口”(发送查询和返回结果集) ),而 Datasnap 和C. 做。
唯一的问题是 Delphi 2007 中的 Datasnap 使用较旧的技术,这些技术从 2009 年起已被新的实现所取代。在 Delphi 2007 中,Datasnap 既支持其 DCOM 实现的 HTTP 代理(通过 ISAPI dll,但 IIRC 它可能与最新的 IIS 版本存在问题),也支持 SOAP 实现(使用 TSOAPConnection)。它们都小心地以特殊格式封装请求和响应,以允许标准的 delphi 数据库访问数据。从 2009 年开始,有一个新的实现可以使用不同的传输(包括 HTTP),但恕我直言,只有从 XE 开始,它才变得有点可用(特别是因为安全和代理问题)。您必须更改所有数据访问组件,并检查应用程序设计。
因为,无论您使用什么技术来访问远程数据库,当数据通过较慢的连接时,应用程序设计都至关重要。如果应用程序被设计为从服务器请求太多数据、经常访问数据等等,那么它的性能可能会很糟糕。通常更好的方法是需要适当的子集,仅在需要时在本地详细说明(更好的是,要求远程服务器执行任何可以轻松远程执行的活动,即使用存储过程或查询),然后将更改发送到服务器。
If you need/wish to use standard DB-aware controls you need to use a framework that is able to map data to a TCustomDataset descendant client side. This framework in Delphi is Datasnap, although there are others (i.e. RemObjects). Pure web services via SOAP will let you ask from data from the server, but the whole interface is up to you, SOAP let you invoke remote functions, nothing more, it does not support a "db oriented interface" (sending queries and returning resultsets), while Datasnap & C. do.
The only issue is Datasnap in Delphi 2007 use older techonologies that have been superseeded by a new implementation from 2009 onwards. In Delphi 2007 Datasnap supports both an HTTP proxy to its DCOM implementation (through an ISAPI dll, but IIRC it can have issues with recent IIS versions), and a SOAP implementation (using TSOAPConnection). They both take care to encapsulate request and response in a special format to allow a standard delphi db access to data. From 2009 there is a new implementation that can use different transports (including HTTP), but which IMHO became somewhat usable only starting from XE (especially because of security and proxy issues). You would have to change all your data access components, and review the application design.
Because, whatever technology you use to access a remote database, when data go across a slower connection, application design has a paramount importance. If the application is designed to request too many data from the server, to access it very often and so on, it could have dreadful performance. Usually is better an approach that requires the proper subset, elaborates it locally only when needed (and even better, asks the remote server to perform any activity that can be easily performed remotely, i.e. using stored procedures or queries), and then send changes to the server.
您可以在服务器和客户端之间配置 VPN,并且您将能够使用相同的功能应用程序通过安全通道连接到基于云的 SQL 服务器。
性能可能是一个问题,这取决于应用程序的设计方式。恕我直言,SQL Server 是一个在 VPN 上运行的可定位数据库,因为它经过了很好的优化,可以最大限度地减少客户端和服务器之间的往返。
Windows 服务器附带 VPN 组件,您还可以选择免费/开源选项,例如 OpenVPN。
You can configure a VPN between the server and clients, and you'll be able to use the same application to connect to a cloud-based SQL server over a secure channel.
Performance can be an issue, it depends on how the application is designed. SQL Server is IMHO a situable database to run over a VPN, because it is very well optimized to minimize round-trips between client and server.
Windows server comes with VPN components, you have free/open source options also, like OpenVPN.
DataSnap
DataSnap
由于您使用的是 SQL Server,因此您应该考虑 Azure 平台,因为它包含基于云的 SQL Server 平台。
自托管 Windows + SQL 服务器需要两者的许可证以及您自己的管理。
Azure 通过 MS 客户端库支持,Azure Web 服务位于较新的 Delphi 版本的标准控制集中。
Since you are using SQL Server, you should consider Azure platform, as it contains cloud bases SQL Server platform.
Self hosted Windows + SQL server require licenses for both, and your own administration.
Azure is supported via MS client libs, and Azure web services are in standard control set of newer Delphi versions.