Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Web service and Its Integration in Android

Web service and Its Integration in Android

Web services and its integration in Android. Presented this talk in NitroDroid 2012.

Paresh Mayani

October 06, 2012
Tweet

More Decks by Paresh Mayani

Other Decks in Programming

Transcript

  1. Web service and Its integration
    in Android
    - By Paresh Mayani (@pareshmayani)
    Internet
    Database
    Database
    Web Services

    View Slide

  2. Web service?
    • The W3C defines a “web service” as “a
    software system designed to support
    interoperable machine-to-machine interaction
    over a network.

    View Slide

  3. Request
    Sending data
    like Name,
    Address
    Method
    GET, POST
    Response
    Receiving
    data
    FORMAT
    XML / JSON

    View Slide

  4. Categories of web service
    • SOAP Web Service
    • RESTful Web Service

    View Slide

  5. Soap Web Service
    • Simple Object Access Protocol
    • An XML-based messaging protocol.
    • Communication between the web
    service and client happens using
    XML messages
    • SOAP defines the rules for
    communication like what are all the
    tags that should be used in XML and
    their meaning.

    View Slide

  6. RESTful Web Service
    • Representational State Transfer
    (REST)
    • Describe an architecture style of
    networked systems.
    • An Architectural Style, Not a
    Standard
    • It uses architectures that use HTTP
    or similar protocols by restricting
    the interface to use standard
    operations like GET, POST, PUT,
    DELETE for HTTP

    View Slide

  7. Goodbye SOAP – Welcome JSON
    REST
    • Lightweight - not a lot of extra xml markup
    • Human Readable Results

    View Slide

  8. JSON
    • JavaScript Object Notation
    • It is a lightweight data-interchange format.
    • It is easy for humans to read and write.
    • It is easy for machines to parse and generate.
    JSON is built on two structures:
    • A collection of name/value pairs. In various languages, this is
    realized as an object, record, struct, dictionary, hash table, keyed
    list, or associative array.
    • An ordered list of values. In most languages, this is realized as an
    array, vector, list, or sequence.
    • Reference: http://www.json.org/

    View Slide

  9. JSON Structure
    JSON
    Object
    JSON
    Array
    http://www.technotalkative.com/android-json-parsing/

    View Slide

  10. + HTTP
    • Option 1:
    java.net.URL;
    java.net.HttpURLConnection;
    • Option 2:
    HTTPClient API

    View Slide

  11. HttpClient API

    View Slide

  12. Request

    View Slide

  13. Request

    View Slide

  14. No Request

    View Slide

  15. Get in Touch
    twitter.com/pareshmayani
    fb.com/GDGAhmedabad
    http://gplus.to/GDGAhmedabad
    http://www.technotalkative.com/

    View Slide