Tuesday, March 25, 2008

Calling Other People's Web Services

Here's a recent article about calling an external (internet) web service from inside a database:

Using Web Services in a PocketBuilder Application, Reed Shilts, Mar. 22, 2008
The title says "PocketBuilder" but most of the real work is performed by a few lines of SQL inside SQL Anywhere:
  • CREATE FUNCTION f ( ... ) TYPE 'SOAP:DOC' to pass parameters to the external web service, receive the XML data it sends back, and return the XML to the caller as a LONG VARCHAR string,

  • SELECT ... FROM OPENXML ( f ( ... ) ) WITH ... to invoke the function, pass it parameter values and parse the XML string it returns into a relational result set, and

  • CREATE PROCEDURE to do the SELECT and return the result set to the application program (in this case, a PocketBuilder DataWindow).
You can use this facility from any application development environment that can call a stored procedure to get a result set, not just PocketBuilder.

I don't much like the formatting (or lack thereof) in the sample code, but Sys-Con Publishing has never pretended to be reader-friendly... Reed's a good guy, I'm not blaming him, and at least the samples have line breaks :)

Here is the other article that Reed's article refers to (but doesn't link to... thanks again, Sys-Con! do you even get "the internet"?):
Consuming Amazon Web Services Using PowerBuilder and SQL Anywhere 10.0.1, Deanne M. Chance, Jan. 4, 2008
Deanne's article contains more detailed sample code. The four "Listings" are stored together in one separate file so just jump to "Listing 1" and print what you see.

Alas, the one "Table" and five "Figures" are stored in 6 separate files... maybe Sys-Con used up their quota of hypertext links inside this article, and couldn't affort an external link to this article.
Apparently they also used up their quota of disk space because one of the Figures is hopelessly blurred, another barely readable.
Anyway, once again it's not the author's fault, AND THE BOTH ARTICLES ARE WORTH THE EFFORT! [shouting intended]

No comments: