Presentation is loading. Please wait.

Presentation is loading. Please wait.

Distributed Web Systems Web Services Lecturer Department University.

Similar presentations


Presentation on theme: "Distributed Web Systems Web Services Lecturer Department University."— Presentation transcript:

1 Distributed Web Systems Web Services Lecturer Department University

2 Outline Web services and the Semantic Web XML and Web services protocols Implementing web services

3 What is a Web Service? A Web Service is any service that: –Is available over the Internet or private (intranet) networks –Uses a standardized XML messaging system –Is not tied to any one operating system or programming language Although not required, a web service may also have two additional (and desirable) properties: –a web service should be self describing. –a web service should be discoverable.

4 A Basic Web Service Computer A: Language: Perl Operating System: Windows 2000 Computer B: Language: Java Operating System: Linux XML

5 XML Messaging There are several alternatives for XML messaging: –XML Remote Procedure Calls (XML-RPC) –SOAP –Regular XML transported over HTTP Any of these options are valid. XML-RPC SOAP HTTP POST/GET XML Document

6 Self Describing and Discoverable Self describing: –If you publish a new web service, you should also publish a public interface to the service. –At a minimum, you should include human-readable documentation so that others can easily integrate your service. –If you have created a SOAP service, you should also include a public interface written in a common XML grammar. Discoverable: –If you create a web service, there should be a relatively simple mechanism to publish this fact. –Interested parties should be able to easily discover your service. –The discovery service could be completely decentralised or completely centralised.

7 The Web Today: Human Centric Web Browser Web Server HTTP GET: “What are available flights for my dates” HTTP Response with HTML Page: “BE384 leaving at 14:45 arriving 15:50” This illustrates a human-centric web, where humans are the primary actors initiating web requests. It also represents the primary model on which most of the web operates today.

8 The Application-Centric Web Conversations between applications occur as easily as conversations between web browsers and servers Booking Application Web Server On to other applications (e.g. travel agent systems) On to human users XML Request: “What are available flights for my dates” XML Response: “BE384 leaving at 14:45 arriving 15:50”

9 The Semantic Web Tim Berners-Lee, the original inventor of the WWW, is now arguing for a Semantic Web: –The next stage is development of the Web –Application centric –Global application integration over the Web –Web services can be viewed as an actualisation of the Semantic Web vision Numerous applications: –e-commerce (shopping, travel, etc) –e-business (orders, logistics, etc) –scientific distributed computing (the Grid, etc) –…

10 Haven’t we seen this before? An application-centric web is not a new notion. For years, developers have created –CGI applications, Java Servlets and CORBA applications –designed primarily for use by other applications. The crucial difference is that most of these systems consisted of ad-hoc solutions. With web services, we have the promise of some standardisation. Standardisation will lower the barrier to application integration.

11 Long term vision: Just-In-Time Integration 787-Travel “Smart” travel agent application Service Registry Discover Services 1 British Airways Server Service Description Ticket Booking Service Retrieve Service Description 2 Invoke Remote Service 3

12 Hype vs Reality How close are we to creating “Just-in-time” integration? Currently, only some processes can be automated: –automatic registry query –automatic invocation of service However, –no mechanism exists for automating business relationships. –no mechanism exists for evaluating the quality of services. “Hot” research area! –Big industry players involved (Microsoft, IBM, Sun, …)

13 XML  XML: eXtensible Markup Language  "XML, to a certain extent, is HTML done right." - Simon St.Laurent  “XML is HTML on steroids.”  XML:  Extensible: can be extended to lots of different applications.  Markup language: language used to mark up data.  Meta Language: Language used to create other languages.

14 XML vs HTML  XML is Extensible:  HTML: restricted set of tags, e.g.,,, etc.  XML: you can create your own tags  Example: Put a list of publications on the web.  HTML: You are stuck with regular HTML tags, e.g. H1, H3, etc.  XML: You can create your own set of tags: TITLE, AUTHOR, DATE, PUBLISHER, etc.

15 Publications list in HTML Harry Potter J. K. Rowling 1999 Scholastic HTML conveys the “look and feel” of your page. As a human, it is easy to pick out the publisher. But, how would a computer pick out the publisher? Answer: XML

16 Publications list in XML Harry Potter J. K. Rowling 1999 Scholastic Look at the new tags! A Human and a computer can now easily extract the publisher data.

17 XML vs HTML (contd.)  General Structure:  Both have Start tags and end tags.  Tag Sets:  HTML has set tags  XML lets you create your own tags.  General Purposes:  HTML focuses on "look and feel”  XML focuses on the structure of the data.  XML is not meant to be a replacement for HTML. In fact, they are usually used together.

18 Basic Definitions  Tag: a piece of markup  Example:,,, etc.  Element: a start and an end tag  Example: Hello  HTML Code:  This is a sample paragraph.  This code contains:  3 tags,,, and  However, it only contains one element: …

