Skip to content

Instantly share code, notes, and snippets.

@seguri
Created January 31, 2017 20:55
Show Gist options
  • Save seguri/2d4faa0dc65bcb30fe8f5ee0dda0d983 to your computer and use it in GitHub Desktop.
Save seguri/2d4faa0dc65bcb30fe8f5ee0dda0d983 to your computer and use it in GitHub Desktop.
vat_validator
package com.example.vat_validator;
import eu.europa.ec.taxud.vies.services.checkvat.CheckVatPortType;
import eu.europa.ec.taxud.vies.services.checkvat.CheckVatService;
import javax.xml.datatype.XMLGregorianCalendar;
import javax.xml.ws.Holder;
public class Main {
public static void main(String[] args) {
// Get service
CheckVatService service = new CheckVatService();
CheckVatPortType port = service.getCheckVatPort();
// Input
String countryCode = "IT";
String vatNumber = "06700351213"; // TODO Sanitize
// Output
Holder<XMLGregorianCalendar> xgc = new Holder<>();
Holder<Boolean> valid = new Holder<>();
Holder<String> name = new Holder<>();
Holder<String> address = new Holder<>();
// Send
port.checkVat(new Holder<>(countryCode), new Holder<>(vatNumber), xgc, valid, name, address);
// Check
System.out.println("Req date: " + xgc.value);
System.out.println("Valid ? " + valid.value);
System.out.println("Name : " + name.value);
System.out.println("Address : " + address.value);
}
}
21:51:40 mark@localhost:/t/vat_validator % mvn -o -q clean compile exec:java
Req date: 2017-01-31+01:00
Valid ? true
Name : FACTORIA S.R.L.
Address : VIA FILIPPO PALIZZI 19/A
80127 NAPOLI NA
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment