Figure 4: The GETRATE program
|
H DFTACTGRP(*NO) BNDDIR('HTTPAPI':'QC2LE')
D GETRATE PR ExtPgm('GETRATE')
D Country1 3A const
D Country2 3A const
D Rate 15P 5
D GETRATE PI
D Country1 3A const
D Country2 3A const
D Rate 15P 5
/copy 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 Result s 8F
/free
|
SOAP =
'<?xml version="1.0" encoding="US-ASCII" standalone="no"?>'
+'<SOAP-ENV:Envelope'
+' xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">'
+'<SOAP-ENV:Body>'
+' <ConversionRate xmlns="http://www.webserviceX.NET/">'
+' <FromCurrency>'+ %trim(Country1) +'</FromCurrency>'
+' <ToCurrency>'+ %trim(Country2) + '</ToCurrency>'
+' </ConversionRate>'
+'</SOAP-ENV:Body>'
+'</SOAP-ENV:Envelope>';
|
A |
rc = http_url_post_xml(
'http://www.webservicex.net/CurrencyConvertor.asmx'
: %addr(SOAP) + 2
: %len(SOAP)
: *NULL
: %paddr(Incoming)
: %addr(Result)
: HTTP_TIMEOUT
: HTTP_USERAGENT
: 'text/xml'
: 'http://www.webserviceX.NET/ConversionRate');
|
B |
if (rc <> 1);
http_crash();
else;
Rate = %dech(Result: 12: 2);
endif;
*inlr = *on;
/end-free
P Incoming B
D Incoming PI
D Result 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 atof PR 8F extproc('atof')
D string * value options(*string)
|
/free
if (name = 'ConversionRateResult');
Result = atof(value);
endif;
/end-free
|
C |
P E
|