Skip to main content
Participant
June 4, 2014
Answered

EU VAT WSDL

  • June 4, 2014
  • 6 replies
  • 1386 views

Can anyone help me with this, I am trying to make use of the EU's VAT number checker, I have the location of the WSDL, but my CF knowledge is basic at best and I am struggling to grasp the complexities of how to make the cfc talk to the remote server and give me the information back. I am not particularly after anyone to create the code for me because I would like to do it myself ideally but if anyone has an example CFC that they could show me that would do something similar I would be most greatful.

http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl - wsdl location if you would like to see it.

This topic has been closed for replies.
Correct answer BKBK

OK so I thought I had got it right in my head an now I'm not so sure, what you put before I could working in the page and that was fine. I have now got this far making the component and I'm a bit lost because I cant find anything that gives an example of a CFC running as a remote web service using a 3rd party system anywhere as a guide :/

This is what I have so far in the CFC

<cfcomponent name="vatcheck" hint="checks the clients vat number against the EU system and gives a repsonse to its validity" output="false">

     <cffunction name="checkvat" returntype="any" access="remote">

     <cfargument name="vatnumber" type="string">

 

      <cfinvoke webservice="http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl" method="checkVatRequest"  returnvariable="parameters">

      <cfinvokeargument name="parameters" value="#vatnumber#">

         

     </cfinvoke>

     </cffunction>

  </cfcomponent>

On page

<cfajaxproxy cfc="vatcheck" jsclassname="jsobj" />

var cfcAsAjax = new jsobj();

var data = cfcAsAjax.checkvat(CountryCode +', ' + vatNumber)

So any pointers as to where I have gone wrong would be great


Obviously,

<cffunction name="checkvat" returntype="any" access="remote">

<cfargument name="countryID" type="string"><!--- 2-letter code --->

<cfargument name="vatno" type="string">

<cfinvoke webservice="http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl" method="checkVat"  returnvariable="parameters">

   <cfinvokeargument name="countryCode" value="#arguments.countryID#"> 

   <cfinvokeargument name="vatNumber" value="#arguments.vatno#"> 

</cfinvoke>

<cfreturn parameters>

</cffunction>

Then proceed from there.

6 replies

BKBK
Community Expert
Community Expert
June 5, 2014

CFCs are unnecessary. You already have the WSDL, whose purpose is to describe the web service's interface. In other words, it tells you how to invoke the web service. To see what functions to call, just do something like

<cfset vat_ws_obj=createobject("webservice","http://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl") >

<cfdump var="#vat_ws_obj#">

You will see that the service comprises 2 functions, namely:

checkVat (java.lang.String, java.lang.String)

checkVatApprox (java.lang.String, java.lang.String, java.lang.String, types.checkvat.services.vies.taxud.eu.europa.ec.CompanyTypeCode, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String)

The WSDL tells you the arguments of checkVat are countryCode and vatNumber. For a trader in The Netherlands, that would be something like 'NL' and '123456789B01', respectively.

We also learn from the WSDL that the arguments of checkVatApprox are:

countryCode

vatNumber

traderName

traderCompanyType

traderStreet

traderPostcode

traderCity

requesterCountryCode

requesterVatNumber

They are all strings. However, traderCompanyType must match the regular expression, "[A-Z]{2}\-[1-9][0-9]?".

Participant
June 5, 2014

The reason I was going to put it into a CFC was so that I could pass it into my Javascript via cfajaxproxy so I could make it available to the script I am running. Or am i over thinking the whole thing?

BKBK
Community Expert
Community Expert
June 5, 2014

It all depends on your requirements, of course. In any case, you now have everything you need to put together a CFC.