Loading…
Loading…
Explains how the platform persists and manages WSDL artifacts, operations, and their linkage to service versions. Covers creation, retrieval, and
The WSDL Import Repository is a data access component responsible for the persistence and management of WSDL artifacts within the platform's database. When an API publisher imports a WSDL file or provides a URL, this repository handles the creation, retrieval, and updating of records that represent the WSDL and its parsed contents.
Its primary function is to store structured data extracted from WSDL files, including:
This component sits between high-level API management services and the database, providing a durable, queryable store for all imported WSDLs. All database operations are automatically scoped to the active tenant, ensuring strict data isolation in a multi-customer environment.
The repository manages WSDL data primarily across two database tables: s2r_wsdl_artifact for the top-level artifact metadata and s2r_wsdl_operation_catalog for the individual SOAP operations within each artifact.
flowchart TD
A[API Publisher] -- "Imports WSDL (upload or URL)" --> B[API Platform];
B -- "1. Parses WSDL" --> C{WSDL Metadata & Operations};
B -- "2. Persists via Repository" --> D{Persistence Layer};
subgraph "Stored Artifact"
D -- creates --> E[WSDL Artifact Record];
D -- creates --> F[WSDL Operation Records];
end
E -- "has many" --> F;When a new WSDL is imported, the create method orchestrates the persistence process:
artifact_id).sourceName (e.g., a filename or URL) is normalized. If it exceeds 300 characters, it is truncated and appended with a short SHA-256 hash of the original string to maintain uniqueness while respecting database column limits.s2r_wsdl_artifact table. This record includes metadata like source_type, the normalized source_name, checksum_sha256, target_namespace, and the user who imported it. The raw wsdl_xml is also stored if provided.source_type is url, the source_url column is populated with the normalized source name. This URL is used by maintenance processes to re-fetch the WSDL if needed.WsdlOperationRecord objects provided. For each operation:
s2r_wsdl_operation_catalog table, linked to the parent artifact_id.request_schema, response_schema, operation_faults, and operation_headers, are serialized into their respective JSONB database columns.headers) and header faults (headerFaults) are combined into a single list before being serialized into the operation_headers column. A kind field within each header object distinguishes its type.WsdlImportResult object, containing the details of the newly created artifact and its operations, is returned to the caller.To prevent database errors from overly long source names (like complex URLs), the normalizeSourceName function truncates any name longer than MAX_SOURCE_NAME_LENGTH (300 characters).
The format for a truncated name is:
[first N characters]...#[12-char-sha256-hash]
For example, a 400-character URL would be transformed into a 300-character string, with the end portion replaced by an ellipsis and a short hash of the original URL.
// Example of the normalization logic
String originalName = "https://example.com/very/long/path/that/exceeds/the/limit/" + "a".repeat(300);
String normalized = normalizeSourceName(originalName);
// `normalized` will be a 300-character string ending in "...#" followed by a 12-character hash.
The repository provides several methods for retrieving and maintaining WSDL artifacts:
findById and findWsdlXmlById retrieve a full artifact or just its raw XML content, respectively.findLatestComparable and findLatestComparableNewer are used to find previously imported artifacts that are similar to a new one, based on matching source_name or target_namespace. This helps identify potential duplicates or updates.findRehydrationCandidates method identifies service versions linked to artifacts that are missing their raw wsdl_xml content (a state common for artifacts imported before this feature was added). A separate "rehydrate" service uses this list to re-fetch the WSDLs from their original source_url.findUnlinkedServiceVersions method finds service versions that are not linked to any WSDL artifact (wsdl_artifact_id is NULL). A "backfill" service uses this information to find a matching WSDL and create the association using linkArtifactToServiceVersion.IMPORTANT
All database queries executed by this repository are scoped to the current tenant's data. This is enforced by appending a tenant-scoping SQL clause (TENANT_SCOPE_SQL) to every WHERE clause, ensuring that one tenant can never access another tenant's WSDL artifacts.
To ensure backward compatibility with older platform installations, several methods dynamically check for the existence of specific database columns before executing a query. For instance, findRehydrationCandidates and findUnlinkedServiceVersions first call columnExists to verify that s2r_service_version.wsdl_artifact_id is present. If the column does not exist, the methods return an empty list, preventing SQL errors on legacy schemas.
The WsdlImportRepository exposes the following public methods for managing WSDL artifacts.
createPersists a new WSDL artifact and its associated operations to the database. Two overloads exist; the primary one accepts the full WSDL XML.
| Name | Type | Required | Description |
|---|---|---|---|
sourceType | String | Yes | The origin of the WSDL, e.g., url or upload. |
sourceName | String | Yes | The source identifier, such as a URL or filename. Will be normalized if over 300 characters. |
checksumSha256 | String | Yes | The SHA-256 checksum of the WSDL file content. |
targetNamespace | String | Yes | The targetNamespace defined within the WSDL. |
backendSuggestion | WsdlBackendSuggestionRecord | No | A record suggesting a backend endpoint, inferred from wsdl:service elements. Serialized to the inferred_backend JSONB column. |
operations | List<WsdlOperationRecord> | Yes | A list of all parsed SOAP operations from the WSDL. |
wsdlXml | String | No | The complete, raw XML content of the WSDL file. If null, the artifact may be a candidate for rehydration later. |
importedBy | String | Yes | An identifier for the user or system principal performing the import. |
A WsdlImportResult object containing the full details of the newly persisted artifact.
| Method | Description |
|---|---|
findById(UUID artifactId) | Retrieves a complete WsdlImportResult (artifact and operations) by its unique ID. Returns Optional.empty() if not found. |
findWsdlXmlById(UUID artifactId) | Fetches only the raw WSDL XML string for a given artifact ID. Returns Optional.empty() if the artifact is not found or if the XML was not stored (e.g., for artifacts imported before database migration V82). |
findOperationsByArtifactId(UUID artifactId) | Retrieves the list of WsdlOperationRecord objects associated with an artifact ID. |
findLatestComparable(...) | Finds the most recently imported artifact (excluding the one with the given artifactId) that has a matching source_name or target_namespace. |
findLatestComparableNewer(...) | Similar to findLatestComparable, but only considers artifacts imported after the specified importedAfter timestamp. |
findRehydrationCandidates() | Returns a list of RehydrationCandidate records for service versions whose linked WSDL artifacts are missing the raw wsdl_xml content. |
findUnlinkedServiceVersions() | Returns a list of UnlinkedServiceVersionCandidate records for service versions that are not linked to any WSDL artifact. |
createArtifactFromFetchedWsdl(...) | Creates a new s2r_wsdl_artifact record from a WSDL fetched by a maintenance process. Returns the new artifact's UUID. |
linkArtifactToServiceVersion(UUID serviceVersionId, UUID artifactId) | Updates a s2r_service_version row to set its wsdl_artifact_id. Returns the number of rows affected (0 or 1). |
updateWsdlXmlAndSourceUrl(UUID artifactId, String wsdlXml, String sourceUrl) | Populates the wsdl_xml and source_url on an existing artifact record. Used by the rehydration process. |
The repository uses several record types to model WSDL data.
WsdlImportResultRepresents a fully persisted WSDL artifact, including its operations.
| Field | Type | Description |
|---|---|---|
artifactId | UUID | The unique identifier of the artifact. |
sourceType | String | The source type, e.g., url. |
sourceName | String | The normalized source name. |
targetNamespace | String | The WSDL's target namespace. |
checksumSha256 | String | The SHA-256 checksum of the artifact content. |
importedAt | OffsetDateTime | The timestamp when the artifact was imported. |
backendSuggestion | WsdlBackendSuggestionRecord | The inferred backend endpoint details. |
operations | List<WsdlOperationRecord> | The list of SOAP operations contained in the WSDL. |
WsdlOperationRecordRepresents a single parsed SOAP operation from a WSDL.
| Field | Type | Description |
|---|---|---|
operationName | String | The name of the wsdl:operation. |
inputMessage | String | The name of the input wsdl:message. |
outputMessage | String | The name of the output wsdl:message. |
soapAction | String | The soapAction URI for the operation. |
requestSchema | Map<String, Object> | A JSON-schema representation of the request body. |
responseSchema | Map<String, Object> | A JSON-schema representation of the response body. |
faults | List<WsdlOperationFaultRecord> | A list of wsdl:fault definitions for the operation. |
headers | List<WsdlOperationHeaderRecord> | A list of soap:header definitions for the operation's input. |
headerFaults | List<WsdlOperationHeaderRecord> | A list of soap:headerfault definitions for the operation. |
bindingStyle | String | The resolved soap:binding style (rpc or document). If not specified in the WSDL or for older artifacts, this defaults to document. |
RehydrationCandidateContains the necessary information for a maintenance process to re-fetch a missing WSDL.
| Field | Type | Description |
|---|---|---|
artifactId | UUID | The ID of the artifact needing rehydration. |
serviceId | UUID | The ID of the associated service. |
serviceVersionId | UUID | The ID of the associated service version. |
serviceKey | String | The unique key of the service. |
environment | String | The environment of the service. |
sourceType | String | The original source type of the artifact. |
sourceName | String | The original source name of the artifact. |
sourceUrl | String | The URL from which the WSDL was originally fetched, if available. |
backendEndpointUrl | String | The backend endpoint URL of the service, used as a fallback for lookup. |
UnlinkedServiceVersionCandidateContains information for a maintenance process to find and link a WSDL to a service version.
| Field | Type | Description |
|---|---|---|
serviceId | UUID | The ID of the service. |
serviceVersionId | UUID | The ID of the unlinked service version. |
serviceKey | String | The unique key of the service. |
environment | String | The environment of the service. |
status | String | The status of the service version. |
isActive | boolean | Whether the service version is active. |
backendEndpointUrl | String | The backend endpoint URL of the service, used to find a matching WSDL. |
The following SQL is used by the findById method to retrieve the main artifact record. Note the TENANT clause, which ensures multi-tenant data isolation.
select id, source_type, source_name, checksum_sha256, target_namespace, inferred_backend::text as inferred_backend, imported_at
from s2r_wsdl_artifact
where id = ?
and tenant_id = current_setting('s2r.tenant')::uuid
create) will throw an IllegalStateException if an object cannot be converted to a JSON string. This is a fatal error for the import operation.mapOperationRow) are designed to be resilient. If a JSONB column contains malformed or unparsable data, the method will return an empty List or Map instead of throwing an exception. This prevents read operations from failing but may hide underlying data corruption issues.findWsdlXmlById for an artifact imported before database migration V82 will return an empty Optional, as the raw XML was not stored at that time. This is expected behavior.linkArtifactToServiceVersion method may return 0 if the target service version is deleted by another process between the time it was selected for backfill and the time the UPDATE statement is executed.