For something like this, you do not need the full implementation of a web service. You can use SQLCLR (SQL Server.NET Integration) to send a request to the URL, return the response in XML (unless you can find a JSON library that will work without installing UNSAFE), and then parse that answer.
Take a look at the following MSDN pages:
According to the Google Geocoding API, the API URI should be formatted similarly to the following:
https://maps.googleapis.com/maps/api/geocode/xml?address={EscapedAddress}&key={API_KEY}
Just send that with these two variables replaced by their respective values ββvia HttpWebRequest , then call HttpWebRequest.GetResponse , then call HttpWebResponse.GetResponseStream . And don't forget to call the Close and Dispose HttpWebResponse (or create an instance in the using block) !!
Additional notes:
- If you have not already done so, you will need to enable (once) CLR Integration at the server level: Enabling CLR Integration
- Do not make the easy path and set the database to
TRUSTWORTHY ON . Just sign the assembly with a password, and then create an asymmetric key in the master database, pointing to your signed DLL, then create a login from this asymmetric key and, finally, grant UNSAFE ASSEMBLY permission to enter the system. Then you can set the assembly WITH PERMISSION_SET = EXTERNAL_ACCESS . - Do not use SP_OA * procedures as protected user3469363 . These OLE Automation procedures are deprecated with SQL Server 2005 and will (hopefully) be removed someday (hopefully soon). They are also less efficient and less reliable than SQLCLR.
Solomon rutzky
source share