I am working with a client right now to build Android and iOS applications we hope to have posted to Google Play and the Apple Store before the end of the summer. Like many mobile applications these mobile apps are going to be dependent on some communications with the organization’s HTTP/HTTPS servers for some information and services – in our case the exchange will be via JSON. Unfortunately, the mobile application development is underway while the backend services are not yet available.
This is a pretty common occurrence I see in today’s mobile app development industry. I call it the “meet in the middle” approach. Mobile apps are built to get much of their data/services across “the network” but without actually having the backend in place at the start of development. Backend applications are being built simultaneously to eventually provide the required services and data – sometimes unaware of exactly how that data is going to be requested or used.
If you are a mobile developer – or anyone developing some type of “client” application – that is going to be consumers of Web service calls, you may want to check out some of the service mocks or virtualization capability now available.
Service Mocks Defined
What do I mean by a service mock? These are phony, stand-in services that take the place of the real services. They allow the mobile applications to make real HTTP calls (to a real URL) and get back data that simulates the actual service response. Extremely helpful during the construction and testing of your application.
Remarkably – at least to my surprise – there are several tools and vendor platforms that support the quick and easy development of service mocks. They can provide a variety of data formats (JSON, XML, CSV, plain text, etc.) and can even include some limited intelligence to provide slightly different responses based on headers, parameters, etc..
In this post, I hope to shed some light on some of these service mock products and also give you some things you may want to think about before you go shopping for a potential solution. I may not be able to give you everything you need, but at least give you food for thought, some places to start looking for what you need, and save you some valuable time on the Google search page.
What to look for
Unfortunately, this may be the toughest part of your task. What do people (vendors, tool and service providers, developers in need of help, …) call this stuff? Service Mock is my term, and it is used by some providers/users, but it isn’t the only way you will see this type of need labeled. Look for “service mocking”, “service virtualization”, “service API documentation and testing”, “simulated mobile backend” and even something called “MBaaS simulation.” In that last one, MBaaS stands for mobile backend as a service – the latest of the “as a service” qualifiers. If you find a product that looks like something close to what you need or you would like to know if there are other products like it, search for “competitors of…” that product. That is how I came up with some of the products you see listed below.
As you explore your options, you may be surprised at the number of solutions to help provide service mocks. Some key questions you need to ask yourself (and your development team) before you pick a tool or service to meet your need:
- How much do you want to pay? There are several open source or beta products that are free while other, typically more sophisticated tools and services are going to cost some money. Usually not-break-the-development-budget-expensive, but certainly > $0.
- Do you want to host the tool/service on your own platforms and within your walls or do you prefer to find a hosted service that requires no hardware/software on your end to setup? Can you run your mock “in the cloud?” Do you want the option to run locally on hardware/software we procure and/or also the option to run in the cloud?
- What types of data do you need to communicate in the mock? Again, our project just needed to have the service mock provide JSON. Solutions vary in offering JSON, XML, HTML, plain text, and other MIME types.
- All the tools/services I explored offered HTTP solutions, but do you need to communicate via HTTPS or other protocol (SMTP, FTP, etc.)?
- Do you need to provide for a certain degree of security – even in your mocking? Again HTTPS, OAuth, or other security protocol exchanges usually require more infrastructure and/or setup.
- How much sophistication/intelligence does the mock have to have? Can it just respond with a static JSON response, for example? Or does it need to be able to at least do some intelligent work in looking at some piece of request data and make a response selection?
Typically, the key here is your service mock should be quick and easy! That is quick to setup and operate while easy to pay for. Spending too much to get something up and running that is just a stand-in for the actual service would usually be a waste of time and money.
In our case, we need something that was cheap (as in free), required no hardware/software on our end, generally unsophisticated in its responses, and responded with HTTP (although HTTPS would have been nice). Happily, there were many options to meet our need readily available in the cloud.
Service Mock – Hosted/Cloud Providers
If you are looking for a cloud provider that can help you setup, host and operate your service mock, you have a few options. Here are the ones I found with a few pro/con bullet points I collected for each:
- Free for 1 user
- Uses API Blueprint for service definition (a common description language for describing services – essentially an API language).
- REST only (no SOAP)
- Provides a traffic inspector to get some analytics about the calls to service
- No OAuth/HTTPS/etc.
- GitHub integration
- Little more complex to setup/operate than some of the other solutions
- Currently free while it is in its “preview” mode.
- Provides REST and SOAP style request/responses
- Easy to provide your own service responses (just cut and paste the response) with your selection of response status, content type, encoding, etc.
- Also allows import of API documentation (RAML, Apigee, Swagger, Mashable, WSDL) to establish the service
- OAuth2 capable
- No HTTPS
- Also provides easy to uses client tool for testing services
- Extremely easy to use Web UI – simply pick your content type (XML, JSON, HTML, …) and cut and paste your service response.
- Allows for various status code responses.
- No static addresses/URLs – you get a dynamically generated GUID like address (not sure how long it stays around).
- Only one service at each address
- Free while it is in its Beta mode.
- Does require sign up – even for the beta.
- REST only
- Easy to use Web UI for service mock setup/administration
- Provides a real-response capture/reuse capability
- Can manual write/provide the responses or use API specs to define service mock
- Powerful – yet easy to use and setup. Providing sophistication where you need it.
- Allow for delay in response
- Simulate error state
- Allow URL path parameters
- Free for 5000 requests/month. $29 gets you 25,000 requests a month and $99/month gets you 100,000 requests a month.
- Simulate error responses
- Console to get request / response analytics
- JSON, XML, plain text responses
- Free during its beta program
- Easy to use Web-based UI – simply cut and paste the response
- Response status code selection
- JSon only (name says it all)
- Need to use jsonstub headers (user key, project id, etc.) when making the request. They provide jQuery, Ember, Angular and Curl examples for how to do that for each service.
Other Options For Service Mocking
If a wholly hosted mock service does not meet your needs, you will find several products from VMWare, CA, HP, Crosscheck, Cloudpoint and others to build/host your own solutions. Of course, these products (and the hardware they run on) are usually not free.
There are also a ton of REST mocking frameworks and APIs that allow you to build/host your own service mocks as well. They include PowerMock, jquery-mockjax, REST Mock (from SmartBear). These can provide as sophisticated as you need (and are willing to build) service mocking. Some are open source while others have fees or licenses requirements.
Finally, you can always roll your own. For example, a simple Java servlet running on a Tomcat server exposed via URL to your devices may be all you need.
If you have other products and services you have found useful in providing simulated/mock back end services for your mobile development, leave us a comment and tell us about your experiences. If your team needs help building its mobile application, give us a call. Intertech would love the opportunity to partner with you on your next mobile endeavor or help you with issues you are having on your current efforts.