Teaching Web Services and XML with the Water Language - PowerPoint PPT Presentation

1 / 54
About This Presentation
Title:

Teaching Web Services and XML with the Water Language

Description:

Query rental car Web services using an XML query generated based on the published interface. Receive the XML response from the rental car Web service. ... – PowerPoint PPT presentation

Number of Views:76
Avg rating:3.0/5.0
Slides: 55
Provided by: matthew99
Category:

less

Transcript and Presenter's Notes

Title: Teaching Web Services and XML with the Water Language


1
Teaching Web Services and XML with the Water
Language
  • Christopher Fry
  • Clear Methods, Inc.
  • Ed Gehringer and Matt Kendall
  • North Carolina State University

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
2
Agenda
  • Teaching Web services
  • Introduction to Water
  • ConciseXML
  • Things
  • Servers
  • Steam IDE
  • The Water object model

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
3
Introduction Web-services example
  • A new airline, Web Air, would like to add car
    rental services to their on-line ticket sales
    system.
  • The Web Air reservation system operates off of a
    database of flight information no knowledge of
    rental cars.
  • Web Airs ticket system must obtain rental data
    from rental car agencies.
  • What problems could Web Air encounter in gaining
    this information?

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
4
Introduction Web Air Problems
  • Rental companies may operate on different
    platforms. Example Mainframes vs. Linux
    clusters.
  • Individual rental companies may format rental car
    information differently. Example Using RGB
    values to indicate the color of a car, vs. using
    a string value.
  • Rental companies may use proprietary formats to
    store data. Example A binary format created for
    an individual company.
  • Access to the data may occur over antiquated or
    proprietary protocols. Example Using Solaris
    remote procedure calls to access the data.

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
5
Introduction Web Services
  • One way to simplify data sharing is to apply
    standards to interactions between the systems
    involved.
  • Web services use a set of standards to simplify
    machine-to-machine communications.
  • XML for both input and output.
  • Web Airs ticket system only needs to understand
    XML.
  • Gets XML data from vendors.

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
6
Web Services Interfaces
  • Standards require that the interface for each Web
    service be published.
  • The interface is a contract that specifies the
    available inputs, the formatting of outputs, and
    the protocols that the Web service employs to
    transmit data.
  • The protocols employed by Web services are
    Internet standards such as HTTP, FTP, and SMTP.

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
7
Web Services Interfaces (2)
  • Since inputs and outputs are well defined, Web
    Airs ticket system can
  • Query rental car Web services using an XML query
    generated based on the published interface.
  • Receive the XML response from the rental car Web
    service.
  • Use the known interface to translate the data
    from each rental car agency into a format that it
    can use internally.

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
8
Teaching Web services
  • Web services are hard to teach. Why?
  • Implementation is complex
  • SOAP
  • WSDL
  • Which platform? J2EE? .NET?
  • Syntax-to-concept mapping
  • The good (human language capacity)
  • The bad (lousy, non-uniform syntaxes)
  • The ugly (multiple incompatible languages)
  • How do we educate students about Web services,
  • Rather than train them in a specific technology?

9
Why Teach with Water?
  • Supports Web services natively.
  • So we are teaching the concepts.
  • Can return responses in XML, HTML, or SOAP
  • So we dont have to spend time on libraries.

