Skip to content

XML and SOAP contracts Since v0.2 ​

A contract is the schema your XML or SOAP service publishes. Requests on the contract's paths are refused when they name an unknown operation, use another operation's SOAPAction or the wrong SOAP version, miss or add elements, use wrong types, break value facets, or break an uploaded DTD. The checks run after the XML body limits (depth, element counts, DTD refusal) on the same body. For the limits, see Schema enforcement.

Before you begin ​

  • Role: operator for the application.
  • The contract files: a WSDL 1.1 (SOAP 1.1 and 1.2, document/literal or rpc/literal; rpc/encoded is refused), an XSD, or a DTD. Files refer to each other by file name only, and nothing is fetched from the network.
  • The waap-xmlcheck helper installed next to the waap binary on the control plane's node and on inspection nodes. It validates in a separate process, so a parser crash costs a helper restart, never the inspection service.
  • Check the files first: waap api xml check -kind wsdl -f orders.wsdl -import types.xsd.

Add a contract ​

text
1. Open Applications > All applications > the application > Request checks > API protection.
2. Open the XML contracts tab and select Add a contract.
3. Enter Name, Kind and Paths. For a WSDL, set SOAPAction and Allowed operations.
4. Choose the main file first, then the files it imports. The page shows the
   operations found, or why the files do not load.
5. Select Preview changes, add a comment and select Apply.
sh
waap api xml check -kind wsdl -f orders.wsdl -import types.xsd
waap api xml contract set -app shop -name orders-soap -kind wsdl -path /soap/orders -f orders.wsdl -import types.xsd -m "orders contract"
waap api xml contracts -app shop
yaml
# applications[].policy.api.xml
xml:
  contracts:
    - name: orders-soap
      paths: [/soap/orders]
      kind: wsdl
      file: orders.wsdl
      imports: [types.xsd]
      soap_action: check
      operations: [PlaceOrder]
      on_violation: block

A new contract follows the application's mode. Upload it in detect, watch waap events list -app shop -rule api.xml.schema (and api.soap.) for a few days, fix the contract or the client, then set the application or Contract mode to block. Set On violation to log to keep one contract logging while others block.

Files that need the helper

An apply that names files is refused when waap-xmlcheck is not installed on the control plane's node, or when it cannot load the contract. Without -f, contract set changes only the settings.

Edit or remove a contract ​

text
1. Open the XML contracts tab and select Edit on the contract's row.
2. Change paths, allowed operations, SOAPAction handling, root or On violation.
   Leave the files empty to keep the stored ones.
3. To remove it, select Remove, then preview and apply.
sh
waap api xml contract remove -app shop -name orders-soap -m "retire contract"

Requests to a removed contract's paths are no longer checked.

How a request is checked ​

Only requests with a body on a contract path are checked; GET /soap/orders?wsdl passes.

  1. The body must be XML (text/xml, application/xml, application/soap+xml, *+xml) and at most Largest document validated.
  2. A document with its own document type declaration is refused before parsing, as is one over the XML limits.
  3. For a WSDL, the envelope must be SOAP 1.1 or 1.2 with exactly one non-empty Body. Its first element names the operation. With SOAPAction set to check, a SOAPAction header (1.1) or action parameter (1.2) naming another operation is refused; an empty or absent action is accepted.
  4. The document (for a WSDL, the Body element) is validated by the helper.

Settings reference ​

Module settings ​

SettingWhat it doesDefaultAllowed valuesApplies in
Contract mode (xml.mode)Whether violations refuse or only log.empty (same as API protection)detect, block, emptydetect wins over the application's block
Validation time budget (xml.budget)Longest a document may take to validate.100ms5ms to 2sall
Largest document validated (xml.max_document)Bigger documents on a contract path are refused as too large.1MiB1 up to the request body limitall
When the helper cannot answer (xml.on_unavailable)What happens when the helper is missing, restarting or too slow.inheritinherit (the failure policy), open (log and pass), closed (refuse with 503)all

Contract ​

SettingWhat it doesDefaultAllowed valuesApplies in
Name (name)Identifies the contract in events and configuration.none (required)lowercase letters, digits, dashesall
Kind (kind)The kind of contract.none (required)wsdl, xsd, dtdall
Paths (paths)Request paths the contract covers.none (required)exact, or a prefix ending in *; a path belongs to one contractall
Main file and imports (file, imports)The contract files, stored with the version.none (required)up to 32 files, 8 MiB togetherall
Root element (root)The expected root element.none (any global element){namespace}localkind xsd only
SOAPAction (soap_action)Whether the SOAPAction must match the operation.checkcheck, ignorekind wsdl only
Allowed operations (operations)Operations clients may call.none (all)operation names from the WSDLkind wsdl only
On violation (on_violation)What a violation does.blockblock, logblock refuses only in block mode

Helper settings ​

Administrators set these under System > Helpers, with waap settings set helpers, or in the configuration (helpers.xmlcheck).

SettingWhat it doesDefaultAllowed valuesApplies in
Run waap-xmlcheck (xmlcheck.enabled)Runs the helper while an application has contracts.truetrue, falseoff: checks report the helper unavailable
Binary (xmlcheck.binary)Path of the helper on the nodes.empty (next to the waap binary)absolute pathall
Workers (xmlcheck.workers)Documents validated at once.21 to 64all
Memory (xmlcheck.memory)Memory the helper may use. A document needing more is refused as too complex.512MiB64MiB to 16GiBall
CPU time (xmlcheck.cpu_seconds)CPU time after which the helper is recycled.360060 to 604800all

Rules ​

RuleMeaning
api.xml.schemaThe document breaks the schema; also not XML, too large, own DTD, or wrong root.
api.xml.dtd_mismatchThe document breaks the uploaded DTD.
api.soap.operationThe operation is not in the contract, or not allowed.
api.soap.action_mismatchThe SOAPAction names another operation.
api.soap.envelopeNot a SOAP envelope, missing or duplicate Body, or the wrong SOAP version.
api.xml.check_unavailableThe helper could not answer.
api.xml.check_timeoutValidation took longer than the time budget.

Events carry the element path and the value, with at most five problems per document. The event page shows the SOAP operation, and the endpoint inventory names SOAP calls POST /soap/orders#PlaceOrder. All rule IDs work in exceptions by prefix (api.soap., api.xml.).

Some pattern facets are not enforced

xs:pattern facets run with Go's linear-time regular expressions. Character class subtraction ([a-z-[aeiou]]), \I, \C, negated blocks inside a class and unknown Unicode blocks cannot be translated. Such a pattern is not enforced; the upload shows a warning that names it. Rewrite the pattern to have it enforced.

Limits ​

LimitValue
Contracts per application32
Files per contract32 (one main file and 31 imports)
Size of one contract's files8 MiB together
Problems reported per document5
Helper check time (waap-xmlcheck check)10 seconds, 512 MiB

Troubleshooting ​

Apply is refused: XML contract checks need waap-xmlcheck ​

  • Cause: the helper is not installed on the control plane's node.
  • Check: waap api xml helpers, or System > Helpers.
  • Fix: install it next to the waap binary, or set Binary.

Requests on a contract path fail with api.xml.check_unavailable ​

  • Cause: the helper is not running or is restarting. It restarts with a delay that grows from 100 ms to 10 s.
  • Fix: check the helper state. Set When the helper cannot answer to open to pass requests meanwhile.

A valid request breaks api.xml.schema ​

  • Cause: the contract is older than the client, or a facet is stricter than the client.
  • Check: the event shows the element path, the value and the parser's message with its line.
  • Fix: update the contract, or use False positive for that path and rule.