Using European VAT Verification SOAP Service

Hello everyone,
I am trying to use a SOAP service that confirms the VAT number in Europe. It exists in http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl.
Now, if I use it as the SOAP examples I get a string “soap:Client” with no other content.
The code I use for this is:

Dim sm As New SOAPMethod("http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl") Dim reply As String reply = sm.checkVat("EL", "999445290")

The “EL” stands for Greece and the 999445290 is a valid VAT Number. The web service should return the company info (which it does from other systems).

If I use the “invoke” method the SOAPResult returns the following error:
“Unexpected wrapper element {urn:ec.europa.eu:taxud:vies:services:checkVat}checkVat found. Expected {urn:ec.europa.eu:taxud:vies:services:checkVat:types}checkVat.”

Any ideas how I can use the SOAP service ?

Thank you in advance.

Fotis…

Try this:

dim sm as soapMethod
dim sr as soapResult

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

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

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

I have that in my Apps. Maybe later I can post some code.

James thank you. That worked…

Christian if you would post also some code, I would love to see the way you would access the web service.

Seems the examples in the LR simply do not work :frowning:

Thank you James for posting a working sample :slight_smile:

here is something:

[code]Sub Action()
List.DeleteAllRows

dim v1 as string = ConvertEncoding(vat1.Text, encodings.UTF8)
dim v2 as string = ConvertEncoding(vat2.Text, encodings.UTF8)
dim co as string = ConvertEncoding(Company.Text, encodings.UTF8)
dim ci as string = ConvertEncoding(city.Text, encodings.UTF8)
dim zi as string = ConvertEncoding(Zip.Text, encodings.UTF8)
dim st as string = ConvertEncoding(Street.Text, encodings.UTF8)

v1 = EncodeURLComponent(v1)
v2 = EncodeURLComponent(v2)
co = EncodeURLComponent(co)
ci = EncodeURLComponent(ci)
zi = EncodeURLComponent(zi)
st = EncodeURLComponent(st)

dim url as string = “https://evatr.bff-online.de/evatrRPC?UstId_1="+v1+"&UstId_2="+v2+"&Firmenname="+co+"&Ort="+ci+"&PLZ="+zi+"&Strasse="+st+"&Druck=
dim data as string = sock.get(url, 90)

if DebugBuild then
try
dim f as FolderItem = GetFolderItem(“vat.txt”)
dim t as TextOutputStream = TextOutputStream.Create(f)
t.Write data
catch io as IOException
break
end try
end if

dim doc as new XmlDocument(Data)

dim params as XmlNode = doc.FirstChild
dim param as XmlNode = params.FirstChild
while param <> nil
dim pvalue as XmlNode = param.FirstChild
if pvalue<>Nil then
dim parray as XmlNode = pvalue.FirstChild
if parray<>Nil then
dim pdata as XmlNode = parray.FirstChild
if pdata<>nil then
dim pvalue1 as XmlNode = pdata.Child(0)
dim pvalue2 as XmlNode = pdata.Child(1)

      if pvalue1 = nil then Return
      if pvalue2 = nil then Return
      
      dim string1 as xmlnode = pvalue1.FirstChild
      dim string2 as xmlnode = pvalue2.FirstChild
      dim text1 as xmlnode = string1.FirstChild
      dim text2 as xmlnode = string2.FirstChild
      dim s1, s2 as string
      if text1<>Nil then s1 = text1.Value
      if text2<>Nil then s2 = text2.Value
      
      Select case s1
      case "Erg_Name", "Erg_Ort", "Erg_PLZ", "Erg_Str"
        select case s2
        case "A"
          s2 = "OK"
        case "B"
          s2 = "Falsch!"
        case "C"
          s2 = "nicht abgefragt"
        case "D"
          s2 = "nicht verfügbar"
        end Select
      end Select
      
      List.AddRow s1, s2
      
      if s1 = "ErrorCode" then
        result.text = ErrorDescription(val(s2))
      end if
    end if
  end if
end if

param = param.NextSibling

wend

Exception x as XmlException

exception n as NilObjectException

End Sub
[/code]

as you see simply a query with HTTPSocket passing parameters in URL.

Thank you Christian,
However, there must be something missing in your code, as I cannot see the HTTPSocket anywhere…

Of course. It’s part of the window.

Well, some homework should be there for you. (beside translation of variable names)

So, as far as I understand, you send a POST request with the XML document and you receive another XML document (that contains the desired response data).
Are you using a HTTPRequest.Post or a HTTPSocket.SendRequest? And how do you pass the XML? Do you use HTTPSocket.SetRequestContent? Do you also use HTTPSocket.SetRequestHeader?

Do you suggest using a HTTPRequest instead of SOAPMethod?

Thank you in advance for your reply.

as you see, we use HTTPSocket.get as sock is a HTTPSocket.

As you see .SetRequest* methods are not called.

and I don’t use built in SOAP classes.
For real SOAP stuff, I use my own SOAP Kit :slight_smile:

Thank you Christian.
Sorry, I didn’t look closely enough and didn’t notice the sock variable…
I have seen that you have the SOAP Kit, but it is quite expensive. Is there any way to test it and evaluate it before considering buying it?

If you remember a previous post of mine, in another project I need to create the SOAP service, that a third party app (built in VS C#) will be using the services. Does your kit provide functionality for that?

I normally create people a test project to make sure the SOAP kit works well with the service.
But once you have the source code, we need you to buy the kit as there is no way to give it back…

Does it also support classes for SOAP server?

I am alos interested in this. :slight_smile:

@Christoph: see above

SOAP Kit reads the wsdl file and creates source code for xojo.
You call functions with parameters to send soap requests and get back events.

Which means - if I am not mistaken - that it is for mainly for client use and not so much for server?

Yes for client

Hi FOTIS GEORGIADIS

Have you successfully resolved your issue?
I’ve tried to do the code which worked last year, and today, it doesn’t work.
I’ve tried using httpsocket also like this.

[code]
'Make an HTTPSocket to
Dim s, requete as string

requete =TextArea2.Text
'Create a HTTPSocket

Dim SOAPServer as new HTTPSocket

'Send the XML SOAP Data
SOAPServer.SetRequestContent (requete, “text/xml; charset=UTF-8”)

'Get the recieved SOAP XML
s = SOAPServer.Post (“https://ec.europa.eu/taxation_customs/tin/checkTinService.wsdl”,15)

'Show the recieved data
TextArea1.Text = DefineEncoding (s, Encodings.UTF8)[/code]

Inside TextArea2 :

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:ec.europa.eu:taxud:tin:services:checkTin:types"> <soapenv:Header/> <soapenv:Body> <urn:checkTin> <urn:countryCode>at</urn:countryCode> <urn:tinNumber>999/9999</urn:tinNumber> </urn:checkTin> </soapenv:Body> </soapenv:Envelope>

But the website returns :

[code]
…/…

.../... Sorry, the page you wanted isn't here[/code]

But when i try to use SoapUI No problem. It works fine.
It looks like this website avoids to give a result with Xojo application.