Development of Web Services for Android Applications
-
Upload
md-ashraful-haque -
Category
Education
-
view
238 -
download
1
Transcript of Development of Web Services for Android Applications
![Page 1: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/1.jpg)
Development of Web Services for Android Applications
Md Ashraful Haque
![Page 2: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/2.jpg)
2Introduction
In present days, the ability to seamlessly exchange information between internal business units, customers, and partners is vital for success
Yet most organizations employ a variety of disparate applications that store and exchange data in dissimilar ways and therefore cannot "talk" to one another productively
Web services have evolved as a practical, cost-effective solution for uniting information distributed between critical applications over operating system, and language barriers that were previously impossible
![Page 3: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/3.jpg)
3
In last few years the use of smartphones and tablets has been increased enormously, changing the scenario of mobile phone usage
The applications associated with this smartphones and tablets are the most attractive tools which provides a touch and click interface to the users
According to Nielsen Media Research • In 2014, the mobile users spent 89% of their time on media through the mobile
Application
Contd…
![Page 4: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/4.jpg)
4 Now-a-days Android operating system has become a predominant platform in the
market of application development. (Shanmugapriya et al., 2011)
Several companies as part of OHA (Open Handset Alliances) developing millions of Android applications
e-learning to m-learning, e-commerce to m-commerce
In this shifting from web-based application to mobile application, web services act as the intermediate interface
Contd…
![Page 5: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/5.jpg)
5Web service overview Web service is a standardized technology that
• Exposes information, functionalities and business logic of a existing web-server/web page application over the Internet
• Allows other system/application to access these information, functionalities and business logic by calling the web methods
• provides program-to-program interface between the systems/application
• Uses some open standards or protocols like SOAP, WSDL and UDDI
![Page 6: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/6.jpg)
6
o Device A request some data from other system B over the network
o System B exposes the data using a web service through the network
o System A gets the response data as a result
Web services communicate between different systems/applications
Contd…
WEB SERVICE
![Page 7: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/7.jpg)
7 Web services are independent of programming language and platform (Kao,
2001)
Contd…
![Page 8: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/8.jpg)
8Architecture of web services Web services Architecture is defined by SOA (Service Oriented
Architecture)• SOA concept refers to a architecture based on some distinct services• Interaction between these services exist
According to SOA there are three components in a web services-• Service roles/actors• Service operations• Standards/Protocols
![Page 9: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/9.jpg)
9
SERVICE REQUESTOR
SERVICE PROVIDER
SERVICE REGISTRY
XML
XML
SERVICE RESPONSE
SERVICE REQUEST
BIND/INTERACT
PUBLISH(WSDL)
FIND/LOCATE(WSDL+UDDI)
SOAP
SOAP
The service actor are-o Service provider
o Service Requestor
o Service Registry
The operations performed o Publish
o Find/Locate
o Bind/Interact
Contd…
![Page 10: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/10.jpg)
10 Standards/protocols of web service
SOAP (Simple Object Access Protocol)
• It is XML-based messaging protocol, where XML (eXtensible Markup Language) provides tags to each element of the message
• The basic communication between the systems are served by SOAP Request and SOAP Response
• Also known as Communication Protocol
Contd…
![Page 11: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/11.jpg)
11Contd…
• Framework of SOAP-
o Has components like envelop, header, body
o The message elements are encapsulated in the SOAP envelop
![Page 12: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/12.jpg)
12Contd… WSDL(Web Services Description Language)-
• The service description is specified in the WSDL file
• XML-document format
• Provides location (URL) of the service and description of the service to a client application
![Page 13: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/13.jpg)
13Contd… UDDI (Universal Description, Discovery and Integration)
• XML-based standard for publishing, finding and registering web services
• It acts as a centralised registry that enables the clients to locate the web services.
• Closely resembles online “Phone Directory” (Dustdar, et al., 2005)
• Provide two basic informationo Service description along with the way to encode ito Query and update APIs of the registry
![Page 14: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/14.jpg)
14Introducing the Android Application Android Platform
• Open source software stack for mobile application development
• Google initiated android project with Open Handset Alliance including 30 companies (Knutsen, 2009)
• Linux based kernel and runs its application on Dalvik Virtual Machine
• Several version has released till today, the latest version released is Lollipop (Android 5.0) and Android M is the upcoming release.
![Page 15: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/15.jpg)
15Contd… Advantages of Android Platform
• Open source software
• Android integration in any device
• Devices can be easily customizable
• No external review required
![Page 16: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/16.jpg)
16Contd…
Architecture of android platform
o Four layers and five sections
![Page 17: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/17.jpg)
17Importance of web services in android Applications
Using and implementing functionalities of existing web-based systems/applications
Access data from remote database server easily
Client users can access the web service in an emergency situation if health related web services are available
User get information on touch and click using a web service through the application
![Page 18: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/18.jpg)
18Developing a web service in java Programming language
Creating a web service that will access a remote database server Creating a web service class and web methods
Creating Database Source Name (DSN)
Accessing database in java
Deploy and Testing the web service
![Page 19: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/19.jpg)
19Contd… Creating web service class and web methods
• A web service consists of a set of web service class and web methods
• Web service classes encapsulate all the web methods used in the service
• Web methods are the actual implementation of exposing the functionality of a system over the network
![Page 20: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/20.jpg)
20Contd..
o @WebService (serviceName = “test”)
o @WebMethod(operationName=“loginid”)
o @WebParam (name =“username”)
![Page 21: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/21.jpg)
21Contd… Creating Database Source Name (DSN)
• Database source name provides connectivity to a database through an ODBC driver
• DSN contains database name, database
driver, directory and other information
• Once a DSN is created, one can use the
DSN in an web service to invoke
information from the database
![Page 22: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/22.jpg)
22Contd… Accessing the database in Java
• Java provides a set of classes that connects the database by loading the ODBC driver
![Page 23: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/23.jpg)
23Contd… Deploying and Testing web service
• To make the web service available to any client application, the service have to be deployed
• The web service has been deployed to the Glassfish server so that the service can be available over the Internet
• The web service can be tested by tester in the browser
![Page 24: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/24.jpg)
24Contd…
Web method is tested by click on the loginid button
Service description file
![Page 25: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/25.jpg)
25Contd… The WSDL file
o URL to access the web service
o Method or the operation
o Data types used in method parameter and return types
![Page 26: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/26.jpg)
26Contd…
Parameter Provided
Method returns a value
![Page 27: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/27.jpg)
27Contd…
o The SOAP request and SOAP response.
![Page 28: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/28.jpg)
28Consuming the web service in Android applications
An android application can be developed as client application for consuming the web service
Android application creates a request to the web service, the web service responses to the application with desired result
![Page 29: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/29.jpg)
29Contd…
Key points of Android Application for consuming a web service are-
Creating layout files in XML
Creating activity class files in JAVA
Accessing the web service inside the application
Internet Permission in the manifest file
![Page 30: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/30.jpg)
30Contd... Creating Layout file in XML-
• Framework of each activity of an application is defined in the layout file
• Just a XML file with tags
• It can define different elements such aso Form widgets- Buttons, Progress Bar, TextView etco Text fields- EditText, Password, Date, E-mail etco Layout- Linear, Relative etc
![Page 31: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/31.jpg)
31Contd…Referring a linear layout
Referring a textview within the application
Referring a text editor in the application
Referring a button to be clicked
![Page 32: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/32.jpg)
32Contd… Creating the activity class file in java
• most important files in the application written in java programming language
• ultimately converted in Dalvik executable file and runs the application
• Inherits the base classes of android like Activity Class, ActionBarActivity Class etc
• Implements and overrides the necessary methods such as onCreate(), onClick() etc
![Page 33: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/33.jpg)
33Contd…• performing the following functionality-
o Defines the XML-layout elements and provide reference of the XML elements into java
o sets the content view of the application as per the XML-layout file
![Page 34: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/34.jpg)
34Contd…o Sets tasks in application after the button is clicked
![Page 35: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/35.jpg)
35Contd… Accessing the web service inside the application
• Most important part of the application that actually calls the web method• Add a third party library KSOAP2 (http://ksoap2.sourceforge.net) to the library
of Android project that is optimized for Android
![Page 36: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/36.jpg)
36Contd…
• Firstly defines the namespace of the web service, name of the web method, SOAP-Action and the URL of the web service description
![Page 37: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/37.jpg)
37Contd…
• SOAP request is fired based upon the specified web method of the web service and properties are added as per the requirement
• SOAP envelop is created and version of the SOAP is declared
![Page 38: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/38.jpg)
38Contd…• Passing the request to the envelop
• Connecting to the web service using the URL and invoking the web method with request
• The response of the request is stored as String
![Page 39: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/39.jpg)
39Contd…
Internet permission in the manifest file
• the application needs a permission for accessing the Internet
![Page 40: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/40.jpg)
40Current Technology RESTful-based web service
• has gained wide acceptance across worldwide in last few years
• It is being used as a simpler alternative to SOAP and WSDL-based web services (Zur et. al, 2005)
• REST stands for Representational State Transfer, defines a set of architectural principles for developing web services
• It typically communicate over HTTP with the same HTTP principle CRUD (create, Read, update, Delete)
![Page 41: Development of Web Services for Android Applications](https://reader035.fdocuments.net/reader035/viewer/2022070515/5879c7071a28abb42a8b653b/html5/thumbnails/41.jpg)
41Conclusions-
Companies/organisations are developing web services to integrate the existing functionalities and resources of multiple systems/applications
e-commerce companies like Flikart, Amazon, Snapdeal, Myntra, Paytm expanding themselves through mobile application version
Web services can be developed for the agricultural information system so that any client application can access those facilities easily
Further studies on RESTful web services for Android application can be done