views:

296

answers:

5

Can I call a remote webservice from a Stored Procedure and use the values that areretuned?

+4  A: 

If you're using SQL 2005/2008, you could do this from a CLR stored procedure if you have the ability to install and run these. For more info:

http://msdn.microsoft.com/en-us/library/ms190790.aspx

Kev
A: 

Service Broker might provide the sort of functionality you're looking for here.

andrewbadera
A: 

As The AntiSanta says, using a CLR stored procedure this is possible. The real question is whether you can avoid it altogether. It feels upside-down to call a web service from a stored procedure. Ideally you'd have some other service/app/layer that calls both the stored procedure and a web service. Possibly the stored proc returns parameter values for the web service, and you commit your local transaction after the WS call is complete.

This would make both debugging, deployment and support much more simple in the long run, and decouples the direct reference between the stored proc and the web service.

Neil Barnwell
Do you have any other recommendations? I have a Access front end (adp writen in VBA) program with a sql backend. I woudld like to call the webservice from access but dont want to use com addin. I am calling a webserivce on remote server (headoffice) that gives the me a Purchase order number.
MartGriff
A: 

On SQL Server 2000 and up (if CLR is not enabled), you can use COM through stored procedures (sp_OACreate, sp_OAMethod, etc) if you have an existing COM wrapper for your web service.

Cade Roux
A: 

A Good artical on how to call a webservice from SQL:

http://blog.hoegaerden.be/2008/11/11/calling-a-web-service-from-sql-server-2005/

MartGriff