Package org.mockserver.mock.wsdl
Class WsdlExpectationGenerator
java.lang.Object
org.mockserver.mock.wsdl.WsdlExpectationGenerator
Generates MockServer
Expectations from a WSDL 1.1 document so SOAP web services
can be mocked without hand-authoring stubs. Supports SOAP 1.1 and SOAP 1.2 bindings.
For each service/port the binding is resolved and one expectation is produced
per binding operation:
- request:
POSTto the path of thesoap:address/soap12:addresslocation, matched by:- SOAP 1.1 — the
SOAPActionheader (tolerating optional surrounding quotes), whensoap:operation/@soapActionis present; - SOAP 1.2 — the
content-typeactionparameter, when present; - otherwise — a best-effort XPath on a body element whose local-name equals the operation name (documented heuristic, used only when no SOAP action is declared).
- SOAP 1.1 — the
- response:
200with a skeleton SOAP envelope containing a<{Operation}Response/>element in the WSDL target namespace.
The WSDL is parsed with the hardened StringToXmlDocumentParser (DOCTYPE and
external entities disabled) so importing an untrusted WSDL cannot trigger XXE.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionParses the given WSDL and returns one expectation per SOAP operation.
-
Constructor Details
-
WsdlExpectationGenerator
public WsdlExpectationGenerator()
-
-
Method Details
-
generate
Parses the given WSDL and returns one expectation per SOAP operation.- Parameters:
wsdl- the WSDL 1.1 document as a string- Returns:
- the generated expectations (never empty)
- Throws:
IllegalArgumentException- if the WSDL is blank, cannot be parsed, or declares no SOAP operations
-