11.07.2015 Views

in PowerBuilder - sys-con.com's archive of magazines - SYS-CON ...

in PowerBuilder - sys-con.com's archive of magazines - SYS-CON ...

in PowerBuilder - sys-con.com's archive of magazines - SYS-CON ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

TECHNIQUESWRITTEN BYDOUG PORTERWork<strong>in</strong>g with Web Services<strong>in</strong> <strong>PowerBuilder</strong>An <strong>in</strong>troductionAUTHOR BIODoug Porter is a s<strong>of</strong>twaredeveloper withDailyAccess Corporation.He is a Sun CertifiedJava Programmerand Certified Power-Builder Pr<strong>of</strong>essional andwas a speaker at Tech-Wave 2004. He holds aBA <strong>in</strong> Spanish and anMS <strong>in</strong> CIS from the University<strong>of</strong> South Alabamawhere he has alsoworked as an adjunct<strong>in</strong>structor. Doug worksextensively withEAServer, <strong>PowerBuilder</strong>,and Java develop<strong>in</strong>gclient/server and Webapplications for thef<strong>in</strong>ancial <strong>in</strong>dustry.Unless you have been hid<strong>in</strong>g <strong>in</strong>a cave for the past couple <strong>of</strong>years, you are probably wellaware <strong>of</strong> the buzz surround<strong>in</strong>gservice-oriented architecture(SOA). This <strong>con</strong>cept <strong>of</strong> <strong>in</strong>teractionamong loosely coupled collections <strong>of</strong>components is <strong>of</strong>ten implementedthrough a series <strong>of</strong> services accessibleover HTTP that processes requests andresponses (Web services). As a Power-Builder developer you may be wonder<strong>in</strong>ghow you can jo<strong>in</strong> the SOA partywhile still leverag<strong>in</strong>g your exist<strong>in</strong>gskills. This article will walk youthrough three techniques available tothe <strong>PowerBuilder</strong> developer (even ifyou may not be on a currently supportedversion).Access<strong>in</strong>g a Web service is very similarto visit<strong>in</strong>g a Web page <strong>con</strong>ta<strong>in</strong><strong>in</strong>gparameters <strong>in</strong> the URL or submitt<strong>in</strong>g aform on a Web page. An HTTP requestgets sent to a URL via an HTTP GET orPOST along with a set <strong>of</strong> arguments <strong>in</strong>the form <strong>of</strong> name/value pairs. In Power-Builder there are three options availablefor perform<strong>in</strong>g this type <strong>of</strong> operation:the GetURL/PostURL functions, us<strong>in</strong>gMicros<strong>of</strong>t’s XmlHttp object via OLE, andus<strong>in</strong>g the Web Service Proxy object.FIGURE 1 | FIGURE 2 |Demonstration Application toCall Amazon.com Web ServicesIn this article we will create a demonstrationapplication that <strong>in</strong>teracts withthe Amazon.com E-Commerce WebService (http://aws.amazon.com). Ourapplication will use this service tosearch through one <strong>of</strong> their product<strong>in</strong>dexes for items match<strong>in</strong>g our searchcriteria. To use the Amazon.com Webservice you will need to sign up for anaccess key through their site. The codesamples will show where your keyshould be placed with the <strong>in</strong>dicator“[YourAccessKey]”.By look<strong>in</strong>g at the documentation forthe Amazon E-commerce Web service,we can see that to perform an itemsearch operation a m<strong>in</strong>imal set <strong>of</strong> argumentsis required. There are many additionalarguments that may be used whenperform<strong>in</strong>g searches, but we will beus<strong>in</strong>g the subset listed below. (Browsethe Amazon.com Web service documentationto see the full range <strong>of</strong> searcharguments and operations available.)• Web Service URL: http://webservices.amazon.com/onca/xml• Service: Name <strong>of</strong> the service be<strong>in</strong>gused; should be AWSECommerceService• AWSAccessKeyID: [YourAccessKey]• Operation: Operation to be performed(ItemSearch <strong>in</strong> our case)• Keywords: Word or phrase to searchfor• SearchIndex: One <strong>of</strong> Amazon.com’ssearch <strong>in</strong>dexes (Music, Books, etc.)Responses from this Amazon Webservice will be returned as structuredXML that can then be parsed and displayed.A demonstration <strong>of</strong> the variousmethods available for pars<strong>in</strong>g XML <strong>in</strong><strong>PowerBuilder</strong> will be covered <strong>in</strong> a laterarticle.Before we can send requests, wemust decide what to search for. I’m ahuge music fan, so for this example wewill use the “Music” SearchIndex andfor our Keywords argument we willsearch for <strong>in</strong>formation on one <strong>of</strong> myfavorite musicians, the great “ButchWalker” (an Atlanta musician formerlywith the Marvelous 3).GetURL/PostURLThe oldest methods for pull<strong>in</strong>g dataover HTTP <strong>in</strong> <strong>PowerBuilder</strong> (s<strong>in</strong>ce version6.5) are the GetURL and PostURLfunctions. These functions allow you tosend an HTTP GET or POST request30 PBDJ volume12 issue11pbdj.<strong>sys</strong>-<strong>con</strong>.com

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!