Download presentation
Presentation is loading. Please wait.
Published byJack Garrett Modified over 9 years ago
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
Web Service HTTP XML Windows C++ Linux Java PDA.NET Server PHP
6
XML Plain text mark-up Strict syntax Flexible vocabulary Supports schemas
7
XML example Heller Joseph Catch 22 Macmillan Preece Jenny Rogers Yvonne Sharp Helen Human Computer Interaction Addison Wesley
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 doesn’t allow the use of other Java packages
16
Data types xsd:base64Binarybyte[] xsd:booleanBoolean xsd:byteByte xsd:dateTimejava.util.Calendar xsd:decimaljava.math.BigDecimal xsd:doubleDouble xsd:floatFloat xsd:hexBinarybyte[] xsd:intInt xsd:integerjava.math.BigInteger xsd:longLong xsd:Qnamejavax.xml.namespace.Qname xsd:shortShort xsd:stringjava.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 User Interface Local classes Proxy classes Tomcat server Axis web app Web Service classes Client side Server side 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 user’s 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
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.