简体   繁体   English

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

[英]How do I configure IIS 7 to allow a remote database connection from within an ISAPI Web Server

I have a native Web service application (ISAPI) that I have built with Delphi 2010. At this time, it only exposes two methods. 我有一个用Delphi 2010构建的本机Web服务应用程序(ISAPI)。目前,它仅公开两种方法。 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. 第一个是EchoString,旨在为我提供有关Web服务正常运行的反馈,并在我从Delphi Web服务客户端发送给它的字符串中添加了几个字符。 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. 第二个公开的方法是我真正感兴趣的方法。我将此方法传递给包含ClientDataset的XML内容的字符串。 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. 从服务器端,我的代码采用此XML,并将其插入ClientDataset,然后将其发布到服务器端数据库。

I am using IBExpress components (IBDatabase, IBTransaction, IBQuery, etc.) to connect to an InterBase database on the server side. 我正在使用IBExpress组件(IBDatabase,IBTransaction,IBQuery等)连接到服务器端的InterBase数据库。

The problem is that as soon as I attempt to connect the IBDatabase component to its database, the Web method fails. 问题是,一旦我尝试将IBDatabase组件连接到其数据库,Web方法就会失败。 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). 我可以使用从客户端发送的包含嵌套数据集的相当大的ClientDataSet的XML创建并填充ClientDataset,而不会出现问题(我使用的是MidasLib单元,因此ClientDataSet并未尝试加载DLL)。 I can create and configure, short of connecting to, the IBDatabase and its various components. 我只需创建并配置IBDatabase及其各种组件即可。 Again, with no problems. 再次,没有问题。 As soon as I set the IBDatabase component's Connected property to True from within the Web service, it fails. 一旦从Web服务中将IBDatabase组件的Connected属性设置为True,它就会失败。

I am running IIS 7.5 under Windows 7 64-bit Ultimate (on my development machine). 我正在Windows 7 64位Ultimate(在我的开发计算机上)下运行IIS 7.5。 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. 我尝试过将特定的ISAPI DLL以及Web服务所驻留的整个目录的“所有人”(尤其是IIS_IUSRS)的全部控制权授予。 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? 我怀疑这完全是IIS 7的特权问题。如何允许ISAPI Web服务连接到InterBase客户端API,以便可以使用Web服务写入数据库服务器? ' ' ' ' ' ' ' ' ' ' ' ''''''''''
Post Script: It appears that connecting to Interbase from the Web service is not the problem. 脚本发布:从Web服务连接到Interbase似乎不是问题。 I am still tracking down the precise cause, but I have now been able to successfully connect to Interbase from within the Web service. 我仍在寻找确切的原因,但是现在我已经能够从Web服务中成功连接到Interbase。 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. 实际上(这很令人尴尬,但是我宁可感到尴尬而不是误导),我对with子句有些不满。

I stored my connection information in resource strings. 我将连接信息存储在资源字符串中。 I made the assignment in a with clause. 我在with子句中进行了赋值。 The name of the resource string for the DatabaseName property was DatabaseName. DatabaseName属性的资源字符串的名称为DatabaseName。 The with clause caused the DatabaseName property to be assigned to itself, instead of the value in the resource string. with子句导致将DatabaseName属性分配给自身,而不是资源字符串中的值。 I fixed the problem by prefacing the DatabaseName resource string with the unit name (ie, DatabaseName := IBModUnit.DatabaseName;). 我通过在DatabaseName资源字符串前添加单元名称(即DatabaseName:= IBModUnit.DatabaseName;)解决了该问题。

I assume you can use the same connection string to connect to the InterBase database from a "native" VCL Forms application on that machine? 我假设您可以使用相同的连接字符串从该计算机上的“本地” VCL Forms应用程序连接到InterBase数据库?

A silly question perhaps, but do you run InterBase as a service? 也许这是一个愚蠢的问题,但是您是否将InterBase作为服务运行? (Otherwise, the ISAPI DLL will not be able to "see" it to connect to it). (否则,ISAPI DLL将无法“看到”它以进行连接)。

[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! 我写了一个愚蠢的东西,暗示IIS没有网络权限<duh!>,而且我似乎无法删除这篇文章!

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. 但是-我确实在某处读到,某些Windows更高版本的服务权限已减少,并且本地系统帐户不再具有网络访问权限。 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? 看到帖子标题包含“远程”,也许您需要授予DLL或服务和/或Interbase服务或所涉及的其他文件之一的额外权限?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用证书保护SQL Server数据库连接的安全? - How do I secure SQL Server database connection using certificate? 如何从远程源配置ASMX Web服务URL - How to configure ASMX web service URL from remote source 如何配置任何Web服务器以接受没有主机和绝对请求URIS的POST请求? - How do I configure ANY web server to accept POST requests that have No Host and absolute request URIS? 为什么我会收到无法从 Web 应用程序而不是控制台应用程序连接到远程服务器的异常? - Why do I get an Unable to connect to the remote server exception from a web app and not console app? 如何从IIS上发布的Web服务连接到Oracle数据库 - How to connect to a Oracle Database from Web Services Published on IIS 如何从数据库“生成”Web API? - How do I “generate” a web API from a database? 如何从主机将Web服务部署到虚拟服务器? - How do I deploy a web service to a virtual server from the host? 浏览Web服务以及如何在IIS 7.5中配置网站时出错 - Error browsing web service and how to configure web site in IIS 7.5 在远程 windows 服务器 2008 上部署 wcf web 服 - Deploy wcf web services on remote windows server 2008 with IIS 7 如何使用JavaScript从远程服务器使用.net Web服务 - How to consume a .net web service from a remote server with javascript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM