Using European VAT Verification SOAP Service

Ok i’ll try it asap.
Thanks
I’ll let you know.

Regards

SOAPMethod works now.

[code] Dim sm as New SOAPMethod
Dim sr as SOAPResult
Dim sock As New HTTPSecureSocket
sock.Secure=True
sock.SetRequestHeader(“User-Agent”,“User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20100101 Firefox/21.0”)
sm.UseSocket(sock)
sm.Parameter(“countryCode”) = Uppercase(country.text) // Country : AT
sm.Parameter(“tinNumber”) = tin.text // Tin number : 999/9999
sm.methodNamespace = “urn:ec.europa.eu:taxud:tin:services:checkTin:types”
sm.timeout = 20
sm.url=“https://ec.europa.eu/taxation_customs/tin/services/checkTinService.wsdl

sr = sm.Invoke(“checkTin”)
If sr.error = True then
MsgBox "ERROR: " + sr.errorMessage
End if

If sr.result(“validStructure”) = “false” Then
MsgBox sr.result(“validStructure”)
End If

If sr.result(“validStructure”) = “true” Then
MsgBox sr.result(“validStructure”)
End If[/code]

Christian, However don’t worry, your example will be useful for me, and it could help me for understand how to use CURL. I’ve tested your example yesterday night, and it works too.

Here with SOAP Method, the code is more short.

I know that we can do lots of app with CURL So it will be interesting for me.

In any cases, thanks at all for your help. :slight_smile:

just tried this soapmethod, but for VAT searching
http://ec.europa.eu/taxation_customs/vies/checkVatTestService.wsdl
and I get a NilObjectException on the line sr = sm.Invoke("checkVat")
it seems sr is nil, and sm is ok
what can it be ?
I even cannot check for sr is nil because it seems I’m stopped inside the Invoke method …

Dim sm As New SOAPMethod
Dim sr As SOAPResult
Dim sock As New HTTPSecureSocket
sock.Secure=True
sock.SetRequestHeader("User-Agent","User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20100101 Firefox/21.0")
sm.UseSocket(sock)
sm.Parameter("countryCode") = Uppercase(aCountry)  // Country : AT
sm.Parameter("vatNumber") = aVAT                   // Tin number : 999/9999
sm.methodNamespace = "urn:ec.europa.eu:taxud:vies:services:checkVat:types"
sm.timeout = 20
sm.url="http://ec.europa.eu/taxation_customs/vies/checkVatTestService.wsdl"

sr = sm.Invoke("checkVat")

well I’ve solved the previous error, but I come on another …
new code :

Dim sm As New SOAPMethod("http://ec.europa.eu/taxation_customs/vies/checkVatTestService.wsdl")
Dim sr As SOAPResult
sm.methodNamespace = "urn:ec.europa.eu:taxud:vies:services:checkVat:types"
sm.Parameter("countryCode") = Uppercase(aCountry)  // Country : XX
sm.Parameter("vatNumber") = aVAT                   // Vat number : 99999999999

sr = sm.Invoke("checkVat")

sr is not nil, but I have an error inside :

[quote]
Unexpected wrapper element {urn:ec.europa.eu:taxud:vies:services:checkVat}checkVat found. Expected {urn:ec.europa.eu:taxud:vies:services:checkVat:types}checkVat.[/quote]
what can it come from ?
thanks.

nevermind … just read the first post and the answer … :wink:
Edit: and no it doesnt work I have again sr =nil …
what can be wrong ?
I’m not a wsdl expert at all … there must be something simple I didn’t see…

I think I have an example for that included with MBS Plugins…

Here
https://www.monkeybreadsoftware.net/example-main-vatidcheck-vatcheck.shtml

And
https://www.monkeybreadsoftware.net/example-main-vatidcheck-vatidcheck.shtml

Here is my code :

[code] dim sm as soapMethod
dim sr as soapResult
dim isValid As Boolean

// create soap method and define parameters
sm = new SOAPMethod
sm.parameter(“countryCode”) = countryCode
sm.parameter(“vatNumber”) = vatNumber

// setup method properties
sm.methodNamespace = “urn:ec.europa.eu:taxud:vies:services:checkVat:types”
sm.timeout = 20 // 20 secondes
sm.url = “http://ec.europa.eu/taxation_customs/vies/services/checkVatService

// call the method
sr = sm.invoke(“checkVat”)

if sr = nil OR sr.error then
'There is an error
else
isValid = (sr.Result(“valid”) = “true”)
if isValid then
theName = Trim(sr.Result(“name”))
theAddress = Trim(sr.Result(“address”))
else
'…
end if
end if[/code]
Note tha I don’t use a socket.

Best regards

your code has :

sm.url = "http://ec.europa.eu/taxation_customs/vies/services/checkVatService"

and mine was :

sm.url = "http://ec.europa.eu/taxation_customs/vies/checkVatService"

now I dont get a nil exception, but a “SERVICE UNAVAILABLE” returning from the web service.
that’s still not OK for me, but this is far better than before !
thanks.

Just checked now and it work for me.
Tested with a valid belgium vat number.

haaaaaaa !!!
I had “checkVatTestService” and it must be “checkVatService” at the end of the url !!!
now it works !!!
many many thanks !