[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Consuming an internal web service
Sender: Scott Klement <sk@xxxxxxxxxxxxxxxx>
I have some doubts on how to begin. I read the message of Scott about
the "SOAP Message Generator", but I feel that something is missing.
What do you feel is missing?
I also read the EXAMPLE16, but I don't see any "SOAP" message.
EXAMPLE16 doesn't use SOAP.
So I'm confused.
Can anybody send me another example ?
Please don't have to be right now, take your time, i'm interested just
for my own knowledge.
I wrote an example recently for the Club Tech iSeries Programming Tips
newsletter. If you have a ProVIP account with the iSeries Network (you're
entitled to one if you have a subscription to iSeries NEWS magazine) then
you can read it at the following link:
http://www.iseriesnetwork.com/article.cfm?id=52258
If you don't have a ProVIP membership... here's the code from the article
(but without the text that explains how it works)
* Example of consuming a Web Service for Currency Conversion
* Scott Klement, Feb 9, 2006
*
* This program requires HTTPAPI to be installed on your iSeries
* and compiled with XML support. You can get it from the
* following link:
* http://www.scottklement.com/httpapi/
*
* To compile this program:
* CRTBNDRPG EXCHRATE SRCFILE(xxx/xxx) DBGVIEW(*LIST)
*
* Sample of calling this program:
* CALL EXCHRATE PARM('USD' 'CAD' 15.00)
*
* (It will respond with the amount of Canadian dollars
* that equal 15.00 in the United States.)
*
* For a list of valid country codes, point your web browser
* at the following link:
* http://www.webservicex.net/CurrencyConvertor.asmx
*
*
H DFTACTGRP(*NO) BNDDIR('LIBHTTP/HTTPAPI')
D EXCHRATE PR ExtPgm('EXCHRATE')
D Country1 3A const
D Country2 3A const
D Amount 15P 5 const
D EXCHRATE PI
D Country1 3A const
D Country2 3A const
D Amount 15P 5 const
/copy libhttp/qrpglesrc,httpapi_h
D Incoming PR
D rate 8F
D depth 10I 0 value
D name 1024A varying const
D path 24576A varying const
D value 32767A varying const
D attrs * dim(32767)
D const options(*varsize)
D SOAP s 32767A varying
D rc s 10I 0
D rate s 8F
D Result s 12P 2
D msg s 50A
D wait s 1A
/free
SOAP =
'<?xml version="1.0" encoding="US-ASCII" standalone="no"?>'
+'<SOAP-ENV:Envelope'
+' xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"'
+' xmlns:tns="http://www.webserviceX.NET/">'
+'<SOAP-ENV:Body>'
+' <tns:ConversionRate>'
+' <tns:FromCurrency>'+ %trim(Country1) +'</tns:FromCurrency>'
+' <tns:ToCurrency>'+ %trim(Country2) + '</tns:ToCurrency>'
+' </tns:ConversionRate>'
+'</SOAP-ENV:Body>'
+'</SOAP-ENV:Envelope>';
rc = http_url_post_xml(
'http://www.webservicex.net/CurrencyConvertor.asmx'
: %addr(SOAP) + 2
: %len(SOAP)
: *NULL
: %paddr(Incoming)
: %addr(rate)
: HTTP_TIMEOUT
: HTTP_USERAGENT
: 'text/xml'
: 'http://www.webserviceX.NET/ConversionRate');
if (rc <> 1);
msg = http_error();
else;
Result = %dech(Amount * rate: 12: 2);
msg = 'Result = ' + %char(Result);
endif;
dsply msg ' ' wait;
*inlr = *on;
/end-free
P Incoming B
D Incoming PI
D rate 8F
D depth 10I 0 value
D name 1024A varying const
D path 24576A varying const
D value 32767A varying const
D attrs * dim(32767)
D const options(*varsize)
/free
if (name = 'ConversionRateResult');
rate = %float(value);
endif;
/end-free
P E
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubsribe from the list send mail
to majordomo@xxxxxxxxxxxxx with the body: unsubscribe ftpapi mymailaddr
-----------------------------------------------------------------------