By Carlos Chang-Oracle on Aug 11, 2014
Author:Senior Director, Fusion Middleware Market Development
One significant difference that you’ll find in mobile architectures is the preference for REST and JSON over SOAP and XML for mobile web services.We don’t have time today to go into an in-depth comparison of SOAP and REST but lets take a brief look at why REST/JSON is considered best practice in Mobile.
This diagram shows a simplified but typical mobile architecture. We have a number of backend applications and data sources connected through a service bus. In typical SOA environments these will use standards based SOAP and XML as the data exchange mechanism. This has proven to be a robust and reliable solution behind the corporate firewall and on the high speed corporate LAN.
The mobile app, running on either a tablet or a smart phone performs all of it’s reading and writing data operations across some form of wireless network, often a public cellular 3g or (if you’re lucky a) 4g network. I’m sure everyone knows that these networks can be unpredictable, they suffer with variable network latency and all too frequent loss of signal. In those environments, SOAP and XML start to look over blown and too heavy.
HTTP is typically used as the transport protocol under both SOAP and REST. REST is tied to HTTP and uses the basic HTTP verbs like GET, POST and PUT to express it’s actions. SOAP was designed to be transport independent so it defines a much bulkier data envelope using XML, in which to transport the data payload.
JSON is altogether a more compact way to represent data than XML. If you take a look at the two documents above side by side you should notice they actually represent the same data object, but the JSON document has considerably less boiler plate to depict the same data structure, so it takes less bytes to move it across the network. For SOAP messages, once you add on the SOAP envelope you end up with a much larger message to be sent across the network.
JSON is also easier to parse than XML, using less memory and less CPU. On a big enterprise server you don’t notice that so much, but on a mobile device memory and CPU can be in short supply.
A fact that many people forget is that CPU useage on a mobile device has a direct impact on battery life. The more demands you make of the CPU the quicker you consume battery power and the shorter time you have between recharges. This could have real business impact if the mobile user can’t complete their work because the device needs to be constantly recharged.
So hopefully you now have a better appreciation of why REST/JSON is considered best practice for mobile apps. But that doesn’t mean customers have to rip out their existing SOAP services and replace them with REST. With the Oracle Service Bus the two approaches can happily coexist and interoperate. This often means customers can quickly expose existing Web Services over REST and reuse existing business logic to shorten app development timescales.
If you’re not yet familiar with the REST and JSON technologies I encourage you to get on Google and start getting up to speed.