1. Frankel David
  2. PowerBuilder
  3. 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)
Frankel David Accepted Answer Pending Moderation
  1. Thursday, 20 October 2022 05:52 AM UTC
  2. PowerBuilder
  3. # 1

Thanks Andreas.

I found the problem in the end that was nothing to do with the language.

This was the culprit:

li_rc = lnv_HttpClient.SetRequestHeader("Accept-Encoding", "gzip, deflate, br")

When I removed this header I started getting results.

But your comment helped as I knew that somehow it should work.

 

thanks again.

d.f.

 

Comment
There are no comments made yet.
Andreas Mykonios Accepted Answer Pending Moderation
  1. Wednesday, 19 October 2022 11:26 AM UTC
  2. PowerBuilder
  3. # 2

Hi.

I'm in Greece, and the service works fine...

The only thing I thing you should do is to change your Content-Type header from:

li_rc = lnv_HttpClient.SetRequestHeader("Content-Type", "text/xml")
// to
li_rc = lnv_HttpClient.SetRequestHeader("Content-Type", "text/xml;charset=UTF-8")

Andreas.

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.