Validate customs XML against an XSD before you send it
Customs portals and TMS interfaces often take strict XML, and a rejection can come back long after the message was sent, with little to go on. Validate XML checks a message against the schema files you already have, in the run, and lists every error by line and path.
Use this templateNeeds an AI connection.
1. Add the schema set
Section titled “1. Add the schema set”Most customs schemas import or include other files, so a single file rarely works. In Schema files, give a .zip of the whole set, or several .xsd files, and set Main schema to the one that defines the message. For one standalone schema, paste it in Schema instead (up to 64,000 characters).
Imports and includes resolve only to relative paths inside the files you supply. Nothing is fetched from the network, so a schema that imports from a URL has to be rewritten to a relative path, with that file added to the set.
2. Give it the message
Section titled “2. Give it the message”Set XML document to the text, or XML file to a file, for example from Read object or an upload. Files must be UTF-8, and the XML file can be at most 8 MiB.
3. Connect both exits
Section titled “3. Connect both exits”By default an invalid message doesn’t fail the step. It continues on Invalid with Error count, Summary and Errors, each error giving its line, column, path, element and message. So connect both exits:
- Valid goes on to HTTP Request or SOAP Request.
- Invalid goes to an Approval that shows the Summary, or to whatever raised the message.
If an invalid message should never get past this point, set When invalid to fail the run instead.
Building the message instead
Section titled “Building the message instead”If your automation builds the XML itself, you may not need this block. Upload XSD on HTTP Request builds the body from the portal’s schema files, and a body that doesn’t match isn’t sent. Use Validate XML for XML that comes from elsewhere, such as your TMS or a partner.
What goes wrong
Section titled “What goes wrong”- A broken schema set fails the step. It doesn’t give an invalid verdict, so a run that fails here points at your schema files, not the message.
- Valid is not the same as accepted. A schema checks structure and formats. It can’t know whether an EORI is enrolled or a code applies to these goods, so the portal can still reject a valid message.
- Long error lists are cut. Errors lists 20 by default, up to 200. Error count counts them all, and More errors than listed says when some are left out.
Try it
Section titled “Try it”Validation runs inside Lainstack with no outside system, so a draft run gives you the real verdict. Try it on a message your portal has already rejected.
- Send a UK import declaration to CDS, which runs this kind of check for you
- Connect a customs portal
- Validate XML reference