Page 1 of 1

Realtime Exchange Rate (web services)

Posted: Tue Aug 13, 2013 3:56 am
by unixkd
Hi all

How can I implement realtime exchange rate conversion in my Xbase++ application ?

Thanks

Joe.

Re: Realtime Exchange Rate (web services)

Posted: Tue Aug 13, 2013 9:07 am
by rdonnay
Do you own Xb2.Net or ASINET?

Re: Realtime Exchange Rate (web services)

Posted: Tue Aug 13, 2013 11:15 am
by unixkd
Yes, I have both Xb2net and ASINET

Thanks.

Re: Realtime Exchange Rate (web services)

Posted: Tue Aug 13, 2013 12:10 pm
by rdonnay
You can try Yahoo. It is free and easy to use.

For example, to convert from GBP to EUR: http://download.finance.yahoo.com/d/quo ... 1ba&e=.csv

gives you data in csv format which can easily be parsed.

You can use the LoadFromUrl() function from AsiNet.
It will return the CSV as a string.

Re: Realtime Exchange Rate (web services)

Posted: Tue Aug 13, 2013 2:50 pm
by unixkd
Thanks Roger,

What I need may be something obtainable from this site: http://www.webservicex.net/CurrencyConv ... ersionRate

It does conversion from one currency to another and vise versa. Sample are given as follows but I do not know how to implement this in Xbase++

SOAP 1.1

The following is a sample SOAP 1.1 request and response. The placeholders shown need to be replaced with actual values.

POST /CurrencyConvertor.asmx HTTP/1.1
Host: www.webservicex.net
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "http://www.webserviceX.NET/ConversionRate"

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ConversionRate xmlns="http://www.webserviceX.NET/">
<FromCurrency>AFA or ALL or DZD or ARS or AWG or AUD or BSD or BHD or BDT or BBD or BZD or BMD or BTN or BOB or BWP or BRL or GBP or BND or BIF or XOF or XAF or KHR or CAD or CVE or KYD or CLP or CNY or COP or KMF or CRC or HRK or CUP or CYP or CZK or DKK or DJF or DOP or XCD or EGP or SVC or EEK or ETB or EUR or FKP or GMD or GHC or GIP or XAU or GTQ or GNF or GYD or HTG or HNL or HKD or HUF or ISK or INR or IDR or IQD or ILS or JMD or JPY or JOD or KZT or KES or KRW or KWD or LAK or LVL or LBP or LSL or LRD or LYD or LTL or MOP or MKD or MGF or MWK or MYR or MVR or MTL or MRO or MUR or MXN or MDL or MNT or MAD or MZM or MMK or NAD or NPR or ANG or NZD or NIO or NGN or KPW or NOK or OMR or XPF or PKR or XPD or PAB or PGK or PYG or PEN or PHP or XPT or PLN or QAR or ROL or RUB or WST or STD or SAR or SCR or SLL or XAG or SGD or SKK or SIT or SBD or SOS or ZAR or LKR or SHP or SDD or SRG or SZL or SEK or CHF or SYP or TWD or TZS or THB or TOP or TTD or TND or TRL or USD or AED or UGX or UAH or UYU or VUV or VEB or VND or YER or YUM or ZMK or ZWD or TRY</FromCurrency>
<ToCurrency>AFA or ALL or DZD or ARS or AWG or AUD or BSD or BHD or BDT or BBD or BZD or BMD or BTN or BOB or BWP or BRL or GBP or BND or BIF or XOF or XAF or KHR or CAD or CVE or KYD or CLP or CNY or COP or KMF or CRC or HRK or CUP or CYP or CZK or DKK or DJF or DOP or XCD or EGP or SVC or EEK or ETB or EUR or FKP or GMD or GHC or GIP or XAU or GTQ or GNF or GYD or HTG or HNL or HKD or HUF or ISK or INR or IDR or IQD or ILS or JMD or JPY or JOD or KZT or KES or KRW or KWD or LAK or LVL or LBP or LSL or LRD or LYD or LTL or MOP or MKD or MGF or MWK or MYR or MVR or MTL or MRO or MUR or MXN or MDL or MNT or MAD or MZM or MMK or NAD or NPR or ANG or NZD or NIO or NGN or KPW or NOK or OMR or XPF or PKR or XPD or PAB or PGK or PYG or PEN or PHP or XPT or PLN or QAR or ROL or RUB or WST or STD or SAR or SCR or SLL or XAG or SGD or SKK or SIT or SBD or SOS or ZAR or LKR or SHP or SDD or SRG or SZL or SEK or CHF or SYP or TWD or TZS or THB or TOP or TTD or TND or TRL or USD or AED or UGX or UAH or UYU or VUV or VEB or VND or YER or YUM or ZMK or ZWD or TRY</ToCurrency>
</ConversionRate>
</soap:Body>
</soap:Envelope>
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ConversionRateResponse xmlns="http://www.webserviceX.NET/">
<ConversionRateResult>double</ConversionRateResult>
</ConversionRateResponse>
</soap:Body>
</soap:Envelope>
SOAP 1.2

