| By Reed Shilts | Article Rating: |
|
| April 16, 2008 08:45 AM EDT | Reads: |
7,548 |
This tied together all the SOAP aspects of the call - the endpoint, the operation, and the argument list. To test the SOAP side of the call (and see if anything came back) I simply called this from iSQL.
I knew that iSQL wouldn't display any result set; the stored procedure is only returning the SOAP payload as a single LONG VARCHAR, not a result set. Why did I try this knowing that iSQL couldn't display anything? I knew that I'd be looking into the HTTP log file and seeing what was generated by SQL Anywhere for the SOAP call and then what was returned by the remote server. I wanted to get over that small hurdle before tackling the decomposition of the returned data payload.
call GetUPSRate( 'SHP-M89872906F', '',
'60506', 'US',
'01776', 'US',
'10.5', '0' )
The first two fields are the trial user information, which changes every week or so. The second pair of fields are the ZIP code and country for Aurora, IL (60506), the next pair of fields are the ZIP code and country for Sudbury, MA (01776), and the final two fields are the package weight and value.
Looking in the HTTP log file for the database server, I see that this trial Web Service call succeeded and reasonable looking data was returned (see Listing 1).
Examining this response data confirmed my understanding from the eCoComa Web site. Basically, I wanted to extract the 'Code,' 'Rate,' and 'Mail Service' values as columns repeated for each "Postage" row in my result set.
The next step was to figure out the syntax for the call to the SQL Anywhere 10 system procedure "openxml" to generate rows of data with my desired columns. Wrapping my head around the XPath query string and namespace qualifiers consumed many lunch hours, but reading and rereading the iAnywhere documentation for the openxml system procedure, the iAnywhere newsgroups, and the online resources about XPath led me to the following simple select statement using openxml.
SELECT MailCode,Rate,Service
FROM openxml(
GetUPSRate( ... arguments ... ),
'//*:Postage', 2 )
WITH ( MailCode CHAR(10) '*:Code',
Rate CHAR(10) '*:Rate',
Service LONG VARCHAR '*:MailService' )
The '//*:Postage' is the XML node that generates a matching row in the result set.
The WITH statement provides the correlation between the XML nodes in the SOAP payload and what I wish to use as columns in my result set.
Wrapping all this up, I created a second stored procedure (using the naming ideas from Chance's article):
call sa_make_object( 'procedure', 'GetUPSRateWrapperUS');
alter procedure GetUPSRateWrapperUS(
@MemberKey char(20),
@SourceZip char(20),
@DestZip char(20),
@Weight char(10) )
begin
SELECT MailCode,Rate,Service FROM openxml(
GetUPSRate( @MemberKey , '',
@SourceZip, 'US',
@DestZip, 'US',
@Weight, '0' ),
'//*:Postage', 2 )
WITH ( MailCode CHAR(10) '*:Code',
Rate CHAR(10) '*:Rate',
Service LONG VARCHAR '*:MailService' )
end;
As you can see, I hard-coded for shipping in the U.S., but it can easily be extended for international shipping. I'd just need to pass in the value for customs and the correct country codes (and maybe replace the phrase 'Zip' with the more international 'PostalCode').
Published April 16, 2008 Reads 7,548
Copyright © 2008 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Reed Shilts
In addition to being one of the "old timer" PowerBuilder kernel programmers, Reed is the development lead for PocketBuilder and currently drafted in PowerBuilder 11 & 12 work. Reed is also a regular (and vocal) member of the Boston PocketPC user's group. He often bring his latest hardware and sometimes offer PocketBuilder as a door prize - even though this is hosted by Microsoft! If you live in the Boston area, stop on by: http://www.bostonpocketpc.com
- 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 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?
- Hot Event in Santa Clara Becomes Cool with the iPhone
- 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

































