Realtime Exchange Rate (web services)

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
unixkd
Posts: 565
Joined: Thu Feb 11, 2010 1:39 pm

Realtime Exchange Rate (web services)

#1 Post by unixkd »

Hi all

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

Thanks

Joe.

User avatar
rdonnay
Site Admin
Posts: 4734
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Realtime Exchange Rate (web services)

#2 Post by rdonnay »

Do you own Xb2.Net or ASINET?
The eXpress train is coming - and it has more cars.

User avatar
unixkd
Posts: 565
Joined: Thu Feb 11, 2010 1:39 pm

Re: Realtime Exchange Rate (web services)

#3 Post by unixkd »

Yes, I have both Xb2net and ASINET

Thanks.

User avatar
rdonnay
Site Admin
Posts: 4734
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Realtime Exchange Rate (web services)

#4 Post 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.
The eXpress train is coming - and it has more cars.

User avatar
unixkd
Posts: 565
Joined: Thu Feb 11, 2010 1:39 pm

Re: Realtime Exchange Rate (web services)

#5 Post 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>

User avatar
rdonnay
Site Admin
Posts: 4734
Joined: Wed Jan 27, 2010 6:58 pm
Location: Boise, Idaho USA
Contact:

Re: Realtime Exchange Rate (web services)

#6 Post by rdonnay »

This will take far more time than I have available.
I just don't have the time to do this for you.
The eXpress train is coming - and it has more cars.

patito
Posts: 121
Joined: Tue Aug 31, 2010 9:01 pm

Re: Realtime Exchange Rate (web services)

#7 Post 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

skiman
Posts: 1189
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Realtime Exchange Rate (web services)

#8 Post 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.
Best regards,

Chris.
www.aboservice.be

patito
Posts: 121
Joined: Tue Aug 31, 2010 9:01 pm

Re: Realtime Exchange Rate (web services)

#9 Post 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

Post Reply