This is a mirror of official site: http://jasper-net.blogspot.com/

How to consume a web service from within SQL Server using SQL CLR

| Sunday, November 28, 2010
DISCLAIMER:
This is just intended as proof of concept. I do feel that if you wish to consume web services from SQL Server, then you should probably put this code in an assembly outside SQL Server and then call that assembly from the CLR within SQL Server. This will make it more maintainable when, for example, the web service changes. If you then need to rebuild the references etc., it will be easier to do this in an external assembly rather than in assemblies stored in SQL Server.

In this scenario we have a web service that return the current temperature for the provided city. We wish to consume this information from within SQL Server and store it in a table. Let’s do this from scratch.

Step 1 is to create the web service itself.

In Visual Studio, create a new ASP.Net Web Service project in a web site (called Weather in this example) call it “WeatherService”.
Delete the default WebMethod and create a new one that will return the temperature for provided city. Call this method “GetTemperatureForCity”.

Read more: Common tips and tricks from a SQL Developer Support perspective

Posted via email from .NET Info

0 comments: