A Guide for Communication with Distributed Web Applications in Mobile Networks
1. A Guide for Communication with Distributed
Web Applications in Mobile Networks
Agastheswar Suribhatla
Department of Engineering and Computing Studies
Arizona State University
asuirbha@asu.edu
Abstract:
Mobile devices with the ability to run complex
applications are increasing enormously and their
cohesiveness with web services has been an integral
part of them. One of the major concerns with these
mobile applications is response time. This paper
evaluates two major web services namely RESTful
and SOAP based on timings when used on android
and iOS platforms. The evaluation results show
that RESTful web services outperform
conventional SOAP web services. It is suggested
that mobile devices use RESTful web services on
mobile devices for lower response time.
Keywords: RESTful, web services, Mobile, SOAP
I. INTRODUCTION:
Web applications usually deal with data and its
operations. Clients can interact with web applications
either by requesting or by manipulating data. Web
service [1] is a software system which allows to
applications to share data over a network using a
standard way such as XML messaging and other web
standards. Web Service Description Language
(WSDL) [13] is a XML based protocol that describes
the operations that web services perform and how
those can be accessed. Messages between applications
are exchanged in XML through SOAP protocol [2]
and XML RPC over HTTP. SOAP uses GET/POST
whereas XML RPC uses remote procedural calls that
work on HTTP, usually XML RPC executes a
procedure on the server and then gets the response in
XML format; SOAP message contains an envelope
which contains header, and body, SOAP fault.
Mobile devices in order to interact with distributed
web applications use web services. Mobile devices
interact with web services, irrespective of their
underlying operating systems, because of their
interoperable capability. Web services using SOAP
require all its messages to be built in XML. On the
other hand RESTful web services which adhere to
REST patterns are built upon the REST architecture.
REST [3][4][5] is an architectural style for distributed
hypermedia systems, as it built on top of HTTP; all the
operations which work with HTTP such as GET,
POST, DELTE, and PUT are supported by REST.
Restful web services considers everything as a
resource and specific URL’s are assigned to each
resources to uniquely identify them, whenever a
request for resource is made using the URL, the
response is sent via JavaScript Object Notation
(JSON) a set of name value pairs.
The key concerns using web services on mobile
devices is the overhead time and memory involved in
communicating with them. This paper evaluates two
widely used web services namely SOAP and RESTful
on android and iOS platforms, based on the message
size and timing involved in requesting a resource and
getting a response back from the server. It is seen that
RESTful web services outperform SOAP both in
message size and time involved in request/response.
The rest of paper is organized into sections as follows:
Section 2 discusses about the Background and related
work done , Section 3 presents the methodology used
for evaluation, Section 4 illustrates the detailed
2. description as how the evaluation is carried out, In
section 5 we presents the results of the evaluation and
analyze them, finally section 6 Concludes the paper.
II. BACKGROUND AND RELATED WORK:
Ever since the interaction with web applications
started in mobile devices many client libraries came
into existence to support them, some of them being
native libraries provided by their respective platforms
and others are third party libraries. Libraries which
support interaction with web applications on mobile
devices are RPC (Remote Procedural Call), RESTful,
SOAP (Simple Object Access Protocol).
RPC: There are two libraries that are used both in
android and iOS for RPC they are JSON RPC and
XML RPC. JSON-RPC [6] is a lightweight cross-
language remote procedure call protocol that
simplifies the creation of web services providers and
clients. XML-RPC [7] is a simple protocol that allows
software running in different environments to make
remote procedure calls over the Internet.
RESTful: RESTful services run on the top of Http
protocol stack. Both android and iOS use built in Http
support to access RESTful resources
SOAP: There is no built in support available for SOAP
both in android and iOS, but there are some third party
libraries that support SOAP namely KSOAP2 [8] for
android, wsdl2objc tool for iOS. KSOAP2 is an
android project that provides light weight and efficient
SOAP client library. Wsdl2objc is a tool which parses
the wsdl file and provides delegate methods to access
the services provided by the wsdl.
Web servers provide web services for clients, to access
resources residing on the servers. Two of the major
web services that are widely used for communicating
with servers are SOAP and RESTful. Servers can
provide SOAP web service by using jax-ws( Java Api
for XML Web Services)[9]; jax-ws is a java api for
creating web services that communicates using XML,
likewise RESTful web services can be provided by
using jax-rs(Java Api for RESTful Web Services)[10];
jax-rs is a java api for creating web services according
to REST architectural pattern.
XML files can be generated from java objects using
jaxb [11] library, a library that provides annotations
which converts objects to and from xml; on the other
hand Json files can be generated using gson [12], a
google library which converts objects to and from
json.
III. METHODOLOGY:
Initially a java helper class was used to create json and
xml files from java objects, these files are then fed to
the server to be transported as json files for RESTful
services and xml files for SOAP when requested by
client. Android and iOS clients request data from
server using RESTful and SOAP services either by
using native support provided by the respective
platforms or by using third party libraries. A detailed
analysis was carried out by sending different file sizes
and then measuring the time taken for request to
response of the file on the client.
IV. DESCRIPTION:
We evaluate the communication mechanisms SOAP
and RESTful on two major mobile platforms android
and iOS based on timing. For this evaluation we have
used 2 machines one which runs windows 7 and the
other machine which runs mac OS X. Windows
machine was setup as server and mac machine was the
client.
Server machine was setup to run SOAP web services
using jax-ws and RESTful web services using jax-rs.
All the applications on the server were developed
using eclipse kepler IDE and the web services were
deployed on apache tomcat 7.0.5. On the client
machine android applications were developed using
adt-bundle and were targeted to android API level
3. 4.4.2, In the case of iOS applications were developed
using Xcode5 and were targeted to iOS 7.
The evaluations were done on the following devices:
Samsung galaxy s4 running android version 4.4.2 and
iPhone 5 running iOS 7.1, also on android emulator
running 4.4.2 and iOS simulator running iOS 7.1.
Initially a java helper class was used to create java
objects and then convert them to json, xml using gson
and jaxb library respectively. Gson takes list of java
objects and converts them to Json( name, value pairs)
objects, jaxb uses xml annotations on java objects to
marshal them to xml elements. These Xml and Json
objects are then written to a file to create Xml and Json
files
The Xml and Json files produced from the helper class
are fed to SOAP and RESTful web services. SOAP
web services is created using jax ws library. Firstly a
java interface is created which is then implemented by
another java class. Then necessary java files for web
service deployment are created using wsgen command
from the created java interface and implementation
files. In the case of RESTful web server, jax rs library
is used to create the RESTful web service; a simple
java method with jax rs annotations is created to serve
the purpose.
Two apps were created for Android and iOS for
calculating the time taken to get response from SOAP
and RESTful web services. The RESTful app used http
connection and the RESTful web server url was feed
to the connection to connect to the server. The app hit
the RESTful web server for a resource and gets Json as
response, the time before sending the request and after
getting the response were recorded and the time taken
for request response is calculating by subtracting one
from another. On an average 50 readings were
recorded for each Json file size both on android and
iOS platforms. The SOAP app in android uses
KSOAP2 to interact with SOAP web server and a tool
wsdl2objc was used to generate delegate methods to
interact with SOAP web server in the case of iOS.
KSOAP2 creates a SOAP message by taking in the
wsdl URL, the method name (method which sends the
requested resource) and any parameters that should be
send to the method. SOAP message is sent to the wsdl
via HTTP and we get the SOAP response. The
response can either be a SOAP message or a SOAP
fault. The SOAP message contains the response in the
SOAP envelope. In the case of iOS the wsdl2objc tool
takes the wsdl url as input, it parses the methods
provided by the wsdl and generates objc files which
contains delegate methods, these delegate methods are
used to send SOAP messages to web servers and get
the response back. The time before sending the created
SOAP request and after getting the SOAP response
were recorded and the request/response time is
calculated by subtracting one from another. On an
average 50 readings were recorded for different Xml
file sizes both on Android and iOS platforms.
RESULTS AND ANALYSIS:
Based on described setup, an evaluation was made on
android and iOS platforms using SOAP and RESTful
web services. By using the java helper class varying
file sizes such as 100kb, 500kb and 1 MB are
generated for json and 267kb, 1.27 MB, 2.57 MB are
generated for xml from the same number of java
objects. These files were sent for each client request
and following times were recorded at the client side.
Start Time: The time taken by the mobile app to first
trigger in the device and then request for a resource
and get the response for it.
Mean Time: The average time for request/response
taken by the mobile app
Lowest Time: The least time for request/response
taken by the mobile app
Highest Time: The highest time for request/response
taken by the mobile app
All timings are recorded in milliseconds
4. Android Device – JSON
File
Size
Start
Time
Mean
Time
Lowest
Time
Highest
Time
1.0
MB
4783 4168.7 1144 9832
500
kb
958 516.6 403 2183
100
kb
355 129.3 92 355
Android Emulator - JSON
File
Size
Start
Time
Mean
Time
Lowest
Time
Highest
Time
1.0
MB
36503 13045.73 8639 36503
500
kb
32601 9758.5 5540 32601
100
kb
13350 3106.6 1493 13350
iOS Simulator - JSON
File
Size
Start
Time
Mean
Time
Lowest
Time
Highest
Time
1.0
MB
4343 1050.8 6251 4343
500
kb
738.6 416.6 312 1027
100
kb
309.3 138 61.2 309.3
iOS Device - JSON
File
Size
Start
Time
Mean
Time
Lowest
Time
Highest
Time
1.0
MB
810 482.8 370.1 810
500
kb
675 208.6 170.4 675
100
kb
353 47.4 41.1 353
Android Device – SOAP
File
Size
Start
Time
Mean
Time
Lowest
Time
Highest
Time
2.57
MB
9483 7022.3 6001 21979
1.27
MB
6561 3691.3 3206 6561
267
kb
1406 733.2 530 20470
Android Emulator – SOAP
File
Size
Start
Time
Mean
Time
Lowest
Time
Highest
Time
2.57
MB
31675 28944.2 26644 35884
1.27
MB
14854 13740 12931 14854
267
kb
4822 4829.8 3996 5902
iOS Simulator SOAP
File
Size
Start
Time
Mean
Time
Lowest
Time
Highest
Time
2.57
MB
3973.5 4915.2 3025 16091.3
1.27
MB
2074.1 1258.8 1159.4 2074.1
267
kb
336.8 334.7 231.4 444.8
iOS Device SOAP
File
Size
Start
Time
Mean
Time
Lowest
Time
Highest
Time
2.57
MB
4648 2637.8 2446 4648
1.27
MB
1978 1290.5 1179 1978
267
kb
708 301.7 268.4 708
5. Considering the results of the RESTful and SOAP web
services, it is evident that json files are smaller in size
and are faster to load than xml files. One of the
interesting facts about the file sizes are that xml file
sizes are twice as the size of json files even though the
same no of objects were used in generating both the
files. The memory usage of devices when loading
these file are as follows:
For json files there isn’t a significant increase in heap
memory for 100kb, 500kb files but for 1 MB file the
heap size for android device has grown up to 29.22
MB.For xml files there isn’t a significant increase in
heap memory for 267kb file but for 1.27 MB file and
2.57 MB files the heap sizes for android device has
grown up to 32.85 MB and 46.26 MB respectively.
Considering the amount of memory used while loading
the files json files consume less memory when
compared to xml files, It can be seen that when
loading file of large sizes the app tends to consume
more memory, which sometimes may result in killing
of the app by the OS.
V. CONCLUSION:
We have looked into various communication methods
used in mobile applications that interact with web
applications. SOAP would be useful if the web
services are offered as WSDL’s or if the application
needs to maintain a conversational state (stateful
behavior), else RESTful web service are used for the
application to be stateless. Since, RESTful web
services are built on top of HTTP they don’t require
any additional setup. Instead the inbuilt HTTP support
in android and iOS can be used where as in case of
SOAP, external third party libraries are used to interact
with SOAP web services.
Memory and Response time serve as key factors
pertaining to a mobile device. Our evaluations proved
that RESTful web services outplay SOAP relating to
these two factors. It was seen that RESTful web
services produced files of lower size and had lesser
response time when compared to SOAP. Therefore, it
is suggested that mobile applications using RESTful
web services have higher flexibility and lower
overhead.
VI. REFERENCES:
[1] "Web Services Glossary". W3C Retrieved 2014-4-
10.
[2] “SOAP Version 1.2 Part1: Messaging Framework
(Second Edition)”, http://www.w3.org/TR/2007/REC-
soap12-part1-20070427/, Retrieved 2014-4-10.
[3] Fielding R., “Architectural Styles and the Design
of Network-based Software Architectures," PhD
Dissertation, University of California, Irvine,
California, USA, 2000.
[4] Fielding, Roy T.; Taylor, Richard N., "Principled
Design of the Modern Web Architecture", ACM
Transactions on Internet Technology (TOIT) (New
York: Association for Computing Machinery), New
York, May 2002
[5] Hatem Hamad, Motaz Saad, and Ramzi Abed,
“Performance Evaluation of RESTful Web Services
for Mobile Devices”, Computer Engineering
Department, Islamic University of Gaza, Palestine,
January, 2010
[6] JSON RPC, http://json-rpc.org/ , Retrieved 2013-9-
7
[7] XML RPC, http://www.xmlrpc.com/spec,
Retrieved 2013-9-12
[8] Ksoap2-android, MIT,
https://github.com/mosabua/ksoap2-android, retrieved
2014- 2-10
[9] JAX –WS, https://jax-ws.java.net/, Retrieved 2013-
9-27
[10] JAX- RS, https://jax-rs-spec.java.net/, Retrieved
2013-10- 11
[11] JAXB, http://jaxb.java.net/, Retrieved 2013-10-
22
[12] GSON, https://code.google.com/p/google-gson/,
Retrieved 2013-11- 6
[13] WSDL, http://www.w3.org/TR/wsdl, Retrieved
2013-12-10