background preloader

Invocar WS desde SQLServer

Facebook Twitter

Consumir un Servicio Web mediante SQL SERVER 2005. Call GeoNames Web Services from a SQL Stored Procedure. Today I needed to get a country name from the lat, long of a point, ideally in a stored procedure.

Call GeoNames Web Services from a SQL Stored Procedure

Getting the country name is just a matter of calling the geonames web service via a handy dandy GET… which returns the following xml… <geonames> <country> <countryCode>AT</countryCode> <countryName>Austria</countryName> <distance>0.0</distance> </country> </geonames> Great, but how do we call this from inside a stored procedure? Initially I thought of looking at using .NET in the SQL CLR, but found some other code snippets that use OLE Automation in T-SQL to create an instance of ‘MSXML2.XMLHTTP’ to pull data.

CREATE PROCEDURE GetCountry -- Add the parameters for the stored procedure here @lat as float, @lon as float AS BEGIN Declare @Object as Int; Declare @ResponseText as Varchar(8000); Declare @Url as Varchar(MAX); select @Url = ' + CAST(@lat as varchar) + '&lng='+ cast(@lon as varchar) +'&type=xml' Llamar a servicios web desde dentro de SQL Server 2005 - SqlRanger - Geeks.

Create a web service directly from Sql Server 2005 using an HTTP Endpoint. Practical SQL Server 2005 CLR Assemblies. Consuming a Web Service from a SQL Server 2005 CLR Assembly Julian Skinner is a freelance programmer and technical author.

Practical SQL Server 2005 CLR Assemblies

This article is extracted from his book, Pro SQL Server 2005 Assemblies published by Apress in December 2005. The source code can be downloaded from here. One advantage of CLR assemblies is the ability to consume web services from within the database. This wouldn’t be easy with T-SQL, and would also require a lot of work in an unmanaged extended stored procedure. Wsdl.exe. For this example, we’ll use an existing public web service: the Terraserver-USA web service, which returns information about locations in the USA as well as aerial images provided by the US Geological Survey (USGS). Our example resides in the AdventureWorks database, and it consists of a stored procedure that takes as a parameter the ID for a row in the Person.Address table. At first sight, this looks like code that might be more usefully placed in a table-valued UDF to enable reuse. /o. How To Call a .NET Web Service from Client Side JavaScript using Internet Explorer and MSXML. If you have a list of options that you want to offer based on user input on an HTML form, you can make this interactive by using the functionality that MSXML and JavaScript provide.

How To Call a .NET Web Service from Client Side JavaScript using Internet Explorer and MSXML

For this article, we will illustrate creating a web service that feeds into a Creating a Stored Procedure to Get the Data You NeedThe first step in creating your web service is to create a stored procedure that will fetch the data that you need based on the parameters the user has typed into the form. If your database provides XML functionality, it is often a good idea to leverage this functionality. In this example, I am using the FOR XML EXPLICIT to render XML that will function as the final HTML that the client will render. If your database platform does not support this feature, this manipulation can either be done on the server using the classes in System.Xml or on the client using MSXML.

CREATE PROCEDURE dbo.WebServiceProc (@param VARCHAR(4)) AS 'selectList' AS [SELECT! FROM MyDatabase.dbo.MyTable if (! Master Data Services Team : Getting Started with the Web Services API in SQL Server 2008 R2 Master Data Services. (this post was contributed by Val Lovicz, Principal Program Manager on the MDS Team) This post provides instructions and examples using Visual Studio 2008, .NET and C# and is intended for an audience with a basic understanding of these technologies.

Master Data Services Team : Getting Started with the Web Services API in SQL Server 2008 R2 Master Data Services

The following are general references on MSDN for working with Web services if you would like more background information. Enable Web Services in Configuration Manager Before we get started, make sure your installation of MDS has Web services enabled. The prior post Installing and Configuring Master Data Services provided detailed configuration instructions and included a step to check the Enable Web services for the Web application setting as shown below. Expose the WSDL Exposing the WSDL is only necessary at the time you want to generate proxy classes using a client development tool such as Visual Studio. Caution: Updating web.config will cause the MDS application domain in IIS to recycle.

To enable an http/https Get on the WSDL: How to consume a web service from within SQL Server using SQL CLR - Tips and tricks from a Developer Support perspective. - Site Home - MSDN Blogs. Today I’ll show how you can consume a Web Service from within SQL Server using the SQL Server CLR.

How to consume a web service from within SQL Server using SQL CLR - Tips and tricks from a Developer Support perspective. - Site Home - MSDN Blogs

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. Service Broker: Scalable Web Service Calls From SQL Database. What can Service Broker do for you.

Service Broker: Scalable Web Service Calls From SQL Database

You might not have heard of the Service Broker before, I know I haven't up until a month ago and after learning what it can do, I think all .NET developers should at least be familiar with it. It comes free with SQL Server and no additional installation is required. Some of the highlights for me are asynchronous triggers, reliability, offloading of long running batch jobs or activating external applications that might call for example Web Services.

And some other great but rarely used features like Sql Server notifying the application layer when the data has changed which can be combined with a caching layer to make a very efficient and fast application. In fact list goes on. Asynchronous triggers First of all triggers in the SQL database are synchronous and they do an implicit lock on the database tables when an operation on the table is happening. Reliable messaging External activation Other. SQL Llamando WebServices. SQL Server, é possível criar uma trigger que invoque um web service? - Stack Overflow em Português. Call a webservice from TSQL (Stored Procedure) using MSXML. How to invoke a Web Service from a Stored Procedure. Introduction.

How to invoke a Web Service from a Stored Procedure

How to consume a web service from within SQL Server using SQL CLR - Tips and tricks from a Developer Support perspective. Utilizar ensamblados comprobables con SQL Server (C++/CLI) ./bar.nett: Uso de CLR stored procedure para llamar a un web service desde SQL Server 2008. Hola gente!

./bar.nett: Uso de CLR stored procedure para llamar a un web service desde SQL Server 2008

Pues acá les traigo una forma de acceder a un servicio web desde un procedimiento almacenado usando el CLR. Let's begin! Para hacer práctico el ejemplo, lo haremos con el servicio web del Banco Central de Costa Rica que nos permite consumir los diferentes tipos de cambio monetario. Para este caso escogeremos el tipo de cambio del dólar estadounidense (venta del USD), cuyo valor de parámetro es 318. Para que vayan comprendiendo les coloco la arquitectura que vamos a utilizar: La idea es consumir el valor dela venta en USD y la fecha de dicho valor e ingresarlos a una tabla, la cual, puede ser consultada posteriormente para realizar ajustes, cálculos, etcétera en sistemas que dependan de las fluctuaciones de ésta moneda.

Calling a Web Service from within SQL Server. More and more shops are implementing web services.

Calling a Web Service from within SQL Server

Doing this provides an architecture that allows applications to consume services to retrieve data. Calling a Web Service from within SQL Server.