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.