Loading…
Loading…
Explains how to generate new API services and replacement drafts from imported WSDL artifacts, including automatic configuration and validation.
The WsdlGenerationRepository is a data-access component responsible for translating an imported WSDL artifact into a functional API service configuration within the platform. It automates the creation of services, operations, and REST-to-SOAP mappings, effectively bootstrapping a REST-ful facade for a SOAP-based web service.
This component serves two primary purposes:
It is an internal component typically invoked by higher-level administrative services when an API publisher initiates service creation or updates from a WSDL file. Its inputs are the UUID of a WSDL artifact and service metadata; its outputs are new records in the platform's database and a summary result object.
The repository provides transactional methods for creating and updating service configurations based on WSDL content.
When a new service is generated from a WSDL artifact, the platform executes the following sequence of operations, orchestrated by the generateServiceFromArtifactInternal method.
flowchart TD
subgraph "API Publisher"
A[Provides WSDL Artifact ID <br/> and Service Details]
end
subgraph "Platform"
B(WsdlGenerationRepository)
C{Service Key Available?}
D[Create `s2r_service` and `s2r_service_version` records]
E[For each WSDL Operation...]
F[Infer REST Route and Method]
G[Create `s2r_operation` Record]
H{Backend Suggestion in WSDL?}
I[Create Default `s2r_backend_profile`]
J[Return `GeneratedServiceResult`]
end
A --> B
B --> C
C -- Yes --> D
C -- No --> K((Fail with Error))
D --> E
E --> F
F --> G
G --> E
E -- All Operations Processed --> H
H -- Yes --> I
I --> J
H -- No --> Jdirection parameter is validated to ensure it is one of PUBLISH, CONSUME, or GATEWAY.WsdlContractRoundTripValidator) on the WSDL operations. This process verifies that example values provided in the WSDL schema conform to their own type constraints. Any validation failures are collected as warnings and included in the final result, but they do not stop the service generation process.serviceKey is already in use within the specified environment. If it is, the process fails. The system also accounts for a legacy mode where service keys must be unique across all environments.s2r_service table with a status of draft. The direction determines whether the service is for publishing a backend (WSDL describes the backend) or consuming a service (WSDL describes the surface exposed to clients).s2r_service_version, linking the service to the source wsdl_artifact_id.operationKey is generated from the SOAP operation name.WsdlRestRouteHeuristics. The system ensures generated routes are unique within the service.s2r_operation table. This record stores the operationKey, SOAP operation name, REST route, and JSON schemas for the request and response. It also copies the binding_style and a combined list of SOAP headers and headerFaults from the WSDL artifact into the operation_headers column.OperationMappingRepository.WsdlBackendSuggestionRecord (a hint about the SOAP service's location), a default s2r_backend_profile is created. This profile is configured with auth_type='none' and mtls_enabled=false; the API publisher must configure credentials separately.GeneratedServiceResult object containing the UUIDs of the created service and version, along with any contract validation warnings.When creating a replacement draft for an existing service, the generateReplacementDraftFromLatestComparable method is used. This allows for an in-place upgrade of a service's contract.
sourceName and targetNamespace. If no newer comparable artifact is found, the process fails.WsdlReplacementDraftPlanner is invoked to create a ReplacementPlan. This plan compares the operations from the existing service version with those in the new WSDL artifact. It categorizes each operation as preserved, new, or removed, and preserves configuration (e.g., timeouts, retries, enabled status) for existing operations.s2r_service_version record is created with an incremented version_no and a status of draft. It is linked to the new WSDL artifact ID.PlannedOperationShapes from the replacement plan and inserts corresponding records into the s2r_operation table for the new draft version.WsdlReplacementDraftResult object, which summarizes the changes, including counts of preserved, new, and removed operations.The component exposes several public Java methods for managing WSDL-based service generation.
generateServiceFromArtifactCreates a new service from a WSDL artifact with a specified service key.
| Parameter | Type | Description |
|---|---|---|
artifactId | UUID | The unique identifier of the imported WSDL artifact. |
serviceKey | String | The desired service key, which must be unique within the environment. |
serviceName | String | The human-readable name for the new service. |
environment | String | The target environment for the new service. |
direction | String | The service direction. Must be PUBLISH, CONSUME, or GATEWAY. Defaults to PUBLISH if omitted or blank. |
actor | String | The identifier of the user or system performing the action. Defaults to system if null or blank. |
Returns: GeneratedServiceResult
generateServiceFromArtifactAutoCreates a new service from a WSDL artifact, automatically generating a unique service key. The key is derived from baseServiceKey by appending a numerical suffix (e.g., -2, -3) if the base key is already taken.
| Parameter | Type | Description |
|---|---|---|
artifactId | UUID | The unique identifier of the imported WSDL artifact. |
baseServiceKey | String | The preferred base for the service key. The final key will be derived from this to ensure uniqueness. |
serviceName | String | The human-readable name for the new service. |
environment | String | The target environment for the new service. |
direction | String | The service direction. Must be PUBLISH, CONSUME, or GATEWAY. Defaults to PUBLISH if omitted or blank. |
actor | String | The identifier of the user or system performing the action. Defaults to system if null or blank. |
Returns: GeneratedServiceResult
generateReplacementDraftFromLatestComparableCreates a new draft version for an existing service, based on the latest available comparable WSDL artifact.
| Parameter | Type | Description |
|---|---|---|
serviceId | UUID | The unique identifier of the service to update. |
sourceVersionId | UUID | The unique identifier of the service version to use as the base for the replacement. |
actor | String | The identifier of the user or system performing the action. Defaults to system if null or blank. |
Returns: WsdlReplacementDraftResult
findWsdlArtifactIdForVersionA utility method to retrieve the WSDL artifact ID associated with a specific service version.
| Parameter | Type | Description |
|---|---|---|
serviceId | UUID | The unique identifier of the service. |
versionId | UUID | The unique identifier of the service version. |
Returns: List<UUID>. Returns an empty list if the service version does not exist or if the wsdl_artifact_id column is not present in the database schema. Returns a list containing a single null element if the version exists but is not linked to a WSDL artifact.
GeneratedServiceResultThe result of creating a new service.
| Field | Type | Description |
|---|---|---|
serviceId | UUID | The ID of the newly created service. |
versionId | UUID | The ID of the newly created service version (version 1). |
serviceKey | String | The final, resolved service key. |
serviceName | String | The name of the service. |
environment | String | The environment of the service. |
backendProfileId | UUID | The ID of the auto-configured backend profile, or null if none was created. |
endpointUrl | String | The endpoint URL of the auto-configured backend, or null. |
backendAutoConfigured | boolean | true if a backend profile was automatically configured. |
generated | List<GeneratedOperationRecord> | A list of the operations created for the service. |
contractWarnings | Map<String, Object> | A map containing details of any contract validation warnings, or null if there were no warnings. |
WsdlReplacementDraftResultThe result of creating a replacement draft.
| Field | Type | Description |
|---|---|---|
serviceId | UUID | The ID of the service for which the draft was created. |
newVersionId | UUID | The ID of the new draft service version. |
nextVersionNo | int | The version number of the new draft. |
sourceVersionId | UUID | The ID of the version this draft is based on. |
sourceArtifactId | UUID | The ID of the WSDL artifact used by the source version. |
latestArtifactId | UUID | The ID of the new WSDL artifact used to create the draft. |
generatedOperationCount | int | The total number of operations in the new draft. |
preservedOperationCount | int | The number of operations carried over from the source version. |
newOperationCount | int | The number of new operations added in the draft. |
removedOperationCount | int | The number of operations from the source version that are not in the draft. |
backendProfileId | UUID | The ID of the auto-configured backend profile, or null. |
endpointUrl | String | The endpoint URL of the auto-configured backend, or null. |
backendAutoConfigured | boolean | true if a backend profile was auto-configured. |
contractWarnings | Map<String, Object> | A map containing details of any contract validation warnings, or null. |
The generation process uses system-wide settings for default operation timeouts and retries. These can be configured via the SystemSettingRepository.
| Name | Type | Default | Description |
|---|---|---|---|
default_timeout_ms | Integer | 1000 | The default operation timeout in milliseconds. Values must be between 1 and 60000. |
default_retry_count | Integer | 2 | The default number of retries for an operation. Values must be between 0 and 10. |
NOTE
If the configured values are outside the valid ranges, the system will use the hardcoded fallback defaults listed in the table.
The following SQL statement illustrates the data persisted into the s2r_operation table for each new operation generated from a WSDL. This demonstrates how WSDL metadata is mapped to the platform's operation model.
insert into s2r_operation (
id, service_version_id, operation_key, soap_operation_name, rest_method, rest_path,
soap_action, request_schema, response_schema, fault_schema, binding_style, operation_headers,
enabled, timeout_ms, retry_count, debug_enabled,
created_at, updated_at, created_by, updated_by
)
values (?, ?, ?, ?, ?, ?, ?, ?::jsonb, ?::jsonb, '{}'::jsonb, ?, ?::jsonb, true, ?, ?, false, ?, ?, ?, ?)
Field Mapping:
soap_operation_name: The name attribute from the WSDL operation.rest_method, rest_path: Inferred by WsdlRestRouteHeuristics.request_schema, response_schema: The JSON Schema representation of the WSDL message parts.binding_style: The style from the WSDL binding (e.g., document, rpc).operation_headers: A JSONB array containing the union of soap:header and soap:headerfault definitions applicable to the operation.timeout_ms, retry_count: Set to the system defaults during initial generation.API publishers may encounter the following errors during service generation.
| Error Condition | Trigger |
|---|---|
IllegalArgumentException: "Service key '...' already exists..." | Attempting to create a service with a serviceKey that is already in use in the target environment. The generateServiceFromArtifactAuto method avoids this error. |
IllegalArgumentException: "...already exists in another environment while the database still enforces global service-key uniqueness." | Occurs on systems with a legacy global uniqueness constraint on serviceKey when the key exists in any environment. |
IllegalArgumentException: "direction must be PUBLISH, CONSUME or GATEWAY..." | The direction parameter was an invalid value. |
IllegalArgumentException: "No operations found for artifact..." | The source WSDL artifact ID is valid, but it contains no parsable operations. |
IllegalArgumentException: "no newer comparable WSDL import is available..." | When generating a replacement draft, no WSDL artifact with the same sourceName and targetNamespace and a newer import date could be found. |
IllegalStateException: "draft version already exists" | Attempting to create a replacement draft for a service that already has a version with status = 'draft'. |
WsdlContractValidationException (as a warning) | The WsdlContractRoundTripValidator found that an example value in the WSDL's schema violates its own constraints (e.g., an example string for a field typed as an integer). This is reported as a non-blocking warning in the result payload and logged with code S2R-ADM-0612. The service or draft is still created successfully. |
WsdlImportRepositoryOperationMappingRepositorySystemSettingRepositoryWsdlReplacementDraftPlannerWsdlContractRoundTripValidatorWsdlRestRouteHeuristics