- Frankel David
- PowerBuilder
- Wednesday, 19 October 2022 10:58 AM UTC
I am using the European VIES API to check the VAT number of European customers.
I send the country and vat number and get back a response.
All works well except for the main country that I need and that is Greece which returns the result in Greek.
But PB doesn't seem to understand Greek.
lnv_HttpClient.GetResponseBody(ls_response) returns: �
If I activate Fiddler and try again powerbuilder works correctly:
lnv_HttpClient.GetResponseBody(ls_response) returns:-<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"><env:Header/><env:Body><ns2:checkVatResponse xmlns:ns2="urn:ec.europa.eu:taxud:vies:services:checkVat:types"><ns2:countryCode>EL</ns2:countryCode><ns2:vatNumber>094186625</ns2:vatNumber><ns2:requestDate>2022-10-19+02:00</ns2:requestDate><ns2:valid>true</ns2:valid><ns2:name>AFEA ΑΝΩΝΥΜΗ ΕΜΠΟΡΙΚΗ ΤΟΥΡΙΣΤΙΚΗ ΚΑΙ ΞΕΝΟΔΟΧΕΙΑΚΗ ΕΤΑΙΡΕΙΑ||AFEA TRAVEL AND TOURISM</ns2:name><ns2:address>ΛΥΚΑΒΗΤΤΟΥ 39 10672 - ΑΘΗΝΑ</ns2:address></ns2:checkVatResponse></env:Body></env:Envelope>
If the result is in English then no problem.
I have tried changing the computer Locale to Greek but that did not help.
Postman also returns correct data.
We are using pb2017 - has there been a change since then ?
below is the code.
Long ll_timeout = 15
string ls_user
string ls_password
string ls_header
string ls_mime
string ls_ReturnJson
string ls_request
string ls_response
long ll_length
string ls_url
string ls_host
string ls_vies_code
string cr = '~r~n'
SELECT "t017_nationality_codes"."c_vies_code"
INTO :ls_vies_code
FROM "t017_nationality_codes"
WHERE "t017_nationality_codes"."nationality_code" = :as_country ;
ls_url = "http://ec.europa.eu/taxation_customs/vies/services/checkVatService"
ls_xml = "<s:Envelope xmlns:s='http://schemas.xmlsoap.org/soap/envelope/'><s:Body><checkVat xmlns='urn:ec.europa.eu:taxud:vies:services:checkVat:types'>"
ls_xml += "<countryCode>" + ls_vies_code + "</countryCode>"
ls_xml += "<vatNumber>" + as_vatnumber + "</vatNumber></checkVat></s:Body></s:Envelope>"
ll_length = len(ls_xml)
li_rc = lnv_HttpClient.SetRequestHeader("Cache-Control", "no_cache")
li_rc = lnv_HttpClient.SetRequestHeader("Content-Type", "text/xml")
li_rc = lnv_HttpClient.SetRequestHeader("Content-Length", string(ll_length))
li_rc = lnv_HttpClient.SetRequestHeader("Connection", 'keep-alive')
li_rc = lnv_HttpClient.SetRequestHeader("Accept", '*/*')
li_rc = lnv_HttpClient.SetRequestHeader("Accept-Encoding", "gzip, deflate, br")
li_rc = lnv_HttpClient.SetRequestHeader("host", 'ec.europa.eu')
lnv_HttpClient.Timeout = ll_timeout
long ll_tries
string ls_return_text
ll_tries = 0
li_rc = lnv_HttpClient.SendRequest( "POST", ls_url, ls_xml)
ls_return_text = ''
IF li_rc<0 THEN
if li_rc = -1 then
ls_return_text = '-1 General Error returned'
elseif li_rc = -2 then
ls_return_text = '-2 Invalid URL'
elseif li_rc = -3 then
ls_return_text = '-3 Cannot connect to the api'
elseif li_rc = -4 then
ls_return_text = '-4 API Timed Out!'
else
ls_return_text = string(li_rc) + ' Unspecified Error'
end if
end if
int li_StatusCode = 0
string ls_StatusText = ''
li_StatusCode = lnv_HttpClient.GetResponseStatusCode()
ls_StatusText = lnv_HttpClient.GetResponseStatusText()
ls_StatusText = string(li_StatusCode) + ' - ' + ls_StatusText
lnv_HttpClient.GetResponseBody(ls_response)
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.