19 XML rule 1: Well-Formedness  XML is much more strict than HTML.  XML requires that documents be well- formed:  every start tag must have an end tag  all tags must be properly nested.  XML Code:  This is a sample paragraph. Note the end Also, you cannot interleave tags!

20 XML rule 2: XML is case sensitive  XML is case sensitive.  HTML is not.  The following is valid in HTML:  Hello World  This will not work in XML. Would result in a well-formedness error:  H1 does not have a matching end H1 tag.

21 Rule 3: Attributes must be quoted.  In HTML you can get away with doing the following:   In XML, you must put quotes around all your attributes:  Harry Potter

22 XML Example B359 class Rinat Time management Please plan your work and complete the assignment early! This XML Note could be part of a message board application.

23 Back to web services: Roles and protocols UDDI WSDL XML-RPC, SOAP, Custom XML HTTP, SMTP, FTP, BEEP Discovery Description XML Messaging Transport Three major roles in web services: –Service Provider: provider of the web service. –Service Requestor: any consumer of the web service. –Service Registry: logically centralised directory of services.

24 XML-RPC Use XML messages to perform Remote Procedure Calls (RPC) –Simple! Here is a sample XML-RPC request to a weather service: weather.getWeather 10016 “Give me the current weather conditions in zip code: 10016.”

25 SOAP SOAP: used to stand for “Simple Object Access Protocol” XML-Based protocol for exchanging information between computers. Currently a formal recommendation of the World Wide Web Consortium (W3C.)

26 SOAP Message Format SOAP Message Envelope (Required) Header (Optional) Body (Required) Fault (Optional: Response only)

27 SOAP Example A sample SOAP request to a weather service: <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://www.w3.org/2001/09/soap-envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <ns1:getWeather xmlns:ns1="urn:examples:weatherservice" SOAP-ENV:encodingStyle="http://www.w3.org/2001/09/soap-encoding/"> 10016

28 WSDL WSDL: Web Service Description Language An XML grammar for specifying an interface for a web service Specifies –location of web service –methods that are available by the web service –data type information for all XML messages Given a WSDL file, a developer can immediately figure out how to connect to the web service. –Eases overall integration process. –Better yet, with WSDL tools, you can automate the integration… WSDL is commonly used to describe SOAP services.

29 WSDL in a nutshell : Root WSDL Element : What messages will be transmitted? : What operations (functions) will be supported? : What SOAP specific details are there? : Where is the service located? : What data types will be transmitted?

30 WSDL Example: Weather service

31 WSDL Example: Weather service … WSDL File for Weather Service <port binding="tns:Weather_Binding" name="Weather_Port"> <soap:address location="http://ecerami.com/soap/servlet/rpcrouter"/>

32 UDDI UDDI: Universal Description, Discovery and Integration. Currently represents the discovery layer in the protocol stack. Originally created by Microsoft, IBM and Ariba. Technical specification for publishing and finding businesses and web services.

33 Using the Protocols Together Find Services via UDDI Step 1: Retrieve Service Description File: WSDL or XML-RPC Instructions Step 2: Create XML-RPC or SOAP Client Step 3: Invoke Remote Service Step 4:

34 Implementing Web services Problem: –need to write code to parse XML –need to implement SOAP or other protocol used Web server Client’s PC XML inside HTTP POST XML inside HTTP response Servlet Parse XML, call necessary methods, get results, package them into XML responses, send back to client Can use servlets!

35 Using Apache Axis Apache Axis –a web application (a bunch of servlets) –provides an implementation of SOAP (XML handling, etc) –calls the Java classes implementing the corresponding Web services –… so all you need is to write a Java class, Axis will make it accessible as a Web service! Web server Client’s PC XML inside HTTP POST XML inside HTTP response Servlet Java classes

36 Using Apache Axis (contd.) Deploying Web services in Axis –make your Java classes accessible to Axis – put them inside Axis application tree (use standard places, WEB- INF/classes or WEB-INF/lib) –tell Axis about your web services: set mapping from web service names to class names Web Services Deployment Descriptor (WSDD) Tell Axis what methods should be exposed via the service

37 More Axis… Axis also provides you with an number of useful additional functions: –automatic generation of WSDL for the deployed web services –simplified deployment of web services via the.jws files: rename your.java files to.jws copy them into the root of the Axis application tree when the file is accessed, Axis will automatically compile it and convert SOAP calls correctly into Java invocations –automatic building of Java interfaces and classes for the given web service from its WSDL Please see Axis documentation for details!

38 Writing web services client Use SOAP client Java library provided by Axis: –create a Call object –set the URL for the web service –set the name of the operation to call –set types (and names) of input parameters and the return value –invoke the service Please see the detailed example in the lab!

39 Summary Moving from the human-centric Web of today to the application-centric Web of tomorrow – the Semantic Web Web services provide a mechanism for building interoperable Web applications Based on XML – provides semantic markup of data Service discovery and description: WSDL and UDDI Implementation technologies: Axis

40 More information… Questions


Download ppt "Distributed Web Systems Web Services Lecturer Department University."

Similar presentations


Ads by Google