1 / 22

SSC2: Web Services

SSC2: Web Services. 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. Uses of Web Services.

Download Presentation

SSC2: Web Services

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 PDA .NET Windows C++ Server PHP

  6. XML • Plain text mark-up • Strict syntax • Flexible vocabulary • Supports schemas

  7. XML example <books source="Pete's Bookshelf"> <book> <author type="single author"> <lastname>Heller</lastname> <firstname>Joseph</firstname> </author> <title>Catch 22</title> <publisher>Macmillan</publisher> <isbn number="010176483933" /> </book> <book> <author type="primary author"> <lastname>Preece</lastname> <firstname>Jenny</firstname> </author> <author type="secondary author"> <lastname>Rogers</lastname> <firstname>Yvonne</firstname> </author> <author type="secondary author"> <lastname>Sharp</lastname> <firstname>Helen</firstname> </author> <title>Human Computer Interaction</title> <publisher>Addison Wesley</publisher> <isbn number="8575689937334" /> </book> </books>

  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:base64Binary byte[] • xsd:boolean Boolean • xsd:byte Byte • xsd:dateTime java.util.Calendar • xsd:decimal java.math.BigDecimal • xsd:double Double • xsd:float Float • xsd:hexBinary byte[] • xsd:int Int • xsd:integer java.math.BigInteger • xsd:long Long • xsd:Qname javax.xml.namespace.Qname • xsd:short Short • xsd:string 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 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

More Related