If this project saved you some time or made your day a little easier, a star would mean a lot — it helps others find it too.
This repository contains a simple, standalone validation service (Phorm) accessible by API only.
The implementation of the validation is based on the open source validation engine phive and the collection of rules phive-rules.
"Phorm" is a combination of "PH + form + conform" and is all about standards, compliance, and correctness.
For calling the API from Java there is the separate client library phorm-client - see Java client library below.
Phorm is one service that is typically used at three different points of a Peppol exchange: while the mapping from the backend format to UBL / CII is still being developed, at C2 immediately before a document is wrapped and transmitted, and - optionally - at C3 when a document has been received. The validation engine and the rule sets are identical in all three cases, so a document that passes at design time passes at run time for the same reason.
Solid lines are the mandatory / primary path; dashed lines are optional or feedback paths.
The three Phorm boxes are the same service, called from three different places.
The diagram source is docs/phorm-peppol-flow.mmd,
a higher quality version for print and editing is docs/phorm-peppol-flow.svg.
While the mapping from the backend format (ERP, accounting software) to UBL or CII is being written, every sample document the mapping produces can be validated immediately. This is the fastest feedback loop available, because it needs no Access Point, no network and no deployment - just an HTTP POST against a running Phorm instance.
Phorm is accessible by API only; there is no interactive validation UI. Two endpoints are relevant here:
POST /api/validate/{vesid}- validate against a rule set that is named explicitlyPOST /api/dd_and_validate- let Phorm determine the document type first and validate against the matching rule set
Both deliver JSON by default, XML with the request header Accept: application/xml, HTML with the request header
Accept: text/html and PDF with the request header Accept: application/pdf - the HTML variant is convenient to
read the findings directly during development, the PDF variant to file or forward them as a report.
Findings from this loop are corrected in the mapping, not in the transmitted document, which is why this touchpoint
feeds back into development and not into the message flow.
At C2 the business document is validated after the mapping has produced it and before SBDH wrapping and AS4 transmission. This is the point where validation is worth the most: an invalid document is rejected back to C1 and never enters the network at all, so the error is fixed where it originates instead of coming back later as a rejection from the far side of the exchange.
Two configuration properties make Phorm usable as a gate and not just as a reporting tool:
phorm.api.requiredtoken- the value theX-TokenHTTP header must carry for any API call to be acceptedphorm.api.admin.token: the specific value of theX-Tokenheader that must be provided to access the admin API (/api/admin/*). If it is empty (the default), the admin API is disabled.phorm.repositories.file: the path to an XML file describing additional external validation repositories - see External repositories below. If it is empty (the default), only the built-in rules are available.phorm.api.response.onfailure.http400- iftrue(the default), a failed validation is answered with HTTP 400 instead of HTTP 200, so the caller can use the HTTP status alone as the gate decision, without parsing the result structure first
If the document to be sent is already wrapped in an SBDH, POST /api/dd_and_validate unwraps it automatically and
validates the payload inside.
C3 can validate a document after AS4 reception and before handing it over to C4, so that the receiving side knows the conformance status of what arrived. This touchpoint is optional - it is drawn with dashed lines for that reason - and Phorm only produces the validation result; what the receiving side does with that result is up to the implementation.
POST /api/dd_and_validate fits this position particularly well, because a document arriving over AS4 is SBDH wrapped:
- the SBDH (or XHE) envelope is unwrapped automatically and the payload inside is validated
- the Peppol SBDH envelope constraints are validated as well and returned as an additional first (envelope) validation layer in the result (since v2.1.5)
- if the SBDH is valid and the payload is a Peppol BIS Billing or PINT document, the SBDH sender and receiver participant IDs are cross checked against the sender and receiver IDs in the payload
All layers are returned in a single phive ValidationResultList, so envelope findings and business rule findings are
available from one call.
A validation always runs against one VESID - the coordinate of a validation executor set in the phive-rules registry. There are two ways of arriving at one.
Explicit: POST /api/validate/{vesid} takes the VESID as part of the path, e.g. eu.peppol.bis3:invoice:latest.
The caller decides which rules apply.
GET /api/get/vesids returns all registered VESIDs.
Automatic: POST /api/determinedoctype, POST /api/dd_and_validate and POST /api/hybrid_validate derive the
VESID from the document itself, using the ddd library:
- Syntax detection - the syntax is determined from the root element namespace URI and the local element name
(e.g. the namespace
urn:oasis:names:specification:ubl:schema:xsd:Invoice-2with the local nameInvoiceleads to the syntaxubl2-invoice) - Field extraction - each syntax carries a set of XPath expressions to read the generic document fields, among them the Customization ID, the Process ID, the Business Document ID and the sender / receiver identifiers, names and country codes
- Value provider lookup - the Customization ID selects the concrete profile of that syntax and delivers the VESID
(as well as the profile name, the syntax version and, for CII based syntaxes, the Process ID).
E.g. the Customization ID
urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0on a UBL Invoice identifies a Peppol BIS Billing UBL Invoice V3 and leads to the VESIDeu.peppol.bis3:invoice:latest-active - Resolution - the determined VESID is parsed and looked up in the registry, that is filled from the aggregating
phive-rules-allandphive-rules-all-legacymodules on the first use ofAppValidator, not during the application startup. If no document details can be determined, or if the determined VESID cannot be parsed or resolved, the call is answered with HTTP 400
So in practice the document type identifier and the Customization ID contained in the document decide the rule set, and neither C2 nor C3 needs to maintain a mapping table of its own.
Mermaid source of the diagram
The image files are generated from docs/phorm-peppol-flow.mmd via:
npx --yes @mermaid-js/mermaid-cli -i docs/phorm-peppol-flow.mmd \
-o docs/phorm-peppol-flow.svg -b transparent
npx --yes @mermaid-js/mermaid-cli -i docs/phorm-peppol-flow.mmd \
-o docs/phorm-peppol-flow.png -b white -s 3
flowchart LR
%% ---------- development time ----------
subgraph SDEV["Development time"]
direction TB
DEV["Integration developer"]
SAMPLE["Sample documents<br/>from the mapping"]
DEV --> SAMPLE
end
PH1{{"<b>Phorm</b><br/>validation service"}}
SAMPLE -->|"① design time:<br/>validate mapping output<br/>(REST API)"| PH1
PH1 -.->|"findings feed back<br/>into the mapping"| DEV
%% ---------- the four corner model ----------
subgraph SC1["C1 — Sender"]
C1["Sending entity<br/>(ERP / accounting software)"]
end
subgraph SC2["C2 — Sending Access Point"]
direction TB
M2["Mapping to<br/>UBL / CII<br/>(Peppol BIS, CIUS)"]
S2["SBDH wrapping<br/>+ AS4 send"]
end
PH2{{"<b>Phorm</b><br/>validation service"}}
subgraph SC3["C3 — Receiving Access Point"]
direction TB
R3["AS4 receive<br/>+ SBDH unwrap"]
H3["Hand over to C4"]
end
PH3{{"<b>Phorm</b><br/>validation service"}}
subgraph SC4["C4 — Receiver"]
C4["Receiving entity<br/>(ERP / accounting software)"]
end
%% ---------- touchpoint 2: C2 outbound gate ----------
C1 --> M2
M2 -->|"② outbound gate:<br/>validate before sending"| PH2
PH2 -->|"valid → transmit"| S2
PH2 -.->|"invalid → reject to C1,<br/>nothing enters the network"| C1
%% ---------- transmission ----------
S2 -->|AS4| R3
%% ---------- touchpoint 3: C3 inbound, optional ----------
R3 -.->|"③ optional:<br/>validate on receipt"| PH3
PH3 -.->|"result available for<br/>C4 processing"| H3
H3 --> C4
classDef corner fill:#f5f7fa,stroke:#4a5568,stroke-width:1px,color:#1a202c
classDef devbox fill:#fdf6e3,stroke:#8a6d3b,stroke-width:1px,color:#1a202c
classDef service fill:#e6f2ff,stroke:#1f5fa9,stroke-width:2px,color:#0b2545
class C1,M2,S2,R3,H3,C4 corner
class DEV,SAMPLE devbox
class PH1,PH2,PH3 service
style SDEV fill:#fffaf0,stroke:#c8b48a,color:#1a202c
style SC1 fill:#ffffff,stroke:#a0aec0,color:#1a202c
style SC2 fill:#ffffff,stroke:#a0aec0,color:#1a202c
style SC3 fill:#ffffff,stroke:#a0aec0,color:#1a202c
style SC4 fill:#ffffff,stroke:#a0aec0,color:#1a202c
- Requires Java 21 or newer
- Apache Maven is used as the build tool. May be abstracted by a Docker image.
- Coding language: English
Phorm exposes two kinds of HTTP endpoints: a handful of top-level servlets (root page, health check, readiness check and status) and the REST API below /api.
The column "Since" names the first Phorm version providing the endpoint. Phorm is versioned since v2.0.0, so all endpoints that existed before are listed with v2.0.0.
| Method | Path | Servlet / Handler | Since | Purpose |
|---|---|---|---|---|
| GET | / |
RootServlet |
v2.0.0 | HTML landing page. In test versions it lists the supported APIs and all registered VESIDs; otherwise it shows only the application name |
| GET | /ping |
PingPongServlet |
v2.0.0 | Health / keep-alive check, always replies with the plain text pong |
| GET | /ready |
ReadyServlet |
v2.2.18 | Readiness check, replies with HTTP 200 if validation requests can be served and with HTTP 503 if not (yet) |
| GET | /status |
StatusServlet |
v2.0.0 | Application status as a JSON structure (see below) |
| POST | /api/validate/{vesid} |
ApiPostValidate |
v2.0.0 | Validate a payload against a specific VESID |
| GET | /api/get/vesids |
ApiGetAllVESIDs |
v2.0.0 | List all registered VESIDs |
| GET | /api/get/version |
ApiGetVersion |
v2.2.18 | Get the major and minor version of Phorm |
| POST | /api/determinedoctype |
ApiPostDetermineDocDetails |
v2.0.0 | Auto-detect the document format of a payload |
| POST | /api/dd_and_validate |
ApiPostDetermineDocTypeAndValidate |
v2.0.0 | Detect the document type and validate in one call |
| POST | /api/hybrid_validate |
ApiPostHybridValidate |
v2.1.0 | Validate a ZUGFeRD / Factur-X hybrid PDF invoice |
| GET | /api/admin/repositories |
ApiGetAdminRepositories |
v3.0.0 | Get the external repositories and the VES loaded from them (admin API, only if phorm.api.admin.token is set) |
| POST | /api/admin/repositories/reload |
ApiPostAdminReloadRepositories |
v3.0.0 | Reload the external repositories without a restart (admin API, only if phorm.api.admin.token is set) |
The service offers the following REST APIs below /api.
- POST
/api/validate/{vesid}(since v2.0.0)- Validate the provided payload in the body against the validation rules, identified by
{vesid} - Requires the HTTP header
X-Tokento have the configured value (see below forphorm.api.requiredtoken) - If the HTTP Request Header
Acceptwith valueapplication/xmlis present, the result is an XML structure. If the HTTP Request HeaderAcceptwith valuetext/htmlis present, the result is an HTML file. If the HTTP Request HeaderAcceptwith valueapplication/pdfis present, the result is a PDF file (since v3.0.0). Else the result is a JSON structure. - Test invocation (replace
XXXwith real token):curl -X POST -H "Content-Type: application/xml" -H "X-Token: XXX" -d @src/test/resources/testfiles/peppol-bis3/base-example.xml http://localhost:8080/api/validate/eu.peppol.bis3:invoice:latest
- Validate the provided payload in the body against the validation rules, identified by
- GET
/api/get/vesids(since v2.0.0)- Get a list of all registered VESIDs
- The optional URL parameter
include-deprecatedcan be used to also return registered, but deprecated VES IDs. No parameter value is needed - VES loaded from an external repository (see External repositories below) carry the additional field
repositorywith the repository ID - The result is a JSON structure
curl -X GET http://localhost:8080/api/get/vesids
- GET
/api/get/version(since v2.2.18)- Get the major and minor version of Phorm, e.g. to check whether a feature is available
- The micro version and the build timestamp are deliberately not disclosed
- Requires no
X-Token - The result is a JSON structure with the numeric fields
majorandminorcurl -X GET http://localhost:8080/api/get/version
- Use
Accept: text/plainto get justmajor.minor, e.g.2.2curl -X GET -H "Accept: text/plain" http://localhost:8080/api/get/version
- Example output:
{
"major":2,
"minor":2,
"invocationDateTime":"2026-11-28T09:15:00.123Z",
"invocationDurationMillis":0
}- POST
/api/determinedoctype(since v2.0.0)- Try to detect the format and payload specifics of a document instance.
- The document instance must be the POST payload.
- Requires the HTTP header
X-Tokento have the configured value (see below forphorm.api.requiredtoken) - The result is a JSON structure
- Test invocation (replace
XXXwith real token):curl -X POST -H "Content-Type: application/xml" -H "X-Token: XXX" -d @src/test/resources/testfiles/peppol-bis3/base-example.xml http://localhost:8080/api/determinedoctype
- Example output:
{
"syntaxID":"ubl2-invoice",
"syntaxVersion":"2.1",
"sender":"iso6523-actorid-upis::0088:9482348239847239874",
"receiver":"iso6523-actorid-upis::0002:FR23342",
"doctype":"busdox-docid-qns::urn:oasis:names:specification:ubl:schema:xsd:Invoice-2::Invoice##urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0::2.1",
"process":"cenbii-procid-ubl::urn:fdc:peppol.eu:2017:poacc:billing:01:1.0",
"customizationID":"urn:cen.eu:en16931:2017#compliant#urn:fdc:peppol.eu:2017:poacc:billing:3.0",
"bdid":"Snippet1",
"senderName":"SupplierTradingName Ltd.",
"senderCountryCode":"GB",
"receiverName":"BuyerTradingName AS",
"receiverCountryCode":"SE",
"vesid":"eu.peppol.bis3:invoice:latest-active",
"profileName":"Peppol BIS Billing UBL Invoice V3"
}- POST
/api/dd_and_validate(since v2.0.0)- Determine the document type and afterwards validate the provided payload in the body against the determined validation rules If the payload is wrapped in an SBDH or XHE, the payload document is automatically unwrapped. If the payload is wrapped in a Peppol SBDH, its envelope constraints are automatically validated and returned as an additional first (envelope) validation layer in the result (since 2.1.5). Additionally, if the SBDH is valid and the payload is a Peppol BIS Billing / PINT document, the SBDH sender and receiver participant IDs are cross-checked against the payload sender and receiver IDs (they must match according to the Peppol BIS Billing rules).
- Requires the HTTP header
X-Tokento have the configured value (see below forphorm.api.requiredtoken) - If the HTTP Request Header
Acceptwith valueapplication/xmlis present, the result is an XML structure. If the HTTP Request HeaderAcceptwith valuetext/htmlis present, the result is an HTML file. If the HTTP Request HeaderAcceptwith valueapplication/pdfis present, the result is a PDF file (since v3.0.0). Else the result is a JSON structure. - Test invocation (replace
XXXwith real token):curl -X POST -H "Content-Type: application/xml" -H "X-Token: XXX" -d @src/test/resources/testfiles/peppol-bis3/base-example.xml http://localhost:8080/api/dd_and_validate/curl -X POST -H "Content-Type: application/xml" -H "Accept: application/pdf" -H "X-Token: XXX" --data-binary @src/test/resources/testfiles/peppol-bis3/base-example.xml -o result.pdf http://localhost:8080/api/dd_and_validate/
- POST
/api/hybrid_validate(since v2.1.0)- Validate a ZUGFeRD / Factur-X hybrid PDF invoice. The PDF must be the POST body.
A body that does not start with the PDF header
%PDFis rejected with HTTP 400. The carrier-side rules (BR-HYBRID-* business rules and PDF/A-3 conformance via veraPDF) are evaluated by kaltblut, then the embedded XML is extracted, its document type auto-determined (as in/api/dd_and_validate), and its XML business rules applied. All layers are returned in a single phiveValidationResultList, with the PDF carrier layers first. If the embedded XML cannot be extracted, parsed or assigned to a VESID, an error layer with artifact typehybrid-embedded-xmlis added instead, so the overall result is never valid without the XML validation. The same layer reports the errorPHORM-HYBRID-01, if the specification identifier (BT-24) of the embedded XML does not match the profile declared in the XMPConformanceLevel(checked for the ZUGFeRD 2.x / Factur-X profiles MINIMUM, BASIC WL, BASIC, EN 16931 and EXTENDED). - Requires the HTTP header
X-Tokento have the configured value (see below forphorm.api.requiredtoken) - Optional URL query parameter
country=DE|FR|OTHERdrives the country-specific BR-HYBRID rules (BR-HYBRID-DE-, BR-HYBRID-FR-, BR-FX-DE-03 PDF/A downgrade). If it is not provided, the country is auto-detected from the seller and buyer countries of the embedded XML. The country-specific rules are then only applied if seller and buyer are in the same country (DE or FR); otherwiseOTHERis used. - Response format follows the same
Acceptheader convention as/api/dd_and_validate(JSON by default, XML onapplication/xml, HTML ontext/html, PDF onapplication/pdf) - Test invocation (replace
XXXwith real token):curl -X POST -H "Content-Type: application/pdf" -H "X-Token: XXX" --data-binary @invoice.pdf "http://localhost:8080/api/hybrid_validate?country=DE"
- Validate a ZUGFeRD / Factur-X hybrid PDF invoice. The PDF must be the POST body.
A body that does not start with the PDF header
The admin APIs are only available if phorm.api.admin.token is configured. They require the HTTP header X-Token to have the value of phorm.api.admin.token (not of phorm.api.requiredtoken).
- GET
/api/admin/repositories(since v3.0.0)- Get the configured repository configuration file, the date and time of the last successful load, all external repositories with the number of VES loaded from each, and all VESIDs loaded from them
- The result is a JSON structure
curl -X GET -H "X-Token: XXX" http://localhost:8080/api/admin/repositories
- POST
/api/admin/repositories/reload(since v3.0.0)- Reload all external repositories from the file configured in
phorm.repositories.file, with the same rules as on startup (see External repositories), including the resolution of required VES against the built-in VES. Nothing is changed if any error occurs - the previously loaded VES stay active, but/readyreplies with HTTP 503 until a reload succeeds - On success the JSON result contains
"success":true, the VESIDs that wereaddedandremoved, and the same information as/api/admin/repositories - On failure HTTP 500 is returned, with
"success":falseand all problems inerrorscurl -X POST -H "X-Token: XXX" http://localhost:8080/api/admin/repositories/reload
- Reload all external repositories from the file configured in
- GET
/(RootServlet) (since v2.0.0)- Returns an HTML page.
- When the application runs as a "test version" (see
webapp.testversion), the page additionally lists all supported APIs and all registered VESIDs. - The optional URL parameter
include-deprecatedalso lists deprecated VESIDs. No parameter value is needed. - Test invocation:
curl http://localhost:8080/
- GET
/ping(PingPongServlet) (since v2.0.0)- Health check / keep-alive endpoint.
- Always returns the plain text (
text/plain) bodypong. Caching is disabled. - Test invocation:
curl http://localhost:8080/ping
- GET
/ready(ReadyServlet) (since v2.2.18)- Readiness check, e.g. for a Kubernetes
readinessProbeor the Docker health check. - Replies with HTTP 200 and
{"ready":true}if all VES, including those of the external repositories, are loaded and validation requests can be served. - Replies with HTTP 503 and
{"ready":false}if not (yet). After the startup, all VES are loaded in the background, so/readyreplies with HTTP 503 until that is finished. A validation request arriving earlier waits for the built-in VES; a VES of an external repository is only known after the external repositories were loaded. - If the external repositories can't be loaded,
/readystays at HTTP 503 (see External repositories). /api/admin/repositories/reloadsets the readiness to its result: HTTP 200 after a successful reload, HTTP 503 after a failed one.- The result is a JSON structure (
application/json, UTF-8). Caching is disabled and noX-Tokenis required. - No reason is disclosed - use
/statusfor diagnostics./pingstays the liveness check and does not depend on the VES. - Test invocation:
curl -i http://localhost:8080/ready
- Readiness check, e.g. for a Kubernetes
- GET
/status(StatusServlet) (since v2.0.0)- Returns application status as a JSON structure. Caching is disabled.
- Only delivers data if
phorm.statusapi.enabledistrue; otherwise it returns{"status.enabled":false}. - Test invocation:
curl http://localhost:8080/status
- Example output:
{
"build.timestamp":"...",
"startup.datetime":"2026-07-23T08:00:00Z",
"status.datetime":"2026-07-23T09:15:00Z",
"version.pp":"2.2.0",
"version.java":"21",
"global.debug":false,
"global.production":true
}Calling the REST API from Java needs no hand written HTTP client. The separate project phorm-client provides one:
<dependency>
<groupId>com.helger</groupId>
<artifactId>phorm-client</artifactId>
<version>x.y.z</version>
</dependency>try (final PhormClient aClient = PhormClient.builder ()
.baseURL ("http://localhost:8080")
.token ("phorm-dev-token")
.build ())
{
final PhormValidationResult aResult = aClient.determineAndValidate (aXmlBytes);
System.out.println (aResult.getDocumentDetails ().getProfileName ());
System.out.println (aResult.isSuccess ());
}- Requires Java 17 or newer
- Covers all five REST APIs listed above, in the JSON, XML and HTML representation, and the three validation APIs also as PDF (since phorm-client 1.1.0)
- Returns the regular phive
ValidationResultListand dddDocumentDetailsobject models, and keeps the unparsed HTTP response reachable for everything the typed model does not cover - A content wise invalid document is a regular result and not an error, so the findings of an HTTP 400 answer
(see
phorm.api.response.onfailure.http400below) are not lost. Only a problem that prevented the validation from happening at all - a transport failure, a rejectedX-Token, a payload that is not XML, an unresolvable VESID - raises an exception, and it tells a faulty request, an unavailable service and an unusable answer apart - The payload may be passed as
byte []or asIHasInputStream; the latter is streamed to Phorm, so a large document is never held in memory as a whole
See the phorm-client README for the full API coverage and all configuration options.
Phorm comes with one configuration file called application.properties.
The lookup rules for the file is defined in https://github.com/phax/ph-commons/wiki/ph-config
It supports the following settings:
global.debug: overall debug mode. This enables additional checks that should not be executed every time (e.g. because they are slow or because they are spamming the logfile etc.). This flag has no impact on the logging level. This flag should be set totruein development mode, but tofalsein production mode. The value of this field is internally maintained in classcom.helger.commons.debug.GlobalDebug.global.production: overall production mode. If this flag is set tofalsecertain functionality not applicable in development environment (like mass mail sending) is disabled. This flag should be set totruein production mode.webapp.datapath: the path where all relevant data and settings are stored. This can e.g. be a relative path (likeconf- relative to the web application directory) for development purposes but should be an absolute path (e.g./config/phorm) in production. Make sure the user running Phorm has write access to this folder.webapp.checkfileaccess: a flag that determines whether the directory of the web application should be checked for read and write access. This is only required if the data path inside the web application and should therefore always befalse.webapp.testversion: a special indicator for the web application whether the version should be highlighted as a "test" version. Set totruein debug mode andfalsein production mode.phorm.statusapi.enabled: a flag that indicates, if the status API (/status) should deliver data or not.phorm.api.requiredtoken: the specific value of theX-Tokenheader that must be provided to access the API. Customize this once and don't share it. The development default isphorm-dev-token.phorm.api.response.onfailure.http400: a flag to indicate, whether the API should return HTTP 400 (Bad Request) on failed validations or not. The default istruefor backwards compatibility reasons.phorm.api.response.log.payload: a flag to indicate, whether the validation response should be logged in the console or not. The default isfalse.phorm.telemetry.enabled: a flag that enables in-process OpenTelemetry SDK initialisation at startup so spans and metrics are exported. The default isfalse— when disabled, every telemetry call inside Phorm collapses to a cheap no-op and no OTel network connection is opened. Set totrueto opt in.
In addition to the built-in rules from phive-rules, Phorm can load validation executor sets (VES) from local ph-diver repositories, e.g. a checkout of phive-central or a repository with company specific rules.
The repositories are described in an XML file, referenced by phorm.repositories.file, using the ph-diver repository configuration format (namespace URI urn:fdc:com:helger:diver:repoconfig:v1.0):
<repositories xmlns="urn:fdc:com:helger:diver:repoconfig:v1.0">
<repository id="custom-rules" type="localfs" toptoc="diver-xml">
<property name="basedir">/phorm/repositories/custom-rules</property>
</repository>
</repositories>- Only the repository type
localfs(local file system) is supported. A relativebasediris resolved against the directory of the XML file - Each repository must have a top-level ToC (
toptoc="diver-xml", i.e. the filetoptoc-diver.xml), because all VES of a repository are found via the top-level ToC and the ToC per artifact - A VES may require (
requires/partialRequires) other VES from the same repository and built-in VES. The repository of the requiring VES is searched first; pseudo versions such aslatestare resolved within the repository and then within the built-in VES. VES of other external repositories can't be required. A required VES that is found neither in the repository nor in the built-in VES is an error - Deployment note: an external repository with VES requiring a built-in VES needs Phorm 3.0.0 or later - older versions refuse to start or reload
- Only VES using XML Schema and/or Schematron are supported
- All VES are loaded directly after the startup in the background, after the built-in VES. Any problem is logged and Phorm does not become ready -
/readykeeps replying with HTTP 503 until a reload succeeds: an invalid XML file, a repository that can't be created, a VES that can't be loaded (including its required VES), and a VESID that is contained in more than one repository or that is already a built-in VESID - The loaded VES are used by
/api/validate/{vesid}exactly like the built-in ones. They are not considered by the document type detection of/api/determinedoctype,/api/dd_and_validateand/api/hybrid_validate - Use
/api/admin/repositories/reloadto reload the repositories without a restart - The folder example-repository contains a small example repository for testing
When phorm.telemetry.enabled=true, Phorm initialises the OpenTelemetry SDK once at startup via AutoConfiguredOpenTelemetrySdk (no Java agent required). Configure exporters and resource attributes with the standard OTel environment variables (or -D system properties) — Phorm itself adds nothing on top:
| Variable | Purpose |
|---|---|
OTEL_SERVICE_NAME |
service.name resource attribute, e.g. phorm |
OTEL_EXPORTER_OTLP_ENDPOINT |
OTLP collector endpoint, e.g. http://collector:4317 |
OTEL_EXPORTER_OTLP_PROTOCOL |
grpc (default) or http/protobuf |
OTEL_TRACES_EXPORTER / OTEL_METRICS_EXPORTER |
otlp (default), none to disable per signal, etc. |
OTEL_RESOURCE_ATTRIBUTES |
extra resource attributes, e.g. deployment.environment=prod |
See the OpenTelemetry SDK autoconfigure docs for the full list. Span names are documented in com.helger.phorm.telemetry.CPhormTelemetry (phorm.api.*, phorm.auth.check, phorm.payload.read, phorm.xml.parse, phorm.ddd.determine, phorm.vesid.resolve, phorm.phive.validate, phorm.kaltblut.*, phorm.repositories.load, phorm.repositories.load_repository); metric names are in com.helger.phorm.telemetry.PhormMetrics (phorm.requests.received, phorm.validation.runs, phorm.validation.duration, phorm.validation.findings, phorm.payload.bytes, phorm.ddd.determinations, phorm.vesid.resolutions, phorm.kaltblut.*, phorm.repositories.loads, phorm.ves.registry.size).
The gauge phorm.ves.registry.size has one value per attribute source - builtin and external - their sum is the total number of registered VES.
For a VES of an external repository, phorm.phive.validate carries the attribute phorm.vesid.repository and the metrics phorm.validation.runs and phorm.validation.duration the attribute repository, both with the repository ID - they are absent for the built-in VES.
The span phorm.repositories.load carries phorm.repositories.trigger (startup or reload, also the metric attribute trigger of phorm.repositories.loads) and phorm.repositories.errors, and has the status error if loading failed. Its child span phorm.repositories.load_repository per repository carries phorm.repository.id, phorm.repository.ves_found, phorm.repository.ves_loaded and phorm.repository.errors.
For testing purposes use e.g. those values:
OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4317"
OTEL_EXPORTER_OTLP_PROTOCOL="grpc"
OTEL_SERVICE_NAME="phorm"
OTEL_RESOURCE_ATTRIBUTES="service.namespace=com.helger,service.version=1.0.0,deployment.environment=local"
OTEL_TRACES_EXPORTER="otlp"
OTEL_METRICS_EXPORTER="otlp"
OTEL_LOGS_EXPORTER="otlp"
-
Requires Java 21 or higher
-
Build with Apache Maven 3.x - via
mvn clean install -
Alternatively build with a Docker Maven image:
build-with-docker.cmd clean install
or
./build-with-docker.sh clean install
Building:
docker build --pull --build-arg PHORM_VERSION=3.0.0 -t phelger/phorm .The Dockerfile always downloads the WAR of the given version from the GitHub releases,
never the one from a local build - so a local private-application.properties never ends up in the image.
The build argument PHORM_VERSION is required.
The old image tag phelger/valsvc is also maintained for backwards compatibility:
docker tag phelger/phorm phelger/valsvcRunning:
docker run -d --name phorm -p 8080:8080 phelger/phormThe image contains a Docker HEALTHCHECK based on /ready, so the container is reported as healthy as soon as
validation requests can be served (docker inspect -f '{{.State.Health.Status}}' phorm).
Kubernetes ignores the Docker health check - use /ping for the livenessProbe and /ready for the readinessProbe there.
To use external repositories, mount the XML file and the repositories into the container and point phorm.repositories.file to the file, e.g. via a system property.
Setting CATALINA_OPTS replaces the value from the Dockerfile, so its options must be repeated:
docker run -d --name phorm -p 8080:8080 \
-v /local/repositories:/phorm/repositories:ro \
-e CATALINA_OPTS="-Djava.security.egd=file:/dev/urandom -Dphorm.repositories.file=/phorm/repositories/repositories.xml" \
phelger/phormExample curl command (use the correct "X-Token" and the right address):
curl -d "@base-example.xml" -H "Content-Type: application/xml" -H "X-Token: XXX" -X POST http://localhost:8080/api/validate/eu.peppol.bis3:invoice:latest
Pre-built Docker images are available on Docker Hub:
phelger/phorm— for linux/amd64phelger/phorm-arm64— for linux/arm64
Both images are tagged with the specific version (e.g. 2.0.0) as well as latest.
The multi-architecture build script is located in docker/build-all.sh.
If an update is made to the validation, you have to do a git pull and recompile.
To make sure your own configuration is kept unchanged, my suggestion is to create a file private-application.properties
in the src/main/resources folder of your checked-out copy (same folder as application.properties),
where you can adjust or change all the configuration entries that are important to you.
The file with this specific name and within this folder has a higher priority than the default
application.properties file and is also marked as "ignored" in git, i.e. changes to this file
are not overwritten during updates from the repository.
If the file is in the correct folder, it will also be included in the compilation process and
is therefore available out of the box for Phorm.
As an alternative to using private-application.properties you may also consider using
environment variables or Java system properties for the configuration -
see https://github.com/phax/ph-commons/wiki/ph-config for details.
v3.0.1 - work in progress
- The
Dockerfilenow always downloads the WAR from the GitHub release (build argumentPHORM_VERSION, required) instead of using the localtarget/*.war, so that a localprivate-application.propertiesis never part of the image
v3.0.0 - 2026-11-29
- New major version, because of these breaking changes:
- Java 21 is the baseline
/api/hybrid_validatewithout the query parametercountryauto-detects the country instead of usingOTHER- With external repositories configured,
/readyreplies with HTTP 200 only after they were loaded
- Security: the Docker image disables the HotSpot Base64 intrinsic (
-XX:-UseBASE64Intrinsics) as mitigation for CVE-2026-114938 ("Java2Shell"). - Updated to ph-diver 4.5.0
- Updated to kaltblut 1.0.0
- Added support for external local validation repositories, described in an XML file referenced by the new configuration property
phorm.repositories.file. See the new section External repositories - Added the admin APIs
GET /api/admin/repositoriesandPOST /api/admin/repositories/reload, enabled by the new configuration propertyphorm.api.admin.token /api/validate/{vesid},/api/dd_and_validateand/api/hybrid_validatenow create a PDF validation report with the request headerAccept: application/pdf, based on phive-result-pdf/api/get/vesidsreturns the new fieldrepositoryfor VES loaded from an external repository/api/hybrid_validateauto-detects the country from the embedded XML, if the query parametercountryis not provided. PreviouslyOTHERwas used- A VES of an external repository may require a built-in VES. See issue #24
- The external repositories are loaded in the background after the built-in VES.
/readyreplies with HTTP 200 only after both were loaded; an error with the external repositories keeps/readyat HTTP 503 instead of aborting the startup POST /api/admin/repositories/reloadsets the readiness to its result - a failed reload makes/readyreply with HTTP 503, even though the previously loaded VES stay active- Added telemetry for the external repositories: the span
phorm.repositories.loadhas the new attributesphorm.repositories.trigger(startuporreload) andphorm.repositories.errors, and the status error if loading failed; each repository gets a child spanphorm.repositories.load_repository; the metricphorm.repositories.loadshas the new attributetrigger - The gauge
phorm.ves.registry.sizereports the built-in and the external VES separately, with the new attributesource(builtinorexternal) - the sum is the previous total - Updated to ph-telemetry 1.1.3
- The span
phorm.phive.validatehas the new attributephorm.vesid.repository, and the metricsphorm.validation.runsandphorm.validation.durationthe new attributerepository, both only for VES of an external repository
v2.2.18 - 2026-11-29
- Updated to phive-rules 4.7.4
- Updated to phive 12.4.0
- Added the API
GET /api/get/versionto get the major and minor version as JSON or, withAccept: text/plain, as plain text (#25) - Added the readiness API
GET /ready, replying with HTTP 200 if validation requests can be served and with HTTP 503 if not (#26) - All VES are now loaded in the background directly after the startup, instead of on the first use
- Added a
HEALTHCHECKbased on/readyto the Docker image
v2.2.17 - 2026-11-24
- Updated to phive-rules 4.7.3
- Updated to phive 12.3.1 (using Saxon DOM)
v2.2.16 - 2026-11-23
- Updated to phive-rules 4.7.2
v2.2.15 - 2026-11-17
- Updated to phive-rules 4.7.1
v2.2.14 - 2026-11-15
- Updated to phive-rules 4.7.0
v2.2.13 - 2026-11-09
- Fixed the
Dockerfile, where a typo inCATALINA_OPTSprevented the Tomcat option-Djava.security.egd=file:/dev/urandomfrom being applied /api/hybrid_validatenow rejects a request body that is not a PDF document with HTTP 400/api/hybrid_validateno longer reports success if the embedded XML could not be validated (e.g. if its document type could not be determined). Fixes issue #22 - thx @yaworu/api/hybrid_validatenow checks that the specification identifier (BT-24) of the embedded XML matches the profile of the XMP metadata
v2.2.12 - 2026-10-30
- Security: the Docker image now blocks the 16 compromised eMudhra intermediate CA certificates.
The private keys of 8 eMudhra intermediate CAs were compromised, and each of them is also cross-signed by Sectigo's AAA Certificate Services, which is still trusted by the JDK.
The Java runtime does not check revocation by default, so outbound HTTPS connections relying on the JDK trust store could accept forged certificates.
The
Dockerfilenow appends the SHA-256 hashes of all 16 certificates to the JDKblocked.certsfile. The step is skipped if the base image already contains the entries. Existing deployments must pull the new image, or add the hashes to theblocked.certsfile of their own JDK. See phoss-ap #115 - Updated to ph-schematron 10.3.0
- Updated to phive-rules 4.6.4
- Updated to ddd 0.9.3
v2.2.11 - 2026-09-30
- Updated to phive-rules 4.6.3
- Added the section "Java client library" referencing the new phorm-client project
v2.2.10 - 2026-09-28
- Updated to phive-rules 4.6.2
v2.2.9 - 2026-09-25
- Updated to phive-rules 4.6.1
- Updated to phive-rules-legacy 4.6.1
- The OpenTelemetry SDK is no longer registered via
setResultAsGlobal (), but built first and registered in a separate, guarded step.setResultAsGlobal ()registers from insidebuild ()and throws if a globalOpenTelemetryinstance is already present - realistically when Phorm runs with the OpenTelemetry Java agent whilephorm.telemetry.enabledis stilltrue. That aborted the startup with an opaqueIllegalStateException: GlobalOpenTelemetry.set has already been calledand leaked the SDK that had just been built, because the exception leaves no handle to close it and Phorm disables the OpenTelemetry shutdown hook (it manages shutdown itself). Now such an instance is kept, the surplus SDK is shut down, and a warning namesphorm.telemetry.enabled=falseas the fix. The Phorm metrics then register against the already present instance, so running with the agent works instead of failing.
v2.2.8 - 2026-09-23
- Updated to phive-rules 4.6.0
- Updated to phive-rules-legacy 4.6.0
v2.2.7 - 2026-09-06
- Updated to phive-rules 4.5.6
- Added the section "Phorm in the Peppol flow" with a diagram showing the three points where Phorm is used in a Peppol exchange
v2.2.6 - 2026-08-23
- Updated to phive-rules 4.5.4
v2.2.5 - 2026-08-09
- Updated to phive-rules 4.5.3
v2.2.4 - 2026-08-06
- Updated to phive-rules 4.5.2
v2.2.3 - 2026-08-05
- Disabled the audit logging, as Phorm is a stateless validation service and does not need it.
No more
auditsfolder is created below the configuredwebapp.datapath - Updated to phive-rules 4.5.1
v2.2.2 - 2026-08-03
- Updated to phive-rules 4.5.0
v2.2.1 - 2026-07-30
- Updated to phive-rules 4.4.2
- Fixes issue #17 - thx @ic-officient
v2.2.0 - 2026-07-19
- Updated to phive 12.1.0
- Updated to phive-rules 4.4.0
- Updated to ph-schematron 10.0.0
- Updated to kaltblut 0.9.4
- Switched to the aggregating
phive-rules-allmodule, so all available rule sets are registered automatically
v2.1.6 - 2026-07-09
- Updated to phive-rules 4.3.9
- Include existing phive-rules submodule
phive-rules-isdoc,phive-rules-osaandphive-rules-serbia
v2.1.5 - 2026-07-02
- Added validation of Peppol SBDH envelope constraints in
/api/dd_and_validate, returned as an additional first validation layer. See #14 - thx @dmaus2018 - Added a Peppol BIS Billing check in
/api/dd_and_validatethat the SBDH sender/receiver participant IDs match the payload sender/receiver IDs. See #14 - thx @PontusPaulsson
v2.1.4 - 2026-07-01
- Added OpenTelemetry support
v2.1.3 - 2026-06-15
- Updated to phive-rules 4.3.8
v2.1.2 - 2026-05-29
- Updated to phive-rules 4.3.5
- Updated to ddd 0.8.8
v2.1.1 - 2026-05-21
- Updated to phive-rules 4.3.3
v2.1.0 - 2026-05-14
- Updated to phive-rules 4.3.2 (including new rules for Hungarian invoice format)
- Updated to ddd 0.8.7
- Added new API
/api/hybrid_validatefor ZUGFeRD / Factur-X hybrid PDF invoices. The PDF carrier (BR-HYBRID-* + PDF/A-3 via veraPDF) is validated by kaltblut and the embedded invoice XML is auto-detected and validated against the matching VESID; both layers are returned in a singleValidationResultList. An optional?country=DE|FR|OTHERquery parameter drives the country-specific BR-HYBRID rules.
v2.0.4 - 2026-05-09
- Updated to phive-rules 4.3.1 (including new rules for Turkish invoice format)
- Updated to ddd 0.8.6
v2.0.3 - 2026-04-10
- Updated to phive 12.0.3
- Updated to ddd 0.8.5
- Added support for automatic unwrapping of SBDH/XHE envelopes in
/dd_and_validate. See #11
v2.0.2 - 2026-04-02
- Updated to phive 12.0.2 and phive-rules 4.3.0
v2.0.1 - 2026-03-25
- Updated to phive-rules 4.2.5
v2.0.0 - 2026-03-18
- Made the repository public - thanks for all the supporters!!!
- Starting to use semantic versioning
2026-03-17
- Updated to phive 12.0.1 and phive-rules 4.2.3
2026-03-12
- Rebranding: the project has been renamed from "Validation Service" / "valsvc" to Phorm
- The Maven artifact ID changed from
validation-servicetophorm, so the WAR file is nowphorm.warinstead ofvalidation-service.war - The Java package was renamed from
com.helger.valsvctocom.helger.phorm - The Docker image is now
phelger/phorm(the old tagphelger/valsvcis still provided for backwards compatibility) - Configuration property keys were renamed from
valsvc.*tophorm.*(e.g.valsvc.api.requiredtoken→phorm.api.requiredtoken). The oldvalsvc.*keys are still accepted as fallback values. - The log prefix changed from
[VAL-SVC]to[PHORM] - The default Docker data path changed from
/config/valsvcto/config/phorm
2026-02-22
- Updated to phive 12.0.0 and phive-rules 4.2.0
- Both
/api/validate/and/api/dd_and_validateare now able to create HTML results (first draft)
2026-02-18
- Updated to phive-rules 4.1.8
2025-09-02
- The API
/api/determinedoctypecan now also return XML payload - Fixed an error with the document type ID scheme for PINT document types in determination
2025-08-29
- The minimum requirement is now Java 17
2025-03-23
- Added new API
/api/dd_and_validateto run document type detection and validation in one call - Changed the default value of
phorm.api.response.log.payload(formerlyvalsvc.api.response.log.payload) tofalse
2025-03-10
- Added the new phive-rules-zatca for Saudi Arabian invoice
2025-03-08
- Added all other remaining validation rules from phive-rules
2025-03-04
- Added Danish OIOUBL rules to the ruleset
2025-01-09
- The API
/api/validate/{vesid}can return JSON or XML (depending on theAcceptheader)
2024-12-06
- Added new API
/api/determinedoctypeto auto detect payload details
2024-12-05
- the new configuration property
phorm.api.response.log.payload(formerlyvalsvc.api.response.log.payload) can be used to disable logging of the result JSON - Added support for German ZuGFERD XML invoices
2024-12-03
- the new configuration property
phorm.api.response.onfailure.http400(formerlyvalsvc.api.response.onfailure.http400) can be used to disable returning HTTP 400 on validation failure
2024-09-17
- updated to phive v10 and ph-diver v3
2024-05-23
- added UBL.BE rules as well
2024-01-10
- added XRechnung rules as well
My personal Coding Styleguide | It is appreciated if you star the GitHub project if you like it.
