Comments
Richard Davies wrote: The UK has a good crop of technology pioneers in cloud computing - for example ElasticHosts, FlexiScale, Flexiant, OnApp - and also some strong government initiatives such as G-Cloud. We will have to see whether this kind of technical leadership converts into swift mass-market adoption or not.
Cloud Expo on Google News


2008 West
DIAMOND SPONSOR:
Data Direct
SOA, WOA and Cloud Computing: The New Frontier for Data Services
PLATINUM SPONSORS:
Red Hat
The Opening of Virtualization
GOLD SPONSORS:
Appsense
User Environment Management – The Third Layer of the Desktop
Cordys
Cloud Computing for Business Agility
EMC
CMIS: A Multi-Vendor Proposal for a Service-Based Content Management Interoperability Standard
Freedom OSS
Practical SOA” Max Yankelevich
Intel
Architecting an Enterprise Service Router (ESR) – A Cost-Effective Way to Scale SOA Across the Enterprise
Sensedia
Return on Assests: Bringing Visibility to your SOA Strategy
Symantec
Managing Hybrid Endpoint Environments
VMWare
Game-Changing Technology for Enterprise Clouds and Applications
Click For 2008 West
Event Webcasts

2008 West
PLATINUM SPONSORS:
Appcelerator
Get ‘Rich’ Quick: Rapid Prototyping for RIA with ZERO Server Code
Keynote Systems
Designing for and Managing Performance in the New Frontier of Rich Internet Applications
GOLD SPONSORS:
ICEsoft
How Can AJAX Improve Homeland Security?
Isomorphic
Beyond Widgets: What a RIA Platform Should Offer
Oracle
REAs: Rich Enterprise Applications
Click For 2008 Event Webcasts
SYS-CON.TV
Top Links You Must Click On


Web Services Implementation of a Third Kind
Redeploying existing Web Services using the new ASP.NET Web Services target in PowerBuilder 11