The following is a sample SOAP 1.2 request and response. The placeholders shown need to be replaced with actual values.

POST /CurrencyConvertor.asmx HTTP/1.1
Host: www.webservicex.net
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<ConversionRate xmlns="http://www.webserviceX.NET/">
<FromCurrency>AFA or ALL or DZD or ARS or AWG or AUD or BSD or BHD or BDT or BBD or BZD or BMD or BTN or BOB or BWP or BRL or GBP or BND or BIF or XOF or XAF or KHR or CAD or CVE or KYD or CLP or CNY or COP or KMF or CRC or HRK or CUP or CYP or CZK or DKK or DJF or DOP or XCD or EGP or SVC or EEK or ETB or EUR or FKP or GMD or GHC or GIP or XAU or GTQ or GNF or GYD or HTG or HNL or HKD or HUF or ISK or INR or IDR or IQD or ILS or JMD or JPY or JOD or KZT or KES or KRW or KWD or LAK or LVL or LBP or LSL or LRD or LYD or LTL or MOP or MKD or MGF or MWK or MYR or MVR or MTL or MRO or MUR or MXN or MDL or MNT or MAD or MZM or MMK or NAD or NPR or ANG or NZD or NIO or NGN or KPW or NOK or OMR or XPF or PKR or XPD or PAB or PGK or PYG or PEN or PHP or XPT or PLN or QAR or ROL or RUB or WST or STD or SAR or SCR or SLL or XAG or SGD or SKK or SIT or SBD or SOS or ZAR or LKR or SHP or SDD or SRG or SZL or SEK or CHF or SYP or TWD or TZS or THB or TOP or TTD or TND or TRL or USD or AED or UGX or UAH or UYU or VUV or VEB or VND or YER or YUM or ZMK or ZWD or TRY</FromCurrency>
<ToCurrency>AFA or ALL or DZD or ARS or AWG or AUD or BSD or BHD or BDT or BBD or BZD or BMD or BTN or BOB or BWP or BRL or GBP or BND or BIF or XOF or XAF or KHR or CAD or CVE or KYD or CLP or CNY or COP or KMF or CRC or HRK or CUP or CYP or CZK or DKK or DJF or DOP or XCD or EGP or SVC or EEK or ETB or EUR or FKP or GMD or GHC or GIP or XAU or GTQ or GNF or GYD or HTG or HNL or HKD or HUF or ISK or INR or IDR or IQD or ILS or JMD or JPY or JOD or KZT or KES or KRW or KWD or LAK or LVL or LBP or LSL or LRD or LYD or LTL or MOP or MKD or MGF or MWK or MYR or MVR or MTL or MRO or MUR or MXN or MDL or MNT or MAD or MZM or MMK or NAD or NPR or ANG or NZD or NIO or NGN or KPW or NOK or OMR or XPF or PKR or XPD or PAB or PGK or PYG or PEN or PHP or XPT or PLN or QAR or ROL or RUB or WST or STD or SAR or SCR or SLL or XAG or SGD or SKK or SIT or SBD or SOS or ZAR or LKR or SHP or SDD or SRG or SZL or SEK or CHF or SYP or TWD or TZS or THB or TOP or TTD or TND or TRL or USD or AED or UGX or UAH or UYU or VUV or VEB or VND or YER or YUM or ZMK or ZWD or TRY</ToCurrency>
</ConversionRate>
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<ConversionRateResponse xmlns="http://www.webserviceX.NET/">
<ConversionRateResult>double</ConversionRateResult>
</ConversionRateResponse>
</soap12:Body>
</soap12:Envelope>
HTTP GET

