Using European VAT Verification SOAP Service

The URL to query is “https://ec.europa.eu/taxation_customs/tin/services/checkTinService” as you see on the bottom of the WSDL.

Okay, after some debugging, I found that the SOAP code posted above causes an error message from server: Access Denied.

got complete message:

[quote]

Web Filter


Access Denied

Your request has been denied for security reason.



If you believe that this request should not be blocked, please contact EC DIGIT SNet.

If your request is urgent, please contact also the service helpdesk (+32)2 29 58181.
[/quote]

Weird.

if you try with SOAPUI the request works fine.
Perhaps a wrong html header sent from Xojo app to this website and it takes this request as a robot or else.

Hello all.
I’ve a clue.

This morning, i’ve used Wireshark and i’ve discovered an issue.

My URL begins by HTTPS
And the WireShark traces show with the same URL but it begins by HTTP instead of HTTPS

So the result is a bad web page sure.

I need to use this way or something like that. : http://documentation.xojo.com/index.php/SOAPMethod.UseSocket

I’ll let you know.

After some tests, i have the same result like Christian using httpsecuresocket.
Access denied.

I’ve this error using SOAP method : msg:XML parser error 4: not well-formed (invalid token)
This is different than msg:XML parser error 7: mismatched tag

I don’t know why with Xojo it doesn’t work, and with SoapUI it works perfectly.
There’s no difference here, because both are launched on my PC.
And i could not be able to make any traces with wireshark using HTTPS socket.
The traces should be encrypted sure.

when asking via http instead of https, I get here:

[quote]

The requested page does not exist - European Commission[/quote]

So http is not supported.

Yes , it seems that only HTTPS is accepted.
The server doesn’t switch on HTTPS when a HTTP is received.

I must to find a way to do it and that this function works correctly.
But until i cannot know why this webservice rejects my request (Access denied), i could not finish this one.

It’s near the solution, i know.

Did you call the phone number from error message?

Hmmm , no, but i could try to send a mail.
I remember that i’ve tried to do it one years ago, but i’ve had not any response.
I could try again indeed.

I got an answer:

[quote]Your IP address has been blocked because you (your IP address at least) did a lot of requests to " https://ec.europa.eu/taxation_customs/tin/services/checkTinService" without a user agent.
This kind of traffic is detected as an attack by our security system => your IP address is completely blocked => you can’t access any other European Commission web application.
I’ve “un-jailed” your IP address, but if the traffic mentioned above continues like explained, you will probably be blocked again[/quote]

I’ll try it now.

ok
I’ve just sent a mail.
Waiting a reply.

Perhaps add:

SOAPServer.SetRequestHeader("User-Agent","User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20100101 Firefox/21.0")

I got it working :slight_smile:

like this:

[code] dim c as new CURLSMBS

dim xml as string = XMLTemplate

xml = Replace(xml, “$country$”, TextField1.text)
xml = Replace(xml, “$number$”, TextField2.text)

List.AddRow “Check “+TextField2.text+”…”

c.OptionFollowLocation = true
c.OptionMaxRedirs = 3
c.OptionPostFields = xml
c.OptionUserAgent = “MBS TIN Check 1.0”
c.OptionURL = “https://ec.europa.eu/taxation_customs/tin/services/checkTinService
c.OptionPost = true
c.SetOptionHTTPHeader array(“Content-Type: application/soap+xml; charset=utf-8”)

dim e as integer = c.Perform

dim debugMessage as string = c.DebugData
dim Result as STring = c.OutputData

if e = 0 then
dim r as integer = c.GetInfoResponseCode

if r = 200 then
  // ok
  
  dim doc as new XmlDocument(result)
  dim envelope as XmlNode = FindChild(doc, "envelope")
  dim body as XmlNode = FindChild(envelope, "body")
  dim checkTinResponse as XmlNode = FindChild(body, "checkTinResponse")
  
  dim x as XmlNode = checkTinResponse.FirstChild
  while x <> nil
    dim key as string = x.Name
    dim value as string = getText(x)
    
    List.AddRow key+": "+value
    x = x.NextSibling
  wend
  
else
  List.AddRow "HTTP error: "+str(r)
end if

else
List.AddRow "CURL error: “+str(e)+” "+c.LasterrorMessage
end if

List.ScrollPosition = List.ListCount
[/code]

I’ll include this as example project for my next plugins.
If you like to get a copy, send me an email.

You mean that i need to buy MBS plugin to use your example, doesn’t it? lol
I could be agree because is not too expensive, and by the way, i could use it for LDAP protocole in a future.

In any cases, thanks a lot for your help Christian.

How to find your email address?
Nothing in your profile.
My mail is franck.danad(at)roomx.fr

It’s done.
I bought your plugin

Now it works with HttpSecureSocket.
I’ve just add the user-agent in the HTML header.

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
 <soap:Body>
  <checkTinResponse xmlns="urn:ec.europa.eu:taxud:tin:services:checkTin:types">
   <countryCode>at</countryCode>
   <tinNumber>999/9999</tinNumber>
   <requestDate>2015-11-10+01:00</requestDate>
   <validStructure>true</validStructure>
  </checkTinResponse>
 </soap:Body>
</soap:Envelope>

Don’t worry for the CURL plugin, it could be useful in a future :wink:

My example:

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

requete =TextArea2.Text // include the WS request
'Create a HTTPSecureSocket
Dim SOAPServer as new HTTPSecureSocket
SOAPServer.Secure = True

'Send the XML SOAP Data
SOAPServer.SetRequestHeader(“User-Agent”,“User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:12.0) Gecko/20100101 Firefox/21.0”)
SOAPServer.SetRequestContent (requete, “text/xml; charset=UTF-8”)

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

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

WS request:

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

Result:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <checkTinResponse xmlns="urn:ec.europa.eu:taxud:tin:services:checkTin:types"> <countryCode>at</countryCode> <tinNumber>999/9999</tinNumber> <requestDate>2015-11-10+01:00</requestDate> <validStructure>true</validStructure> </checkTinResponse> </soap:Body> </soap:Envelope>

I emailed you the example.
Thanks.