Back in late 2002 I wrote an article on creating Web Services using PowerBuilder ("Implementing PowerBuilder-Based Web Services from PowerDynamo" http://pbdj.sys-con.com/read/42210.htm). It was based on a PowerBuilder 8.0 component deployed to EAServer called from Web pages based on PowerDynamo that used DOM to generate HTML from the XML from the Web Service. Because PowerBuilder 8.0 didn't support the native generation of XML, PowerScript was used to generate it manually.

When PowerBuilder 9.0 came out, native XML was introduced. So were JSP targets. So I took that opportunity to rewrite the EAServer component with PowerBuilder 9.0 and rewrote the Web pages that accessed it using JSP. I wrote an article on how that was implemented in late 2003 ("Creating a Web Service with PowerBuilder" http://pbdj.sys-con.com/read/42590.htm). I was just updating the original component to take advantage of native XML support and using the Jakarta Xtags taglib library to do the XSLT Transform in the Web pages rather than PowerDynamo's DOM processor.

While PowerBuilder 10.0 did offer some Web Services improvements (automatic deployment of components as Web Services, UDDI support) it wasn't anything that really impacted my Web Service. Same for PowerBuilder 10.5 whose primary Web Service improvement (the new .NET engine) was entirely related to PowerBuilder clients consuming Web Services, not with Web Service creation.

That all changed with PowerBuilder 11.0.

PowerBuilder introduces several new .NET target types; of particular interest here is ASP.NET Web Services. So once again I'm re-implementing the Web Service to take advantage of features added with a new version of PowerBuilder (the third implementation of that service, hence the title of this article).

Creating the Web Service
The conversion of the PowerBuilder component itself was trivial. I simply migrated the existing application and then indicated that I wanted to create an ASP.NET target project for deployment (see Figure 1).

By default, the project doesn't include any methods of the component; you need to specify which ones you want to expose in the published Web Service (see Figure 2).

One minor difference is that a PowerBuilder component deployed to EAServer can't refer to an application object, so it doesn't have access to any of the global variables (e.g., SQLCA) that an application object creates. An ASP.NET target does have an application object, so I no longer have to create a local transaction object in the component methods. Instead I'm using SQLCA, although I still set the transaction object properties and do the connect/disconnect in the method (see Listing 1 and Listing 2).

Note that for a "true" production application where you would need to support a large numbers of users simultaneously you would want to use an ADO.NET driver rather than the native driver I'm using here. That's because ADO.NET automatically uses OLEDB session pooling. Therefore, as long as your connection parameters are identical for each connection attempt, you would automatically be provided connection-pooling support. See "Pooling in the Microsoft Data Access Components" (http://msdn2.microsoft.com/en-us/library/ms810829.aspx) for more information.

Once you've deployed the Web Service, the "Run" option will take you directly to the ASP.NET Web Service page (see Figure 3). Note that if you add "?WSDL" to the end of the URL for the Web Service page, you'll get the WSDL that describes the Web Service. The links on the page for each of the methods will take you to a page that you can use to test the Web Service if you're accessing the Web Service from the machine it's deployed to.

Creating the Calling Web Pages
Now that we have our ASP.NET Web Service, it's time to call it and render the results. Since the service is ASP.NET-based, I wanted to use ASP.NET to handle that as well. Fortunately, ASP.NET includes an XML Web server control that makes this very simple. For more information on the control see "HOW TO: Display an XML Document in ASP.NET by Using the XML Web Server Control" (http://support.microsoft.com/kb/315906).

As a result, the ASPX files that we use to show the search results or individual messages are almost identical and rather small (see Listing 3 and Listing 4). They simply embed the control with an instruction to do the processing on the server and leave the rest to the code in the code-behind file.

The code-behind files are also somewhat similar and fairly small (see Listing 5 and Listing 6). The parameters to the page are pulled off and passed to an instance of the Web Service reference. The result is pulled into a string variable that is then loaded into an XmlDocument object. An XslTransform object is also created and pointed to the location of an XSLT file that directs the conversion of the XML to HTML. The XmlDocument and XslTransform objects are then associated with the XML Web server control that performs the transformation of the HTML page. In the case of the search page, I also created an XsltArgumentList object based on the page arguments and then associated that with the XML Web server control as well. That's because the XSLT file will be using those to create hyperlinks in the resulting HTML page.

Creating the XSLT Files
The XSLT files used to direct the transformation of the XML to HTML are in Listing 7 and Listing 8. Samples of the resulting HTML pages are shown in Figure 4 and Figure 5. If you're familiar with Google Groups, you'll notice that I've patterned the layout after the way that they display search results and individual messages, although Google Groups has since significantly altered the way they display individual messages.

The XSLT file for displaying the message is very straightforward. Most of the data is formatted into a simple table. The message text itself is inserting into a <PRE> tag that's used in HTML to display pre-formatted text.

If there's any complicated coding in this entire implementation, it's actually in the XSLT file used to process the search results. Let's look at it in a bit more detail.

The first thing you'll notice is a set of xsl:param tags that are used to obtain the arguments that were passed into the stylesheet through the XsltArguments object. Then there's an xsl:variable called "count" that determines how many rows are in the result set by counting the number of "search_row" tags in the XML file.

If the count is greater than zero, two xsl:call-template tags are processed. The xsl:call-template tag is the XSLT equivalent of a function or subroutine call. There are additional templates embedded in this same XSLT file that are called via the tag at that point in the parent template. The first template ("links") displays links that point to other result pages for the search and the second ("rows") displays the current set of results.


About Bruce Armstrong
Bruce Armstrong is a development lead with Integrated Data Services (www.get-integrated.com). A charter member of TeamSybase, he has been using PowerBuilder since version 1.0.B. He was a contributing author to SYS-CON's PowerBuilder 4.0 Secrets of the Masters and the editor of SAMs' PowerBuilder 9: Advanced Client/Server Development.

In order to post a comment you need to be registered and logged in.

Register | Sign-in

Reader Feedback: Page 1 of 1

Enterprise Open Source Magazine Latest Stories . . .
Apache Deltacloud, the Red Hat-contributed ReSTful API that abstracts differences between clouds so services on any cloud can be managed – provided of course there’s a driver – has graduated from the Apache Foundation’s incubator and is now a full-fledged Top-Level Project (TLP). The...
With Cloud Expo 2012 New York (10th Cloud Expo) just four months away, what better time to start introducing you in greater detail to the distinguished individuals in our incredible Speaker Faculty for the technical and strategy sessions at the conference... We have technical and st...
AMD said late Tuesday that its chief sales officer Emilio Ghilardi had left the company and that CEO and president Rory Read is going to do his job while a replacement is sought. AMD didn’t say why Ghilardi left but it’s assumed Read wants his own people. Read is relatively new to th...
During the lifespan of M3 (Monitis Monitor Manager) there has always been something lacking – timers. M3 execution procedure was outlined in this previous article. The execution mentioned in the latter was a one-time-execution, whereas server monitoring requires periodic invocati...
Red Hat is putting its bought-in Gluster scale-out NAS storage technology, acquired in October, on the Amazon cloud. It’s styled Red Hat Virtual Storage Appliance for Amazon Web Services and other clouds are supposed to follow in short order.
A new episode of the screencast series is now available at the OpenNebula YouTube Channel. This screencast demonstrates the new easily-customizable self-service portal for cloud consumers. Its aim is to offer a simplified access to shared infrastructure for non-IT end users. The scree...
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021


SYS-CON Featured Whitepapers
ADS BY GOOGLE