如何配置 IIS 7 以允许从 ISAPI Web 服务器内部进行远程数据库连接

发布于 2024-09-26 13:26:46 字数 1316 浏览 0 评论 0原文

我有一个使用 Delphi 2010 构建的本机 Web 服务应用程序 (ISAPI)。此时,它仅公开两个方法。第一个 EchoString 旨在向我提供 Web 服务正常运行的反馈,并且它向我从 Delphi Web 服务客户端发送给它的字符串添加几个字符。这总是工作得很好。

第二个公开的方法是我真正感兴趣的方法。我向该方法传递一个包含 ClientDataset 的 XML 内容的字符串。从服务器端,我的代码获取此 XML 并将其插入到 ClientDataset 中,然后将此数据发布到服务器端数据库。

我正在使用 IBExpress 组件(IBDatabase、IBTransaction、IBQuery 等)连接到服务器端的 InterBase 数据库。

问题是,一旦我尝试将 IBDatabase 组件连接到其数据库,Web 方法就会失败。我想我已经排除了此错误的所有其他来源。我可以使用从客户端发送的相当大的 ClientDataSet 的 XML 创建并填充 ClientDataset,其中包含嵌套数据集,没有任何问题(我正在使用 MidasLib 单元,因此 ClientDataSet 不会尝试加载 DLL)。我可以创建和配置 IBDatabase 及其各种组件,无需连接。再次,没有问题。一旦我在 Web 服务中将 IBDatabase 组件的 Connected 属性设置为 True,它就会失败。

我在 Windows 7 64 位旗舰版(在我的开发计算机上)下运行 IIS 7.5。我尝试向Everyone(特别是IIS_IUSRS)授予对特定ISAPI DLL 以及Web 服务所在的整个目录的完全控制权。这并没有解决问题。

我怀疑这完全是 IIS 7 的权限问题。我该怎么做才能允许我的 ISAPI Web 服务连接到 InterBase 客户端 API,以便我可以使用该 Web 服务写入我的数据库服务器? ' ' ' ' ' ' ' '
Post Script:看来从 Web 服务连接到 Interbase 不是问题。我仍在追查确切的原因,但我现在已经能够从 Web 服务中成功连接到 Interbase。一旦我知道原因,我会更新这篇文章,但这个问题不再有效。 ' ' ' ' '
我将鲍勃的答案标记为正确的答案。连接字符串错误。事实上(这很尴尬,但我宁愿尴尬也不愿被误导),我被一个 with 子句咬住了。

我将连接信息存储在资源字符串中。我在 with 子句中进行了分配。 DatabaseName 属性的资源字符串名称为 DatabaseName。 with 子句导致 DatabaseName 属性被分配给其自身,而不是资源字符串中的值。我通过在 DatabaseName 资源字符串前面加上单元名称(即 DatabaseName := IBModUnit.DatabaseName;)解决了该问题。

I have a native Web service application (ISAPI) that I have built with Delphi 2010. At this time, it only exposes two methods. The first one, EchoString, is designed to give me feedback that the Web service is functioning properly, and it adds a couple characters to the string that I send to it from my Delphi Web service client. This always works fine.

The second exposed method is the one that I am really interested in. I pass this method a string that contains the XML contents of a ClientDataset. From the server side, my code takes this XML and inserts it into a ClientDataset, after which it posts this data to a server-side database.

I am using IBExpress components (IBDatabase, IBTransaction, IBQuery, etc.) to connect to an InterBase database on the server side.

The problem is that as soon as I attempt to connect the IBDatabase component to its database, the Web method fails. I think I have ruled out all other sources for this error. I can create and populate the ClientDataset with a rather large ClientDataSet's XML sent from the client that includes nested datasets with no problems (I am using the MidasLib unit, so the ClientDataSet is not trying to load a DLL). I can create and configure, short of connecting to, the IBDatabase and its various components. Again, with no problems. As soon as I set the IBDatabase component's Connected property to True from within the Web service, it fails.

I am running IIS 7.5 under Windows 7 64-bit Ultimate (on my development machine). I have tried granting full control rights to Everyone (as well as specifically to IIS_IUSRS) to both the specific ISAPI DLL, as well as to the entire directory in which the Web service resides. This did not solve the problem.

I suspect that this is entirely a privileges issue with IIS 7. What can I do to permit my ISAPI Web service to connect to the InterBase client API so that I can use the Web service to write to my database server?
' ' ' ' ' ' ' ' ' ' '
Post Script: It appears that connecting to Interbase from the Web service is not the problem. I am still tracking down the precise cause, but I have now been able to successfully connect to Interbase from within the Web service. I'll update this post once I know the cause, but this question is no longer valid.
' ' ' ' ' '
I am marking Bob's answer as the correct one. The connection string was wrong. Actually (and this is embarrasing, but I'd rather be embarrassed than misleading), I got bit by a with clause.

I stored my connection information in resource strings. I made the assignment in a with clause. The name of the resource string for the DatabaseName property was DatabaseName. The with clause caused the DatabaseName property to be assigned to itself, instead of the value in the resource string. I fixed the problem by prefacing the DatabaseName resource string with the unit name (ie, DatabaseName := IBModUnit.DatabaseName;).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

暖风昔人 2024-10-03 13:26:46

我假设您可以使用相同的连接字符串从该计算机上的“本机”VCL Forms 应用程序连接到 InterBase 数据库?

也许是一个愚蠢的问题,但是您将 InterBase 作为服务运行吗? (否则,ISAPI DLL 将无法“看到”它并连接到它)。

I assume you can use the same connection string to connect to the InterBase database from a "native" VCL Forms application on that machine?

A silly question perhaps, but do you run InterBase as a service? (Otherwise, the ISAPI DLL will not be able to "see" it to connect to it).

死开点丶别碍眼 2024-10-03 13:26:46

[编辑]
对不起。我写了一篇愚蠢的文章,暗示 IIS 没有网络权限而且我似乎无法删除此帖子!

但是 - 我确实在某处读到,后来的 Windows 版本上的服务权限有所减少,并且本地系统帐户不再具有网络访问权限。鉴于帖子标题包含“远程”,也许您需要向您的 DLL 或服务和/或 Interbase 服务或涉及的其他文件之一授予额外的权限?

[Edit]
Sorry. I wrote a stupid thing suggesting that IIS won't have network permissions <duh!> and I can't seem to delete this post!

But - I did read somewhere that the service permissions on later Windows versions have been reduced somewhat and the localsystem account no longer has network access. Seeing as the post title contains "remote" maybe you need to grant extra permissions to your DLL or service and/or the Interbase service or one of the other files involved?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文