Hello,
I am trying to utilize the new exchange rate Web Service offered by the Federal Reserve Bank of New York (see http://www.ny.frb.org/markets/pilotfx.html ). I was hoping to use the HTTP API’s to retrieve the exchange rate. There is a link on the web site that will provide the Web Service Definition. There is a lot of wsdl code that they show. I tried to extract what I needed for the SOAP message that the HTTP API’s need. I believe the exchange rate that is returned is a string variable as opposed to the floating point variable that are returned in some of your examples. Thanks in advance for any help. . Here is the code that I wrote:
H DFTACTGRP(*NO) BNDDIR('HTTPAPI':'QC2LE')
D ExchRateX PR ExtPgm('EXCHRATEX') D Country1 3A const
D ExchRateX PI D Country1 3A const
/copy httpapi_h
D Incoming PR D rate 12A 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 12A
/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.newyorkfed.org./markets/fxrates/WebService/" +'<SOAP-ENV:Body>' +' <tns:getLatestNoonRateRequest>' +' <tns:currency_code>'+ %trim(Country1) +'</tns:currency_code>' +' </tns:getLatestNoonRateRequest>' +'</SOAP-ENV:Body>' +'</SOAP-ENV:Envelope>';
rc = http_url_post_xml( 'http://www.newyorkfed.org./markets/fxrates/WebService/v1_0/FXWS' : %addr(SOAP) + 2 : %len(SOAP) : *NULL : %paddr(Incoming) : %addr(rate) : HTTP_TIMEOUT : HTTP_USERAGENT : 'text/xml' : *blanks );
if (rc <> 1); http_crash(); else; http_comp(%trim(Country1) + ' ' + Rate); endif;
*inlr = *on;
/end-free
P Incoming B D Incoming PI D rate 12A 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 12A extproc('atof') D string * value options(*string)
/free if (name = 'getLatestNoonRateReturn'); rate = atof(value); endif; /end-free P E
Regards, Peter W. Hoey
|