RAD Communicating with an External WebService
As we delve into the world of web services, discover how to seamlessly integrate the VIES Check-VAT WebService into your RAD/Eclipse environment, unlocking a world of streamlined VAT verification and validation. With a few simple steps, you can harness the power of this external web service to elevate your development capabilities. By following this straightforward guide, you'll be well on your way to mastering the art of web service integration and revolutionizing your workflow.

- Download the .WSDL from here
- Right click on the “WebSphereCommereServerExtensionsData” folder and select New > Folder. I have named it “WebService”.
- Now copy the downloaded WebService into this folder.
- Now right click on the “checkVATService.wsdl” file and select: Web Services > Generate Client.

- Click on “Next” to proceed.

- Provide a name for the target package and click “Finish”.

- Once the client is generated, the files we can play around with are displayed as below:

- Now incorporate the following code in any command to make the WebService call.
public String checkVatAppox(String strFullVatNumber) {
String strIsValid = "false";
String strReferenceReq = "";
try {
CheckVatPortProxy proxy = new CheckVatPortProxy();
CheckVatApprox vatParameters = new CheckVatApprox();
CheckVatApproxResponse responseData = new CheckVatApproxResponse();
// Removing blank spaces
strFullVatNumber = strFullVatNumber.replaceAll(" ", "");
Holder<String> hCountryCode = new Holder(strFullVatNumber.substring(0, 2));
Holder<String> hVatNumber = new Holder(strFullVatNumber.substring(2, strFullVatNumber.length()));
Holder<String> hTraderName = new Holder();
Holder<String> hTraderCompanyType = new Holder();
Holder<String> hTraderStreet = new Holder();
Holder<String> hTraderPostcode = new Holder();
Holder<String> hTraderCity = new Holder();
String strRequesterCountryCode = "GB";
String strRequesterVatNumber = "155442220";
Holder<XMLGregorianCalendar> hRequestDate = new Holder();
Holder<Boolean> hValid = new Holder();
Holder<String> hTraderAddress = new Holder();
Holder<String> hTraderNameMatch = new Holder();
Holder<String> hTraderCompanyTypeMatch = new Holder();
Holder<String> hTraderStreetMatch = new Holder();
Holder<String> hTraderPostcodeMatch = new Holder();
Holder<String> hTraderCityMatch = new Holder();
Holder<String> hRequestIdentifier = new Holder();
proxy.checkVatApprox(hCountryCode, hVatNumber, hTraderName, hTraderCompanyType,
hTraderStreet, hTraderPostcode, hTraderCity,
strRequesterCountryCode, strRequesterVatNumber, hRequestDate,
hValid, hTraderAddress, hTraderNameMatch, hTraderCompanyTypeMatch,
hTraderStreetMatch, hTraderPostcodeMatch, hTraderCityMatch,
hRequestIdentifier);
LOGGER.info("VAT: " + hCountryCode.value + " - " + hVatNumber.value + " - " + hValid.value +
" - " + hRequestDate.value + " - " + hRequestIdentifier.value);
strIsValid = hValid.value.toString();
strReferenceReq = hRequestIdentifier.value;
} catch (Exception e) {
strIsValid = "Offline";
LOGGER.info("Cannot validate VAT right now as the server is busy...");
}
return strIsValid + "<>" + strReferenceReq;
}

