filmov
tv
Consuming Web Service from Excel - Delphi

Показать описание
We can consume the web services not only from applications developed using various programming languages but also from Microsoft office tools like Excel. In this mini-video I would like to call a service from Excel 2003 in pure VBA (visual basic for application) without installing any plugins, neither opening up Visual Studio, nor other hacks. This example, this service returns CEP (code postal) according to the address you request. Actually, user can find any Address here in Brazil, for instance, when a user types a street, avenue starting with letter B, web service will return all data address starting with B, in all over Brazil, this is really big result. My database has more than 200 megabytes. Actually, this database contain more than 900 thousands records, 45,738 districts and 10,698 places.
Some fun features include strong authentication, URI signatures and JSON support (thanks to vba-json).
I'm using a REST server. REST is simple enough in practice that it doesn't really need a toolkit. All it requires is support for HTTP, which VBA offers through the MSXML2.XMLHTTP object. Using this object, you can create HTTP requests and process the responses. There's no need to use the Microsoft Office Web Services Toolkit for this example; the VBA code for the button in alone is all you need.
It's working awesomely in my Excel 2003 (and most likely 2010), but does not work on Excel for Mac due to missing XMLHTTP libraries. I think it should work with pretty much any REST webservice. In my opinion Microsoft would like to have VBA dead and it is pushing dot net solutions for Office.
Some fun features include strong authentication, URI signatures and JSON support (thanks to vba-json).
I'm using a REST server. REST is simple enough in practice that it doesn't really need a toolkit. All it requires is support for HTTP, which VBA offers through the MSXML2.XMLHTTP object. Using this object, you can create HTTP requests and process the responses. There's no need to use the Microsoft Office Web Services Toolkit for this example; the VBA code for the button in alone is all you need.
It's working awesomely in my Excel 2003 (and most likely 2010), but does not work on Excel for Mac due to missing XMLHTTP libraries. I think it should work with pretty much any REST webservice. In my opinion Microsoft would like to have VBA dead and it is pushing dot net solutions for Office.