处理 BLOB 数据的 Web 服务
需要开发一些“服务”程序来接收和处理来自 Oracle DB 服务器的 BLOB 数据。客户端将用 Delphi 2010 编写。我可以自由选择用于生成该项目的服务器部分的技术。这就是我在这里发布这个问题的原因。你们能给我指点一些博客文章、文章、论坛吗?在那里我可以获得有关创建此类服务的各种信息?我有使用 Microsoft 的 WCF 服务的经验,但它通过 WSDL 与 Delphi 客户端的集成很差。现在我停止了用 C# 编写的 ASMX Web 服务,需要获取一些示例如何在服务器和客户端之间传输 BLOB 数据。如果服务器和客户端通过原始套接字进行通信,而不是将所有数据封装在 SOAP 中,那就更好了。预先感谢并强烈希望你们能提供帮助!
There is a need to develop some "Service" program that will receive and process BLOB data from Oracle DB server. The clients will be written in Delphi 2010. I have freedom of choice that technologies I will use to produce server part of this project. And that's why I have posted this question here. Could you guys point me some blog posts, articles, forums where I can get various information about creating such type of services? I have an experience with Microsoft's WCF services, but it has bas intergration with Delphi clients via WSDL. Now I stopped on ASMX Web Service written in C# and need to get some samples how can I transfer BLOB data between server and client. It would be better if server and client communicating thru raw socket, instead of incapsulation all data in SOAP. Thanks in advance and strongly hope for you help, guys!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我建议您使用 RemObjects SDK 来开发服务器和应用程序。客户端 Web 服务应用程序,它具有 Delphi 和 Delphi 上不提供的许多功能。 .Net,它们也支持不同的消息传递,因此您可以使用二进制消息而不是 SOAP 来传输 BLOB 数据,这更快、更紧凑。
它们还有 .Net 版本的服务器和客户端,因此您可以在它们之间混合使用。
I would recommended you to use RemObjects SDK for develop server & client web services applications, it has many features not available on Delphi & .Net, also they support different messaging, so you can use binary message instead of SOAP to transfer the BLOB data, which is much faster and more compact.
They also .Net version of server and client so you can mix between them.
处理 BLOB 字段的一种很好的标准方法是 REST 协议。
借助 REST 协议,您可以从 URI 中 GET、POST、PUT 或 DELETE 二进制 BLOB。也就是说,如果您的 URI 专用于 BLOB 字段,您将能够使用原始二进制传输,而不能使用 MTOM 或 Base64 传输。
例如,您可以通过以下 URI 的 GET 获取 ID=123 的 BLOB 内容:
它也可以在标准 Web 浏览器中工作。所以如果BLOB是图片,应该直接在浏览器中显示。
使用同一 URI 处的 POST 可以添加新的 blob,或者使用 PUT 可以更新 blob。使用 DELETE 动词...您可以将其删除。这就是 RESTful 通过 HTTP 的含义。
例如,这就是我们的 mORMot 框架的工作原理。它还能够快速直接访问到服务器端的 Oracle 数据库,带有一些专用的类。这种基于 ORM 的框架的优点在于,高级客户端可以使用对象,并且处理的不仅仅是 BLOB,而且它还可以处理 URL 级安全性和身份验证。
但是,如果您不需要整个 RESTful ORM 功能,您可以使用 mORMot 中提供的一些单元轻松编写自己的服务:
这都是开源的,可以在 Delphi 5 及更高版本上运行。有很多可用文档(更多超过 600 页),包括 REST、ORM 或 n-Tier 等概念的高级演示。
A nice and standard way of handling BLOB fields is the REST protocol.
Thanks to the REST protocol, you can GET, POST, PUT or DELETE a binary BLOB from its URI. That is, if your URI is dedicated to the BLOB field, you'll be able to use raw binary transmission, and no MTOM or Base64 transmission.
For instance, you can get a BLOB content with ID=123 with a GET at such an URI:
It will work also from a standard web browser. So if the BLOB is a picture, it should be displayed directly in the browser.
With a POST at the same URI, you add a new blob, or with a PUT you update the blob. With a DELETE verb... you delete it. This is what RESTful means over HTTP.
This is, for instance, how our mORMot framework works. It is also able to fast have direct access to the Oracle database on the server side, with some dedicated classes. What is nice with such an ORM-based framework, is that high-level clients can use objects, and handle much more than only BLOBs, and that it handles URL-level security and authentication.
But you can easily write your own service using some units available in mORMot, if you don't need the whole RESTful ORM feature:
This is all Open-Source, working from Delphi 5 and later. There is a lot of documentation available (more than 600 pages), including high-level presentation of such concepts as REST, ORM or n-Tier.
这是相当高级的,但问题也是如此:
如果它是一个“原始套接字”,那么它并不是真正的“Web 服务”;当然,还有 REST 或 HTTP POST 的中间立场。
如果您正在查看 Web 服务,并且数据非常重要,那么您可能需要查看 MTOM 以避免 base-64 开销(WSE 3 或(更简单的)WCF 通过 basicHttpBinding 支持该开销)。我希望大多数工具都能合理理解 MTOM 的基本 Web 服务。
This is fairly high-level, but so is the question:
If it is a "raw socket" it isn't really a "web service"; although there is of course the middle ground of REST or a HTTP POST.
If you are looking at a web-service, and the data is non-trivial, then you probably want to look at MTOM to avoid the base-64 overhead (which is supported in WSE 3, or (simpler) WCF via basicHttpBinding). I would expect most tools to have a reasonable comprehension of a basic web-service with MTOM.
如果您想将数据库中的某些数据(在本例中是 oracle 中的 blob 数据)公开为 Web 服务,WSO2 DSS[1] 提供了更简单的解决方案。这是在 Apache 许可下并且免费提供的。由于所有 WSO2 产品均基于 WSO2 Carbon 平台,因此您创建的服务也支持 MTOM、WS-Security 和其他 Web 服务相关功能。
[1] http://wso2.org/library/dss
if you want to expose some data in a data base (in this case blob data in oracle) as a web services WSO2 DSS[1] provides an easier solution. This is under Apache license and it is available for free. Since all the WSO2 Products are based on WSO2 carbon platform the services you create supports MTOM, WS-Security and other Web service related features as well.
[1] http://wso2.org/library/dss