| By Deanne M. Chance | Article Rating: |
|
| January 4, 2008 05:00 PM EST | Reads: |
13,297 |
An example XML response is shown in code Listing 3. What you need to know is how to return a particular XML node. As mentioned above, this can be done with the XPath query language. It may be helpful to know that "//" represents descendant nodes, the '*' represents any namespace such that //*:'ItemAttributes' finds all such nodes. The WITH clause further selects on child elements based on the root from the XPATH argument (//*:'ItemAttributes'). For example, if we wanted to extract the title, we could use this statement *:Title/text().
You may be wondering how to look at the raw HTTP responses received. This information can be useful for debugging. If you're using SQL Anywhere 10.0.1 build number 3484 or higher you can use the database server command line option -zoc <filename> or set the server option WebClientLogFile. The other alternative is to use a logging tool such as TcpTrace.
Listing 4 is the response to the ItemLookup request using TcpTrace.
Creating a GUI in PowerBuilder
Now that we have
our back-end built, we can write a front-end GUI using a RAD
development tool such as PowerBuilder. To start things off, open a new
workspace in PowerBuilder and name it Amazon. Now, create a new target
by choosing File->New->Target and choose application. Finally,
create a main window by choosing File->New->PB Object and choose
window. We now have all the elements needed for a basic project setup
and simply need to add code to tie them together. To do this, you will
have to add the code shown in Listing 5 to your application object's open event.
With that in place we can go about adding elements to our main window.
A single line edit will be provided to allow the user to enter a new
UPC. The information gathered here will be used in the call to our
stored procedure that will populate a datawindow containing
bibliographical information. To view the latter, add a datawindow
control. Finally, to fire the whole process off, drop down a command
button. The finished layout is shown in Figure 4.
The workhouse of the GUI is the datawindow, since it's going to do all the work of invoking the stored procedure we created earlier. To create it, go to File->New->Datawindow->FreeForm. When prompted for your data source, make sure you choose Stored Procedure. From there, you'll get to choose the function or procedure you want to invoke. In our case, choose the ItemLookupWrapper procedure. Complete the creation of the object by stepping through and accepting all the defaults until you complete the process by clicking the Finish button.
Making the Call
Having put all the work of calling
the Amazon Web Service in a stored procedure on the database side,
calling it out of PowerBuilder is trivial. Other than the database
connection and the creation of the datawindow object, you only need two
lines of code! The first is a call to set your transaction object and
the other retrieves whatever UPC the user has entered.
The first call can be put in the open event of your main window and is simply:
dw_1.SetTransObject(SQLCA)
The second call is needed to invoke the stored procedure and can be put in the clicked event of a cb_ok button like this:
dw_1.Retrieve(sle_1.Text)
Finished Product
Figure 5
shows the finished product. Key in a UPC and with the help of
PowerBuilder, SQL Anywhere and Amazon Web Services you have just rolled
your own media organizer!
Conclusion
Calling Web Services out of SQL
Anywhere opens up a whole new world of programming fun. Coupled with
this arsenal and an excellent RAD development tool such as
PowerBuilder, you can be up and coding your own Web Service clients in
no time at all. I encourage you to start exploring!
Next Time
In this segment we looked at consuming
Web Services from SQL Anywhere. In the next article in this series,
we'll look at exposing them. In doing so, we will go about building our
own mini-version of an Amazon-like Web Service using the data we
collected in this part.
References
- Amazon API Documentation http://developer.amazonwebservices.com/connect/kbcategory.jspa?categoryID=19.
- SQL Anywhere Documentation www.ianywhere.com/developer/product_manuals/sqlanywhere.
- SQL Anywhere Developer Edition http://eshop.sybase.com/eshop/try_buy.
- PowerBuilder Evaluation Copy http://eshop.sybase.com/eshop/try_buy.
- Inside SOAP www.xml.com/pub/a/2000/02/09/feature/index.html.
Published January 4, 2008 Reads 13,297
Copyright © 2008 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Deanne M. Chance
Ms. Chance graduated in 1996 with a degree in computer science from the University of Illinois. She has been a frequent contributor to the PowerBuilder Developer's Journal and gave a key presentation at Sybase TechWave 2005 entitled "A Real-Time Physical Inventory Solution Using PocketBuilder ASA and a WiFi Connection." She has held several engineering positions, starting a career at Motorola where she focused on mobile I.P. by doing real-time embedded programming for the base radio controller group as part of the iDEN/Nextel project.
- Why SOA Needs Cloud Computing - Part 1
- Cloud Expo and The End of Tech Recession
- The Transition to Cloud Computing: What Does It Mean For You?
- A Rules Engine Built in PowerBuilder
- Sybase Named “Silver Sponsor” of iPhone Developer Summit
- How PowerBuilder Got Its Groove Back
- The Cloud Has Cross-Border Ambitions
- Ulitzer Names The World's 30 Most Influential Virtualization Bloggers
- Ulitzer Named "New Media" Partner of Greatly Anticipated iStrategy Event in Berlin
- Risks and Enterprise Mobility?
- Steps for Success in Enterprise Mobility?
- Are Mobile Luddites Resisting Mobility?
- The Difference Between Web Hosting and Cloud Computing
- Sybase CTO to Speak at 4th International Cloud Computing Expo
- Why SOA Needs Cloud Computing - Part 1
- Cloud Expo and The End of Tech Recession
- The Transition to Cloud Computing: What Does It Mean For You?
- Five Reasons to Choose a Private Cloud
- Seeding The Cloud: The Future of Data Management
- The Threat Behind the Firewall
- Economy Drives Adoption of Virtual Lab Technology
- Tips for Efficient PaaS Application Design
- A Rules Engine Built in PowerBuilder
- Sybase Named “Silver Sponsor” of iPhone Developer Summit
- Where Are RIA Technologies Headed in 2008?
- PowerBuilder History - How Did It Evolve?
- The Top 250 Players in the Cloud Computing Ecosystem
- Custom Common Dialogs Using SetWindowsHookEx
- DDDW Tips and Tricks
- OLE - Extending the Capabilities of PowerBuilder
- DataWindow.NET How To: Data Entry Form
- Book Excerpt: Sybase Adaptive Server Anywhere
- Sybase ASE 12.5 Performance and Tuning
- Working with SOA & Web Services in PowerBuilder
- Office 2003 Toolbar: A New Look For Your Old PowerBuilder App
- Dynamically Creating DataWindow Objects


































