SSC2: Web Services - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

SSC2: Web Services

Description:

Web Services provide information on the operations they can perform ... eg Infinity vs Inf. Date/Time formats. Trailing zeroes in decimals 0.70 vs 0.7 ... – PowerPoint PPT presentation

Number of Views:8
Avg rating:3.0/5.0
Slides: 23
Provided by: peterlo7
Category:
Tags: services | ssc2 | trailing | web

less

Transcript and Presenter's Notes

Title: SSC2: Web Services


1
SSC2 Web Services
2
Web Services
  • Web Services offer interoperability using the web
  • Web Services provide information on the
    operations they can perform
  • Clients can be built using this information, and
    coupled to any interface
  • Natural extension of OOP

3
Uses of Web Services
  • To glue together components of a system,
    especially distributed computing
  • MOBIlearn
  • mobile gaming
  • To provide standardised access to databases,
    services etc
  • Amazon

4
Important elements
  • SOAP
  • The XML messaging protocol that all web services
    use
  • UDDI
  • A directory service for locating Web Services
  • Built in to .NET
  • WSDL
  • XML document describing what a web service can do

5
Linux Java
Web Service HTTP XML
Windows C
PDA .NET
Server PHP
6
XML
  • Plain text mark-up
  • Strict syntax
  • Flexible vocabulary
  • Supports schemas

7
XML example
ltbooks source"Pete's Bookshelf"gt ltbookgt
ltauthor type"single author"gt
ltlastnamegtHellerlt/lastnamegt
ltfirstnamegtJosephlt/firstnamegt lt/authorgt
lttitlegtCatch 22lt/titlegt
ltpublishergtMacmillanlt/publishergt ltisbn
number"010176483933" /gt lt/bookgt ltbookgt
ltauthor type"primary author"gt
ltlastnamegtPreecelt/lastnamegt
ltfirstnamegtJennylt/firstnamegt lt/authorgt
ltauthor type"secondary author"gt
ltlastnamegtRogerslt/lastnamegt
ltfirstnamegtYvonnelt/firstnamegt lt/authorgt
ltauthor type"secondary author"gt
ltlastnamegtSharplt/lastnamegt
ltfirstnamegtHelenlt/firstnamegt lt/authorgt
lttitlegtHuman Computer Interactionlt/titlegt
ltpublishergtAddison Wesleylt/publishergt
ltisbn number"8575689937334" /gt
lt/bookgt lt/booksgt
8
XML schemas
  • Describe the expected structure of an XML
    document
  • Books example

9
XML and Web Services
  • Web Services were envisaged as a way to allow
    different platforms, languages, systems etc to
    communicate using a standardised language
  • Not just communicate, but perform actions
  • XML schemas provide this language

10
SOAP
  • SOAP Simple Object Access Protocol
  • Plain text XML transmitted using HTTP
  • Sent using GET and POST, instead of HTML
  • Allows sending of text/XML data
  • workaround allows sending of binary files e.g.
    images, by sending byte array
  • can also use SOAP with Attachments

11
Summary
  • A Web Service is a web application that has some
    of its methods accessible over the web
  • Clients can retrieve a structured document giving
    details about how those methods should be called,
    and what they will return
  • All done over HTTP/XML/SOAP

12
Axis
  • Apache Axis is a web application for deploying
    and consuming web services using Java
  • Runs as an application under Tomcat
  • Allows Java methods to be exposed as web
    service methods

13
Axis tools
  • Axis comes with a number of useful tools for
    working with WSDL, XML etc
  • We can call them from the command line, but we
    need all the required libraries in our classpath
  • So we can call them from a project inside
    NetBeans instead

14
Setting up Axis
  • Axis is a web application that runs under Tomcat
  • Copy the axis folder from J to your work
    folder
  • Create a new Web Application within NetBeans,
    using existing sources, with Axis as the source
  • Add new classes to your Axis application

15
Deployment
  • Axis lets us deploy web services in 2 ways
  • instantly, using .jws files that are deployed at
    runtime
  • using a deployment config file to specify which
    classes and methods to expose
  • Instant method is great for quick easy web
    services, but doesnt allow the use of other Java
    packages

16
Data types
  • xsdbase64Binary byte
  • xsdboolean Boolean
  • xsdbyte Byte
  • xsddateTime java.util.Calendar
  • xsddecimal java.math.BigDecimal
  • xsddouble Double
  • xsdfloat Float
  • xsdhexBinary byte
  • xsdint Int
  • xsdinteger java.math.BigInteger
  • xsdlong Long
  • xsdQname javax.xml.namespace.Qname
  • xsdshort Short
  • xsdstring java.lang.String

17
Returning sets of results
  • Often we want to send/receive sets of data of
    with varying number of elements
  • 3 basic methods
  • concatenate the results into a single string
  • return an array (of strings, integers etc)
  • return a structured XML document

18
Consuming Web Services
  • Any platform that can parse generate SOAP
    requests can communicate with a Web Service
  • Tools that generate code stubs from WSDL
    documents make it easy

19
Consuming with Axis
  • Axis tool WSDL2Java generates code stubs from
    WSDL document
  • Can use stubs to create proxy classes that act
    as local versions of the web service, making
    calls to the actual service when necessary

20
Consuming with Axis


Server side
Client side
User Interface
Web Service classes
Local classes
Axis web app
Proxy classes
Tomcat server
HTTP SOAP
21
Understanding Scope
  • Scope determines how often a servlet or web
    service gets loaded
  • Request a new instance is created for every
    request that is received
  • Session a new instance is created for each
    users session
  • Application a new instance is created each time
    the application is started

22
Issues
  • Web Services only offer content pull
  • Even with WSDL, ambiguity can arise because of
    interpretation
  • XML might be difficult to parse, depending on
    methods used
  • Not all implementations of SOAP are the same
  • eg Infinity vs Inf
  • Date/Time formats
  • Trailing zeroes in decimals 0.70 vs 0.7
Write a Comment
User Comments (0)
About PowerShow.com