How to create a mock service using Mocky.io

Previously in another post, i have explained you about creating a mock service using Mockable.io website.

In this post i am going to explain you about creating a mock service using Mocky.io web tool.This is far more easier and simpler than Mockable.io web tool.

First go to http://www.mocky.io/ website.The website itself is act as a tool.

You will find below interface.

mocky

You have to fill the information required under Generate your custom response section.

Let’s create a mock service for a ESB proxy that generates a SOAP/XML response.

You need to fill the information in Mocky.io interface as below.

Status code: you can specify any status code you need in the response.

for this scenario i have specified it as a 200 OK one.

Content type: content types can be mainly SOAP/XML or JSON etc…

in this scenario i needed a SOAP response, so i have specified a XML content type.

Body : In this section specify the message you need as the response.

i have specified a SOAP message.

Then click on generate my HTTP response button and it will start the mock service and the link to the service will appear before “Your link is ready:” label.

mocky2

Start ESB and create a proxy and as an address endpoint give the link in mock service.

Now, using below curl command invoke the ESB proxy service.

curl -v -H “Content-Type: application/xml”  <mock proxy url>

You will see the response in ESB logs as below.

INFO – LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:f02c9e7d-c840-49c1-a169-0704ba2f1a92, Direction: response, Envelope: <?xml version=’1.0′ encoding=’utf-8′?><soapenv:Envelope xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/”><soapenv:Body><coordinates&gt;
<location>
<name>Bermuda Triangle</name>
<n>25.0000</n>
<w>71.0000</w>
</location>
<location>
<name>Eiffel Tower</name>
<n>48.8582</n>
<e>2.2945</e>
</location>
</coordinates></soapenv:Body></soapenv:Envelope>

2 thoughts on “How to create a mock service using Mocky.io

  1. Hey Thank for the information ,I want to know if we can modify the existing mock without changinf the URL. I mean , once the URL is created ….i want to edit the Content without chnaging the URL…Please provide your taught. Thank

Leave a comment