Loading…
Loading…
Describes how the platform identifies SOAP services by parsing the namespace and local name of the first element in the SOAP Body or the root of a bare
The SoapBodyIdentity component extracts a unique service identifier from the body of an XML-based request. This identifier consists of the XML namespace and local name of the operation being invoked.
This mechanism is critical for routing requests to the correct backend service in scenarios where the request URL alone is insufficient for attribution. This is a common pattern for document/literal-wrapped SOAP web services, where multiple distinct operations are exposed on a single endpoint URL.
The component is designed to run on the high-throughput request ingest path. It takes a raw request body payload as input and, if successful, outputs a SoapBodyIdentity object containing the parsed namespace and local name. This identity is then used by other components, such as the SoapServiceAttributionResolver, to complete service routing.
The SoapBodyIdentity component provides a static parse(String payload) method that implements the entire extraction logic. The process is designed for both security and performance, as it handles untrusted traffic from API consumers.
The core logic identifies the primary operation element within an XML payload.
<Body> tag.The following diagram illustrates the parsing flow:
flowchart TD
subgraph "Input"
A[Request Payload String]
end
subgraph "Processing Logic"
B{Payload null or blank?}
C{Contains '<' character?}
D[Truncate to 256 KB]
E[Parse as XML with security hardening]
F{Parse successful?}
G[Get root element]
H{Is root a SOAP Envelope?}
I[Find first element child of <Body>]
J[Use root element as identity]
K[Combine I and J]
L{Identity element found?}
M[Extract namespace and local name]
N{Local name exists?}
end
subgraph "Output"
O[Return SoapBodyIdentity object]
P[Return null]
end
A --> B
B -- Yes --> P
B -- No --> C
C -- No --> P
C -- Yes --> D
D --> E
E --> F
F -- No --> P
F -- Yes --> G
G --> H
H -- Yes --> I
H -- No --> J
I --> K
J --> K
K --> L
L -- No --> P
L -- Yes --> M
M --> N
N -- No --> P
N -- Yes --> OThe process follows these steps:
Initial Validation: The parse method first checks if the input payload is null or blank. If so, it immediately returns null.
Quick Reject: It performs a cheap check for the presence of a < character. If none is found, it assumes the payload is not XML (e.g., JSON) and returns null to avoid the cost of spinning up an XML parser.
Payload Truncation: To optimize performance, the parser only considers the beginning of the payload, where the identity element is expected to be. The payload is truncated to a maximum size of 256 KB (MAX_PARSE_CHARS).
Secure XML Parsing: The truncated string is parsed into an XML Document object. The parser is explicitly hardened to prevent XML-based attacks.
IMPORTANT
The XML parser is configured to be namespace-aware and to refuse processing of DTDs, external entities, and XInclude directives. This is a security measure to prevent XML External Entity (XXE) injection attacks from untrusted request payloads.
Locate Identity Element:
Envelope. It recognizes SOAP 1.1 (http://schemas.xmlsoap.org/soap/envelope/) and SOAP 1.2 (http://www.w3.org/2003/05/soap-envelope) namespaces, as well as namespace-unaware Envelope elements.Envelope is found, the component searches for the first element child inside the <Body> tag.Envelope, the root element itself is treated as the identity element.Extract Identity: If an identity element is successfully located, its namespace URI and local name are extracted.
Return Result: A SoapBodyIdentity object containing the namespace and localName is returned. If any step fails (e.g., parsing error, missing <Body>, missing operation element), the method returns null.
NOTE
The XML parser uses a silent error handler. If a payload is not well-formed XML, the parse method will return null without logging a fatal error. This is intentional, as the component is expected to process a high volume of non-XML traffic on the ingest path.
Given the following SOAP request payload:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:user="http://example.com/users">
<soapenv:Header/>
<soapenv:Body>
<user:GetUserDetails>
<user:UserId>12345</user:UserId>
</user:GetUserDetails>
</soapenv:Body>
</soapenv:Envelope>
The parse method will identify the <soapenv:Body> element's first child, <user:GetUserDetails>, as the identity element. It will return a SoapBodyIdentity object with the following values:
http://example.com/usersGetUserDetailsFor a request where the payload is a non-SOAP XML document:
<CheckInventory xmlns="http://example.com/products">
<Sku>ABC-9987</Sku>
</CheckInventory>
The parse method will use the root element, <CheckInventory>, as the identity element. It will return a SoapBodyIdentity object with the following values:
http://example.com/productsCheckInventorySoapBodyIdentity.parse(String payload)This static method attempts to parse a service identity from a given string payload.
payload (String): The raw request body payload.SoapBodyIdentity object on successful parsing.null if the payload is empty, not valid XML, or does not contain a usable identity element.SoapBodyIdentity RecordThis record is the data structure returned upon successful parsing.
| Field | Type | Description |
|---|---|---|
namespace | String | The XML namespace URI of the identity element. May be an empty string if no namespace is present. |
localName | String | The local name of the identity element (the tag name without any namespace prefix). |
The component uses an internal constant to limit the amount of data it parses. This value is not configurable at runtime.
| Name | Type | Value | Description |
|---|---|---|---|
MAX_PARSE_CHARS | int | 262144 | The maximum number of characters (256 * 1024) from the start of the payload that will be used for parsing. |
The parse method will return null, indicating that a service identity could not be determined, under the following conditions:
payload is null or consists only of whitespace.< character, suggesting it is not an XML document.<Body> element.<Body> element in a SOAP envelope contains no child elements (e.g., it is empty or contains only comments or text nodes).SoapServiceAttributionResolver: A component that uses SoapBodyIdentity to attribute requests to services.SoapPayloadExtractor: A related component that also performs hardened XML parsing on gateway traffic.