Loading…
Loading…
Explains how the WSDL parser analyzes WSDL and XSD documents to extract operations, schemas, backend settings, and handle external references.
The WSDL Parser is a component responsible for parsing and analyzing Web Services Definition Language (WSDL) 1.1 documents. It is a foundational part of the API onboarding process for SOAP-based services.
The parser's primary function is to ingest a WSDL file, either as a single XML document or as a set of interconnected documents via wsdl:import and xsd:import/include, and extract a structured representation of the SOAP service. This includes:
wsdl:portType/wsdl:operation elements.wsdl:service and wsdl:binding definitions.The parser is designed to be robust, with built-in support for repairing common WSDL syntax issues, securely fetching external dependencies, and providing detailed diagnostics to the API publisher. It produces a WsdlParsedDocument object that serves as the input for configuring a SOAP-to-REST API.
The parsing process involves several stages, from initial XML processing to the final extraction of service metadata. The parser can be invoked to perform a full parse or to preview specific aspects like namespace repairs or external references.
flowchart TD
A[API Publisher provides WSDL] --> B(WSDL Parser);
subgraph WSDL Parser
B --> C{Analyze & Repair XML};
C --> D{Discover External Files?};
D -- Yes --> E[Fetch External WSDL/XSD];
D -- No --> F;
E --> F[Merge All Documents];
F --> G[Extract Operations & Schemas];
F --> H[Extract Backend Configuration];
end
subgraph Secure Fetch
style E fill:#f9f,stroke:#333,stroke-width:2px
E -- "HTTP/HTTPS GET" --> I(SSRF Egress Guard);
I -- "Validate URL" --> J(Backend SOAP Service);
end
G --> K(Operation & Schema Definitions);
H --> L(Backend Endpoint & Auth Suggestions);
subgraph "Parser Output"
K
L
endBefore parsing, the WSDL input undergoes several normalization steps:
U+FEFF), often present in files from Windows-based systems, is removed to prevent XML parsing errors.WsdlNamespaceRepairSupport. This fixes many validation errors in non-compliant WSDLs.DocumentBuilderFactory that disables DTDs and external entity resolution to prevent XXE (XML External Entity) attacks.WSDLs often split definitions across multiple files using wsdl:import, xsd:import, xsd:include, and xsd:redefine. The parser recursively discovers and fetches these external documents.
location attributes on import/include elements.http or https URL, a secure fetch is initiated.
OperatorUrlGuard, which enforces egress policies to prevent Server-Side Request Forgery (SSRF) attacks.<wsdl:types> element, creating a single, complete definition for subsequent processing.With a complete WSDL DOM, the parser uses XPath and direct DOM traversal to extract service details.
Backend Suggestions (readBackendSuggestion):
wsdl:service/wsdl:port/soap:address to find candidate endpoint URLs.wsdl:binding elements to determine the SOAP version (1.1 or 1.2), transport protocol (e.g., http://schemas.xmlsoap.org/soap/http), and binding style (document or rpc).inferBackendAuthHint) by scanning for WS-Policy keywords like UsernameToken, PasswordDigest, and X509Token.Operations (parse):
<wsdl:portType>/<wsdl:operation>.soapAction, binding style, headers, and faults. This resolution is keyed by (portTypeName, operationName) to correctly handle WSDLs with multiple port types that share operation names.bindingStyle (document vs. rpc) is determined before schema generation, as it affects how the request and response payloads are structured.WsdlContractBuilder is used to generate JSON Schema representations for the operation's request and response messages.The final result is a WsdlParsedDocument containing a list of WsdlOperationRecord objects and a WsdlBackendSuggestionRecord.
The WsdlParser exposes several public methods for parsing and analyzing WSDL documents.
| Method | Description |
|---|---|
parse(String wsdlXml) | Parses the given WSDL XML string. Assumes no external references need to be resolved from a relative path. |
parse(String wsdlXml, String sourceLocation) | Parses the WSDL XML string. The sourceLocation is used as the base URL for resolving relative paths in wsdl:import and xsd:import/include statements. |
previewNamespaceRepair(String wsdlXml) | Analyzes the WSDL for missing common namespace declarations and returns a preview of the automatic repairs that would be applied. |
previewNamespaceRepair(String wsdlXml, Map<String, String> manualMappings) | Same as above, but allows providing a map of custom prefix-to-namespace mappings to apply during the repair. |
previewExternalReferences(String wsdlXml, String sourceLocation) | Scans the WSDL for all external references (wsdl:import, xsd:import, etc.), attempts to resolve them, and returns a diagnostic report of which references were found, resolved, or failed to load. |
The parser methods return structured records that encapsulate the analysis results.
WsdlParsedDocumentThe primary output of the parse method.
| Field | Type | Description |
|---|---|---|
targetNamespace | String | The targetNamespace attribute from the root wsdl:definitions element. |
backendSuggestion | WsdlBackendSuggestionRecord | A collection of suggested backend settings, including endpoint URL, SOAP version, and authentication hints. |
operations | List<WsdlOperationRecord> | A list of all SOAP operations discovered in the WSDL's portType definitions. |
WsdlOperationRecordRepresents a single SOAP operation.
| Field | Type | Description |
|---|---|---|
operationName | String | The name of the operation from the name attribute. |
inputMessage | String | The qualified name of the wsdl:message for the operation's input. |
outputMessage | String | The qualified name of the wsdl:message for the operation's output. |
soapAction | String | The SOAPAction HTTP header value associated with the operation. |
requestSchema | Map<String, Object> | A JSON Schema representation of the operation's request body. |
responseSchema | Map<String, Object> | A JSON Schema representation of the operation's response body. |
faults | List<WsdlOperationFaultRecord> | A list of declared SOAP faults for the operation. |
headers | List<WsdlOperationHeaderRecord> | A list of SOAP headers declared for the operation's input or output. |
headerFaults | List<WsdlOperationHeaderRecord> | A list of SOAP header faults declared for the operation. |
bindingStyle | String | The SOAP binding style (document or rpc). This influences how the request/response payloads are structured. |
NamespaceRepairPreviewReturned by previewNamespaceRepair to show the results of automatic namespace correction.
| Field | Type | Description |
|---|---|---|
originalXml | String | The original WSDL XML provided as input. |
repairedXml | String | The WSDL XML after applying automatic namespace repairs. |
repairedPrefixes | List<String> | A list of namespace prefixes that were automatically added or corrected. |
unrepairedPrefixes | List<String> | A list of prefixes that could not be automatically repaired. |
manuallyAppliedPrefixes | List<String> | A list of prefixes that were applied from the manualMappings input. |
notes | List<String> | Human-readable notes summarizing the repair actions taken. |
ExternalReferencePreviewReturned by previewExternalReferences to provide a detailed report on external WSDL/XSD dependencies.
| Field | Type | Description