Great, you finally got it to work

Mit freundlichen Grüßen / Best regards

Birgitta Hauser


"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok)
"What is worse than training your staff and losing them? Not training them
and keeping them!"
?Train people well enough so they can leave, treat them well enough so they
don't want to.? (Richard Branson)


-----Original Message-----
From: MIDRANGE-L <midrange-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of Sam_L
Sent: Donnerstag, 27. Januar 2022 16:59
To: midrange-l@xxxxxxxxxxxxxxxxxx
Subject: QSYS2.HTTP_GET, USPS, XMLPARSE Solution

Final result from the "QSYS2.HTTP_GET problem with the USPS APIs" thread.

This does the HTTP_GET and then uses XMLPARSE to access the returmed XML.

with
retXML as (
values QSYS2.HTTP_GET(
'http://production.shippingapis.com/ShippingAPI.dll'
concat '?API=Verify&XML=' concat
url_encode(
'<AddressValidateRequest ' concat
'USERID="????????????">' concat
'<Revision>1</Revision>' concat
'<Address ID="0">' concat
'<Address1>Suite 2</Address1>' concat
'<Address2>8 Wildwood Drive</Address2>' concat
'<City>Old Lyme</City>' concat
'<State>CT</State>' concat
'<Zip5/>' concat
'<Zip4/>' concat
'</Address>' concat
'</AddressValidateRequest>'
)
)
),
xmltbl AS (
select x.* from xmltable
('AddressValidateResponse/Address'
passing xmlparse(document (select * from retXML))
columns
address1 char(30) path 'Address1',
address2 char(30) path 'Address2',
city Char(30) path 'City',
St char(2) path 'State',
zip5 char(5) path 'Zip5',
Zip4 char(4) path 'Zip4'
) as x
)
select * from xmltbl;


My thanks to:
Jack Woehr for his assistance with HTTP_GET.
Birgitta Hauser for posting an immensely helpful XMLPARSE example.

If you want to see this in an RPG program, I have an example on GITHUB.
https://github.com/SJLennon/IBM-i-RPG-Free-CLP-Code

--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx To subscribe,
unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.

Help support midrange.com by shopping at amazon.com with our affiliate link:
https://amazon.midrange.com


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.