SOAP and WSDL
Zyvra mocks and calls SOAP services as well as REST ones. Everything runs on your computer.
Import a WSDL
Choose Import WSDL on the Mock Services page (or in the API Client’s Import menu), or run zyvra import wsdl <file or URL>. Zyvra reads WSDL 1.1 and 2.0 documents (SOAP 1.1 and 1.2, from a paste, a file or a URL, with the schemas they import). It lists the operations with a sample request, response and fault for each, and makes:
- a mock service with an endpoint for each operation, one that answers any other operation with a SOAP fault, a Success scenario and a scenario for every fault the WSDL declares;
- an API Client collection with a ready request for each operation.
A mock service, a collection and a request are each REST or SOAP, never both, and each has an icon that says which. When the WSDL changes, import it again with Update an existing SOAP service (or collection): new operations are added, and what you wrote is kept.
Write the answers
A scenario holds only the body: Zyvra writes the envelope around it, in the SOAP version the caller used. A fault is written as its code, reason and detail. Rules choose between an operation’s scenarios by what the call says, picked from the elements of a sample call instead of typed as an XPath. In a body, {{request.bodyRaw | xpath "//sku"}} copies a value of the call into the answer.
You can also make a mock from a collection of SOAP requests (one operation per request), and Save as mock on a reply keeps it as an operation.
XPath
A path in a rule, a check, a saved value, a workflow condition or a template reads XML. //orderId finds <ns1:orderId> whatever prefix the sender used. Scripts have xml.get(text, xpath), xml.all and xml.has.
Check messages against the schema
A mock made from a WSDL keeps its schemas. Switch on Check requests against the schema (in the import, or on the service’s Settings tab) and a request that does not follow them is answered with a SOAP Client fault that says what is wrong, and shown in Traffic as refused: schema. A collection can check replies the same way, and the scenario editor warns when your own reply does not follow the schema.
WS-Security
On a SOAP request, the WS-Security auth sends a UsernameToken (text or digest, with a Timestamp), signs the Body, and encrypts it for a service’s certificate. It also decrypts an encrypted reply and checks its signature. On a mock service, the Settings tab’s Require a WS-Security token card can require a token, a signature from certificates it trusts (intermediate authorities included) and an encrypted Body, sign and encrypt its answers, and refuse a call that is sent twice. Both sides can make a test key and certificate, so you can try it in a minute. The passwords and keys of a mock are saved in zyvra.yaml as they are: use test ones.
MTOM attachments
Add files on a SOAP request’s Body tab and it is sent as an MTOM message. A reply that comes as MTOM is shown as its envelope with the attachments listed, and a mock scenario can answer with attachments. A WSDL whose policy asks for MTOM makes mocks and requests that use it.