Class WsdlExpectationGenerator

java.lang.Object
org.mockserver.mock.wsdl.WsdlExpectationGenerator

public class WsdlExpectationGenerator extends Object
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: POST to the path of the soap:address/soap12:address location, matched by:
    • SOAP 1.1 — the SOAPAction header (tolerating optional surrounding quotes), when soap:operation/@soapAction is present;
    • SOAP 1.2 — the content-type action parameter, 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).
  • response: 200 with 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 Details

    • WsdlExpectationGenerator

      public WsdlExpectationGenerator()
  • Method Details

    • generate

      public List<Expectation> generate(String wsdl)
      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