|
YOUR FEEDBACK
Did you read today's front page stories & breaking news?
SYS-CON.TV SYS-CON.TV WEBCASTS |
POWERBUILDER LINKS YOU MUST CLICK ON Tutorial Consuming Amazon Web Services Using PowerBuilder and SQL Anywhere 10.0.1
I rolled a little application using SQL Anywhere, PowerBuilder, and Amazon Web Services
By: Deanne M. Chance
Jan. 4, 2008 05:00 PM
To complete this project, you'll need a few things:
Creating a Database
Creating Table Schema When you're finished, your schema should look like Figure 1. Save it by pressing CTRL-S.
Creating an ODBC Connection
Creating an Amazon Web Account
Consuming Web Services in SQL Anywhere 10 The first thing you have to do when adding any stored procedure or function to your database is to start a SQL interpreter such as Interactive SQL. To open it, click Programs->SQL Anywhere 10->Interactive SQL. A Connect dialog will open, as shown in figure 3. Enter "Amazon" for the name of the ODBC connection. You may now go about creating your stored procedure or function. Use a function or stored procedure to create a Web Service call out of SQL Anywhere. If you're using a version of SQL Anywhere prior to version 10.0.1, the function name must be the same name as the SOAP operation you want to perform. For example, in our case we want to use the ItemLookup service, so the name of our function is ItemLookup. I might note that this restriction has been lifted in version 10.0.1. Now you can call the function whatever you like, but you must add a statement such as the following to the end of your function declaration: set 'SOAP(operation=ItemLookup)' Additionally, the names of any parameters also appear in tagnames in the SOAP request envelope. An important part of defining a SOAP stored procedure is specifying them correctly, as the SOAP server expects to see these names. Finally, you'll need to know the URL, binding, and namespace of the service you want to access. Amazon E-Commerce Service (ECS) publishes its API through Web Services Description Language (WSDL) documents, which you can use to construct SOAP requests. Their WSDL is available at http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl. A look at some WSDL might shed some light as to where these parameters come from (see code Listing 1). Note: portions of WSDL were intentionally deleted for clarity. First, if you scan the listing to the service element you'll see that the SOAP address or endpoint is http://soap.amazon.com/onca/soap?Service=AWSECommerceService. This is the value of our URL. Secondly, when analyzing RPC style WSDL documents, namespaces are specified for each operation. In a doc style, the namespace is generally the targetNamespace that defines the top-level WSDL elements. So our namespace clause is http://webservices.amazon.com/AWSECommerceService/2007-04-04. Finally, if you look in that service element, there's a binding attribute that links us to the binding section of the WSDL: <port name="AWSECommerceServicePort" binding="tns:AWSECommerceServiceBinding"> Here, you can determine that the style=document and all operations specify use=literal. So for our Web client function we need to specify type 'SOAP:DOC'. The complete SQL Anywhere example code is shown in Listing 2.
Parsing the XML Response PBDJ LATEST STORIES . . .
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK BREAKING POWERBUILDER / SYBASE NEWS
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||