The following is a sample HTTP GET request and response. The placeholders shown need to be replaced with actual values.

GET /CurrencyConvertor.asmx/ConversionRate?FromCurrency=string&ToCurrency=string HTTP/1.1
Host: www.webservicex.net
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<double xmlns="http://www.webserviceX.NET/">double</double>
HTTP POST

The following is a sample HTTP POST request and response. The placeholders shown need to be replaced with actual values.

POST /CurrencyConvertor.asmx/ConversionRate HTTP/1.1
Host: www.webservicex.net
Content-Type: application/x-www-form-urlencoded
Content-Length: length

FromCurrency=string&ToCurrency=string
HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: length

<?xml version="1.0" encoding="utf-8"?>
<double xmlns="http://www.webserviceX.NET/">double</double>

Re: Realtime Exchange Rate (web services)

Posted: Tue Aug 13, 2013 4:06 pm
by rdonnay
This will take far more time than I have available.
I just don't have the time to do this for you.

Re: Realtime Exchange Rate (web services)

Posted: Tue Aug 13, 2013 4:07 pm
by patito
Hi

Download free Loadui 1.5
only the soapui free is necessary
http://www.soapui.org/?utm_expid=56905- ... 7zFzQJHB0A


Look at this link, this can help,

activex Createobject("MSXML2.ServerXMLHTTP")

which can be downloaded from this example


http://www.xbwin.com/forum.html
news.xbwin.com/ot4xb.examples

Best Regard
Hector Pezoa

Re: Realtime Exchange Rate (web services)

Posted: Tue Aug 13, 2013 11:50 pm
by skiman
Hi,

See the soaptest in the samples folder of eXPress++. With this tool you can test the webservice. Afterwards it will be easy to develop this with xb2net. Below a sample to check for an european VAT number. The code for a soap request is rather easy.

Code: Select all

   oAgent := xbSOAPEnvelope():new()
   oAgent:SetStyle( SOAP_STYLE_DOCUMENT )
   oAgent:NameSpace := "urn:ec.europa.eu:taxud:vies:services:checkVat:types"
   oAgent:SetVar("countryCode", upper(alltrim(cCountryCode)))
   oAgent:SetVar("vatNumber", upper(alltrim(cVatNumber)))
   oResult := oAgent:Execute("http://ec.europa.eu/taxation_customs/vies/services/checkVatService", "checkVat")

 wtf oResult:getvar('valid') , oResult:getvar('name') , oResult:getvar('address') , oResult:getvar('isvalid') , oResult:getvar('retdate') 
   
.

Hope this helps.

Re: Realtime Exchange Rate (web services)

Posted: Thu Aug 15, 2013 6:19 pm
by patito
Hi Joe

attach tutorial soauip project, its easy
http://www.soapui.org/Getting-Started/y ... oject.html

example with

#include "ot4xb.ch"
---------------------------------------------------------------------------
init proc _main_init_proc_ ; @ole32:OleInitialize(0) ; return
exit proc _main_exit_proc_ ; @ole32:OleUninitialize(); return
---------------------------------------------------------------------------
static function _urlenc(cStr)
local p,cc
DEFAULT cStr := ""
p := @ot4xb:ot4xb_urlencode(cStr,Len(cStr),0)
cc := PeekStr(p,,-1)
_xfree(p)
return cc
---------------------------------------------------------------------------
function cSendSms( cNumber,cMsg,cUser,cPwd)
local oHttp := TServerXMLHTTPRequest():New()
local v,n
local cResult := NIL
local cUrl := "http://www.smscountry.com/SMSCwebservice.asp"
local cRequest := cPrintf( "%s?User=%s&passwd=%s&mobilenumber=%s&message=%s",;
cUrl,_urlenc(User),_urlenc(cPwd),_urlenc(cNumber),_urlenc(cMsg) )
oHttp:Open("GET",cRequest)
if oHttp:Send()
cResult := oHttp:responseText
end
oHttp:Release()
return cResult

best regard
Hector