[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Webservices via HTTPS with user/pass
Sender: "Mendoza, German \(RCIS\)" <German.Mendoza@xxxxxxxx>
Unfortunately, I have an issue here with our iSeries not being able to
use outbound port 80 so I can't use your example below. But I made some
modifications to mimic what you wrote and I got it work.
The main thing I had different was that %addr(XML)... I didn't have the
+2 and when I looked at the httpapi_debug.txt, I noticed that my data
was off 2 places.
Thanks for all the help Scott
-----Original Message-----
From: owner-ftpapi@xxxxxxxxxxxxx [mailto:owner-ftpapi@xxxxxxxxxxxxx] On
Behalf Of Scott Klement
Sent: Wednesday, February 08, 2006 7:38 PM
To: ftpapi@xxxxxxxxxxxxx
Subject: Re: Webservices via HTTPS with user/pass
Sender: Scott Klement <sk@xxxxxxxxxxxxxxxx>
> Has anybody been able to call a web service via HTTPS and also
supplying
> a username/password? I have worked with EXAMPLE7 (Example of
supplying
> USER/PASS to HTTP server) with a mixture of EXAMPLE3 (to initialize
the
> SSL API's) and been able to retrieve a page (via http_url_get) and
save
> that to the IFS. But can this be modified to use http_url_POST?
To test this, I wrote a quick program. It connects using HTTPS to a
demo WebService, and downloads a list of users. It works for me with no
problems:
H DFTACTGRP(*NO) BNDDIR('LIBHTTP/HTTPAPI')
/copy libhttp/qrpglesrc,httpapi_h
D addCount PR
D void * value
D depth 10I 0 value
D name 1024A varying const
D mapData PR
D void * value
D depth 10I 0 value
D name 1024A varying const
D path 24576A varying const
D value 32767A varying const
D xml s 500A varying
D rc s 10I 0
D x s 10I 0
D msg s 50A
D count s 10I 0
D odslist ds occurs(200)
D ods_line 4A varying
D ods_name 30A varying
D ods_mins 4A varying
/free
*inlr = *on;
http_setauth( HTTP_AUTH_BASIC: 'demo': 'httpapi' );
xml = '<?xml version="1.0"?>'
+ '<OdsListReq>'
+ '<Server>ods.ods.net</Server>'
+ '<ColumnList>'
+ '<Column>line</Column>'
+ '<Column>name</Column>'
+ '<Column>mins</Column>'
+ '</ColumnList>'
+ '</OdsListReq>';
rc = http_url_post_xml(
'https://www.klements.com/webserv/odslist'
: %addr(xml) + 2
: %len(xml)
: %paddr(addCount)
: %paddr(mapData)
: *NULL );
if (rc <> 1);
msg = http_error();
dsply msg;
return;
endif;
for x = 1 to count;
%occur(odslist) = x;
msg = ods_line + ' ' + ods_name;
dsply msg;
endfor;
return;
/end-free
P addCount B
D addCount PI
D void * value
D depth 10I 0 value
D name 1024A varying const
/free
if name = 'User';
count = count + 1;
%occur(odslist) = count;
endif;
/end-free
P E
P mapData B
D mapData PI
D void * value
D depth 10I 0 value
D name 1024A varying const
D path 24576A varying const
D value 32767A varying const
/free
select;
when (name = 'line');
ods_line = %trim(value);
when (name = 'mins');
ods_mins = %trim(value);
when (name = 'name');
ods_name = %trim(value);
endsl;
/end-free
P E
This code requires V5R1 to run because it uses HTTPAPI's XML parser and
free-format RPG.
If you try this code on your machine does it work?
If you don't want to use HTTPAPI's XML parser, you can change
http_url_post_xml to http_url_post, and it will still work (byt the
results will be in an XML file in the IFS instead of displayed on the
screen.)
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubsribe from the list send mail
to majordomo@xxxxxxxxxxxxx with the body: unsubscribe ftpapi mymailaddr
-----------------------------------------------------------------------
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubsribe from the list send mail
to majordomo@xxxxxxxxxxxxx with the body: unsubscribe ftpapi mymailaddr
-----------------------------------------------------------------------