This has happend to me more than once, thought someone can give some insight.

I have worked on multiple projects where my project depends on external service. When I have to run the application locally, i would need that service to be up. But sometimes I would be coding to the next version of their service which may not be ready.

So the question is, is there already a way that can have a mock service up and running that i could configure with some request and responses?

For example, lets say that I have a local application that needs to make a rest call to some other service outside to obtain some data. E.g, say, for given a user, i need to find all pending shipments which would come from other service. But I dont have access to that service.

In order to run my application, i need a working external service but I dont have access to it in my environment. Is there a better way rather than having to create a fake service?

  • What do you mean by better? A way that you don't have to write code? Creating a fake service would be the way to do it, unless you think it can be done in some way without the existence of a fake service. Commented Jun 12, 2013 at 23:45
  • @RobertHarvey, I should have clarified more. Since there could be more than 1 external service, instead of having a mock service for each, I was thinking if it would be better to have 1 mock service where i can configure it to be whatever the service needs to be by simply configuring it to have expected input and mocked output for each of them.
    – bond
    Commented Jun 13, 2013 at 1:02
  • 1
    So, a generalized service, then. I believe you are describing a mocking framework. Commented Jun 13, 2013 at 14:47

1 Answer 1


One way is to create your own service which returns sample data in the same format as the external service - this is the mock service. Mock Service

In this diagram, I have labelled the part of your application that connects to the service as the service client. Here, you just configure your application to point to your mock service while developing.

Another, possibly better, way - which I have used myself, I'll describe it here in general terms - is to have the service client implement an interface, through which the rest of your application accesses the service. Then you can just create another implementation of the interface which returns mock data:


With this system, you just change which implementation to use as needed, either through a configuration variable or build condition. Another advantage is that you can start coding the application without any reference to the soa technology used, it gives you flexibility while you wait for the service to be ready.

  • 1
    Thanks Paul your diagrams are helpful. Both are good options. What I am thinking about is your option 1. Specially when if there is more than 1 service. May be its a good idea for me to spend some time and create a open source testing framework where any service could be mocked by simply configuring the service. This could act as 1 or possibly many service at once.
    – bond
    Commented Jun 13, 2013 at 1:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.