从SQL Server 2005存储过程访问Web服务

时间:2021-08-17 03:51:40

Currently I have a stored procedure that makes some updates to a table, and after it makes them, I need to call a web service.

目前我有一个存储过程对表进行一些更新,在它生成之后,我需要调用一个Web服务。

The procedure uses a transaction, and I need to call the web service at the end of the transaction. If the web service call should fail, the transaction would get rolled back.

该过程使用事务,我需要在事务结束时调用Web服务。如果Web服务调用失败,则事务将回滚。

I need to know how do I add a SOAP web service reference to SQL and how do I call the service from the stored procedure.

我需要知道如何向SQL添加SOAP Web服务引用以及如何从存储过程调用服务。

Distributed transactions / Enterprise services are excluded for architectural reasons.

出于架构原因,排除分布式事务/企业服务。

Later Edit: Also, CLR assemblies are excluded. CLR has been deactivated on the server i need to deploy the procedure.

稍后编辑:此外,CLR程序集被排除在外。在我需要部署该过程的服务器上已停用CLR。

2 个解决方案

#1


2  

This Simple-Talk tutorial shows you how to accomplish this.

这个简单对话教程向您展示了如何实现这一目标。

You can also do this using COM but it requires the use of sp_OACreate which many DBAs won't let you run (it requires a configure option to be turned on)

您也可以使用COM执行此操作,但它需要使用sp_OACreate,许多DBA不允许您运行它(它需要打开配置选项)

#2


0  

If you have control over the data source that this web service is using (bound to) you may consider the option of adding this data source as linked server to your SQL 2005 server. This way you will be able to execute a SQL using OPENQUERY against this data source without accessing it through web service.

如果您可以控制此Web服务正在使用(绑定)的数据源,则可以考虑将此数据源作为链接服务器添加到SQL 2005服务器的选项。这样,您就可以使用OPENQUERY对此数据源执行SQL,而无需通过Web服务访问它。

#1


2  

This Simple-Talk tutorial shows you how to accomplish this.

这个简单对话教程向您展示了如何实现这一目标。

You can also do this using COM but it requires the use of sp_OACreate which many DBAs won't let you run (it requires a configure option to be turned on)

您也可以使用COM执行此操作,但它需要使用sp_OACreate,许多DBA不允许您运行它(它需要打开配置选项)

#2


0  

If you have control over the data source that this web service is using (bound to) you may consider the option of adding this data source as linked server to your SQL 2005 server. This way you will be able to execute a SQL using OPENQUERY against this data source without accessing it through web service.

如果您可以控制此Web服务正在使用(绑定)的数据源,则可以考虑将此数据源作为链接服务器添加到SQL 2005服务器的选项。这样,您就可以使用OPENQUERY对此数据源执行SQL,而无需通过Web服务访问它。