Mock Services
A mock service simulates a real backend service. It contains one or more reactions.
A service has a unique pair of HTTP and HTTPS ports for addressing it in client applications.
All services available within an environment are listed on the environment Services
page.
![](https://mockmotor.com/images/Services.png)
Service Properties
Each service has a few configurable properties:
![](https://mockmotor.com/images/ServiceProperties.png)
Name: a human-readable name
Description: an optional more lengthy explanation of the purpose of the mock
CORS: when set to Auto
and there are CORS headers in the request, MockMotor generates the response CORS headers automatically.
Creating a New Mock Service
Creating a New Empty Mock Service
To create a new empty mock service, click on Add Service
on the Services page:
![](https://mockmotor.com/images/AddEmptyService1.png)
Populate the service name and optionally description.
You don't have to fill in the port numbers. MockMotor selects the next available pair on saving.
![](https://mockmotor.com/images/AddEmptyService2.png)
Click Save
.
![](https://mockmotor.com/images/AddEmptyService3.png)
MockMotor assigned a pair of ports to the new service and opened them.
The newly created empty service won’t have any reactions defined yet. You’ll have to add them manually.
Creating a New Mock Service from WSDL
You can create a new SOAP mock service in an environment by importing its WSDL.
Click on Import from WSDL
on the Services page:
![](https://mockmotor.com/images/AddSOAPService1.png)
Select WSDL from the disk and click Import
:
The current version of MockMotor doesn't support the loading of WSDL from the network. Please download WSDL to your local disk before importing it.
![](https://mockmotor.com/images/AddSOAPService2.png)
A new mock service is created, and its properties are pre-populated.
Update these properties if required and click Save
:
![](https://mockmotor.com/images/AddSOAPService3.png)
MockMotor creates a single reaction for each operation from the provided WSDL. These reactions are configured to return a SOAP Fault. The generation of schema-valid responses is planned for future releases.
![](https://mockmotor.com/images/AddSOAPService4.png)
You should update the payload, response status and the delay for the operations you need to mock.
![](https://mockmotor.com/images/AddSOAPService5.png)
Creating a New Mock Service from OpenAPI (aka Swagger)
You can create a new REST mock service by importing an OpenAPI file.
Click on “Import from OpenAPI” on the Services page:
![](https://mockmotor.com/images/AddSwaggerService1.png)
Select an OpenAPI file from the disk and click Import
:
![](https://mockmotor.com/images/AddSwaggerService2.png)
MockMotor creates a new REST mock service:
![](https://mockmotor.com/images/AddSwaggerService3.png)
Every operation in OpenAPI is recorded as a reaction, with a dummy response payload and HTTP status 500. The generation of JSON schema-valid responses is planned for future versions.
![](https://mockmotor.com/images/AddSwaggerService4.png)
You have to provide the payload, HTTP status and the delay for responses you need to mock:
![](https://mockmotor.com/images/AddSwaggerService5.png)
Cloning Mock Service to Another Environment
A service can be cloned to another environment.
Click on the Clone to Environment
button on the Service page.
![](https://mockmotor.com/images/CloneService1.png)
Select the target environment and click Clone
:
![](https://mockmotor.com/images/CloneService2.png)
The new cloned service gets the new set of ports:
![](https://mockmotor.com/images/CloneService3.png)
MockMotor also tries to clone all the account properties that are used in the service reactions.
Transferring Mock Service to Another Instance
When you need to transfer a service that works well in on MockMotor instance to another (for example, SFT to PTE), you can export it as a ZIP file from one instance and then import it to another.
Exporting Mock Service to ZIP
To export a service, click the Export as ZIP
button on the Service page.
Save the ZIP file from the download dialog.
![](https://mockmotor.com/images/ExportService1.png)
Importing Mock Service from ZIP
The previously exported service can be imported into another MockMotor installation.
To import a service, go to the Service page and click Import from ZIP
:
![](https://mockmotor.com/images/ImportService1.png)
Select the previously exported file and click Import
:
![](https://mockmotor.com/images/ImportService2.png)
The service is imported, and you’ll be redirected to the new Service page where you can modify its properties.
![](https://mockmotor.com/images/ImportService3.png)
Note that MockMotor assigns a new pair of port numbers to the service.