10
Agenda
  • Teaching Web services
  • Introduction to Water
  • ConciseXML
  • Things
  • Servers
  • Steam IDE
  • The Water object model

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
11
Introduction to Water
  • Water (http//www.waterlanguage.org) is an open,
    all-purpose language designed for XML Web
    services.
  • It provides a simple yet powerful way of writing
    Web services by supporting XML within its core.

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
12
Introduction (2)
  • Without Water, XML is used on the
    "outside"programs are needed to convert into and
    out of XML.
  • Water is a language specifically designed for
    XML. It allows the option of using XML for
    everything presentation, logic, content,
    modeling, etc.

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
13
ConciseXML
  • XML is, by default, a very verbose method of
    representing data.
  • Water uses an extension of XML, ConciseXML, to
    reduce the amount of text required to represent
    data in XML.
  • All XML is valid ConciseXML, because ConciseXML
    is an extension.
  • Not all ConciseXML is valid XML.

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
14
ConciseXML Tag Shorthand
  • Closing tags can be notated as .
  • XML 1.0
  • Hello!
  • ConciseXML
  • Hello!

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
15
ConciseXML Positional Arguments
  • Water uses XML tags to make method calls with XML
    attributes as parameters.
  • Methods are predefined, there is no need to
    specify the attributes as keyvalue pairs.

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
16
ConciseXML Positional Arguments (2)
  • The key is simply omitted.
  • XML 1.0
  • ConciseXML

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
17
ConciseXML Path Notation
  • Representing nested logic is complex in XML.
  • ConciseXML simplifies nesting by supporting a dot
    notation.
  • "abe"..bar
  • ConciseXML is designed to allow XML to better
    represent data and logic by removing both
    verbosity and ambiguity from the language.

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
18
ConciseXML Path Notation (2)
  • XML 1.0
  • "abe"
  • bar
  • ConciseXML
  • "abe"..bar

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
19
Things
  • Like many object oriented languages, everything
    in Water is an object.
  • The most generic class in Water is a thing.
  • Objects in water have a set of properties, called
    fields.
  • We can create a thing without fields

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
20
Things (2)
  • Creates a thing with the fields shape and size.
  • ConciseXML does not require parameter names, but
    we have provided them here.
  • What happens when we execute the following Water
    code?

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
21
Things (3)
  • We can use the path notation provided by
    ConciseXML to select a specific field
  • A Point P
    /.z
  • What value does this code fragment return?
  • Notice that the message field in the above thing
    contains an object.
  • Also note that the objects tag has a body,
    i.e. it is not an empty tag, unlike the thing
    objects we have seen so far.
  • This means that Water can support seemingly
    unstructured content in the body of object tags.

-4
The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
22
Things (4)
  • Water applies a structure to the content of each
    tag.
  • A large object!.0
  • A large object!.1
  • A large object!.2
  • What will each statement return?

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
23
Servers
  • Methods are easy to define in Water.
  • This simple method returns a thing with the
    specified fields.
  • "bar"
  • Foo Bar!
  • /

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
24
Servers Executing a Method
  • We can create a server that will execute our
    method
  • We can execute this method by visiting
    http//localhost8000/?.
  • The question mark (?) is included because we want
    to execute .
  • What happens if we visit http//localhost8000
    without the question mark?

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
25
Servers Parameters
  • We can also provide required parameters in the
    request.
  • This Water program defines a method that
    has a required parameter x. Foo creates a thing
    with a field value that equals x.
  • What will happen if we execute http//localhost80
    00/?x42?

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
26
Servers Omitting a Parameter
  • What if we execute http//localhost8000/? now?
  • What about the message returned by the server
    reminds us of our previous studies of Web
    services?

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
27
Servers Calling from Programs
  • So far, all the services we have called have been
    invoked from a browser. It is also possible to
    call a Web service from a program.
  • This code snippet will execute the method
    with x"Hello World!
  • "http//localhost8000/"/
  • /

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
28
Servers Local Invocation
  • Of course, for local methods such as , we
    can also execute

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
29
Steam IDE
  • Water source files can be edited in any text
    editor, but the Steam IDE is designed to write
    Water programs.
  • Code is executed by highlighting a statement and
    pressing the execute button.
  • Once code is executed, its effects remain in the
    environment until they are changed by a later
    execution.

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
30
Steam IDE (2)
  • Execution One /
  • The variable myvar is assigned the object.
  • If at a later time you execute
  • The value of myvar is retained from the previous
    execution.
  • This retention of the environment allows for
    rapid, iterative development.

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
31
Steam IDE (3)
  • Objects can be inspected by double-clicking on
    their name in the editing pane.

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
32
Agenda
  • Teaching Web services
  • Introduction to Water
  • ConciseXML
  • Things
  • Servers
  • Steam IDE
  • The Water object model

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
33
The Water object model
  • The Water object model is simple, yet extremely
    powerful. It can be described in four
    statements.
  • Everything is an object.
  • An object has fields.
  • Each field has a key and a value.
  • The key and value can be any object.

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
34
An Object
  • Consider this object
  • 10 20/ /
  • How many fields does it have?
  • What are the keys?
  • What are the values?

4
a, s, d
2.7, 343, "This is a string",

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
35
Classes Methods
  • Recall that Web services must publish a well
    defined interface, or contract, that defines
    their inputs and outputs.
  • Water contracts are based on class and method
    definitions.
  • Classes are created using and methods
    are created using .

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
36
Classes Methods Classes
  • We can easily create a class in Water
  • This expression defines a class called
    that has two fields one and two.

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
37
Classes Methods Classes (2)
  • We can create new instances of .
  • What is the only requirement of this myclass
    contract?
  • 1/
  • null /

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
38
Classes Methods Classes (3)
  • We can further define the contract by supplying
    each field with a type.
  • now expects to receive a number for
    field one and a string for field two.
  • tworequiredstring/

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
39
Classes Methods Classes (5)
  • What are the values of one and two for each of
    the following statements?

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
40
Classes Methods Classes (6)
  • So far, we have created instances of classes but
    we have not saved them.
  • You can store an instance into a variable
  • /

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
41
Classes Methods Methods
  • Method definitions are similar to class
    definitions.
  • "bar"
  • Method parameters use all of the same contracts
    as class parameters.
  • "bar"

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
42
Classes Methods Methods (2)
  • The value of the last statement executed in a
    method is the value returned by the method.
  • Methods can specify their return type
  • _return_typestring
  • x.
  • This method concatenates the string supplied for
    x with the string literal "-bar".

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
43
Classes Methods Methods (3)
  • Methods can be declared as members of a class.
  • What is the purpose of _subject in this code?
  • _subject.

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
44
Classes Methods Methods (4)
  • It is also possible to assign methods outside of
    the class definition.
  • If a method is defined outside of a class, we
    have the option of assigning it to a class.
  • What class is the method accessible from if we do
    not explicitly assign it to a class?
  • person.
  • _subject.

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
45
Classes Methods Methods (5)
  • For example, from what classes could the
    following method be invoked from?
  • _subject.._subject.. /
  • What does this method do?

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
46
Classes Methods Invoking 1
  • In Water, a call is either a method call or a
    constructor call. The syntax is the same.
  • In the following example, the first line creates
    a method named foo_method.
  • The second line calls the method with the
    argument x"test". The method call executes the
    method implementation and returns the result.
  • x
  • What is the result of the above execution?

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
47
Classes Methods Invoking (2)
  • You can also invoke a method on a subject
  • _subject.
  • thing.
  • thing.tag

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
48
Classes Methods Invoking (3)
  • Or, you can declare a method as a member of a
    specific class (instead of thing) and invoke it
    on the owning class and its subclasses
  • _subject.
  • /
  • a_game.
  • a_game.tag

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
49
Classes Methods Creating
  • Now consider the following example of creating an
    object instance
  • Notice the identical structure between this
    instance creation and invoking a method without a
    target. In this example
  • The first line creates a class object named
    foo_object.
  • The second line calls the default initialization
    constructor (the init method) for foo_object with
    an argument x"test".
  • The constructor call executes the init method,
    which returns the new instance.

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
50
Classes Methods Creating (2)
  • The init method is Waters version of a
    constructor. We can override the init method to
    perform tasks during object creation.
  • What does _new_object contain?
  • The student class maintains a field called peers.
    student.peers is a that is initially
    empty, it has no fields.
  • When a new student is created, it is added to the
    peers object as a new field. The key of the
    field is the value of student.id. The value is
    the student object itself.
  • Browse to http//localhost to see the results
  • student. /
  • student.peers._new_object/
  • _new_object

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
51
Classes Methods Creating (3)
  • We have created new instances using local Water
    expressions, but remember that we can also create
    new objects based on URLs. For example,
  • http//localhost/student?id400nameTom
  • is identical to

The Water Logo is trademark 2001-2005 by Clear
Methods, Inc.
52
Is Water Easy to Learn?
Overall score Java 58, Water 33, Smalltalk 28
53
Is Water Perceived to Be Useful?
  • Overall score Java 58, Water 40, Smalltalk 25

54
Summary
  • Web services are rapidly growing in importance.
  • Water is a good way to learn Web services.
  • It is concise.
  • Small Web services can be written in a few lines
    of code.
  • One can concentrate on the concepts, not the
    implementation.
Write a Comment
User Comments (0)
About PowerShow.com