Title: XML and Web Services
1XML and Web Services
2Client/Server Recap
- Web services are a client/server technology
- Usually implemented on top of HTTP
- This makes it easy to deploy and maintain web
services
3Remote Procedure Calls (RPC)
- Popularized by Sun
- C/C development (now other languages)
- Allows remote clients to run functions on server
- Server publishes specification of available
functions - See also
- Remote Method Invocation (RMI)
- Common Object Request Broker Architecture (CORBA)
4RPC Example
- Stock market application
- Client wants to inquire on stock price
- Server has a RPC function
- float stock_price(stockName)
- Client calls server function and server returns
the current stock price
5RPC Issues
- What if the function is changed to include a time
parameter? - Client and server must recompile
- What if different computers store floating point
numbers differently? - Need to translate to a common representation
6XML
- eXtensible Markup Language
- Subset of SGML (Standard Generalized Markup
Language) - Well-formed
- Self describing
- Platform independent
- Widely supported in modern programming languages
(Java, C, Python, Perl, PHP, JavaScript)
7HTML Example
- Tags enclosed in lt and gt
- End tags enclosed in lt/ and gt
- Attributes take the form namevalue
- Notice the ltbrgt tag does not have a matching end
tag
lttablegtlttrgt lttd width"100"gt ltp
align"center"gt ltbgtltspangtComS
nbsp486Xlt/spangt ltspangtlt/spangtlt/bgt
ltspangt ltbrgtSpring 2006 lt/spangt
lt/tdgt lt/trgtlt/tablegt
8XML vs. HTML
- As shown, XML and HTML are incompatible
- HTML is not well-formed
- XML requires that all tags have a matching end
tag - To solve this problem a XML compatible version of
HTML was developed XHTML
9XHTML Example
- The ltbrgt tag now has a matching lt/brgt tag
- This snippet is now well-formed XHTML
- The difference is minor, but illustrates a
critical XML property
lttablegtlttrgt lttd width"100"gt ltp
align"center"gt ltbgtltspangtComS
nbsp486Xlt/spangt ltspangtlt/spangtlt/bgt
ltspangt ltbrgtlt/brgt Spring 2006 lt/spangt
lt/tdgt lt/trgtlt/tablegt
10Document Type Definition (DTD)
- Each XML schema has a DTD (or a XSD, not covered
today) - DTDs can be published or included in an XML
document - This is the key to XMLs self-describing property
- Anyone can create a DTD thus defining a new type
of XML
11XHTML DTD1 Example
- ELEMENT and ATTRIBUTE tags define the tags and
properties of the HTML - Ironically, DTDs are not well-formed
- XSD solves this
lt!ELEMENT table (tbodytr))gt lt!ELEMENT
tbody (tr)gt lt!ELEMENT tr (thtd)gt lt!ELEMENT th
Flowgt lt!ELEMENT td Flowgt lt!ATTLIST table
attrs summary Text IMPLIED
width Length IMPLIED cellspacing
Length IMPLIED gt
1. http//www.w3.org/TR/xhtml1/DTD/xhtml1-strict.d
td
12So far
- We have discussed
- Client/server
- RPC
- XML
- How does this relate to web services?
- First we need to answer what is a web service?
13Web Services
- From Wikipedia
- According to the W3C a Web service is a software
system designed to support interoperable
machine-to-machine interaction over a network. It
has an interface that is described in a
machine-processable format such as WSDL. Other
systems interact with the Web service in a manner
prescribed by its interface using messages, which
may be enclosed in a SOAP envelope, or follow a
REST approach. These messages are typically
conveyed using HTTP, and normally comprise XML in
conjunction with other Web-related standards.
14Web Services (2)
- interoperable machine-to-machine interaction
over a network - This is no different from the alternatives (RPC,
etc) - an interface that is described in a
machine-processable format - This is important in that it does not restrict
web services in terms of software, unlike RPC, etc
15Web Services (3)
- systems interact with the Web service in a
manner prescribed by its interface using
messages - The interface is published and also
self-describing - messages are typically conveyed using HTTP, and
normally comprise XML - These two points really differentiate web
services from RPC, etc
16Miscellaneous Jargon
- WSDL Web Service Definition language
- Defines the interface
- Developer tools can auto-generate code templates
from this (Eclipse extensions, Visual Studio) - SOAP Simple Object Access Protocol
- XML protocol for messaging in web services
- Becoming widely supported
- Supports complex operations, data types, binary
attachments, etc
17Web Service Example
- Google API
- http//www.google.com/apis/
- Allows Google search to be incorporated in
programs - Without web services this becomes a very hard
task - Includes WSDL and coding examples for Java and
.Net - Free but must sign up for the service
- Only so many searches per day
18Summary
- Web services are about exchanging structured data
between remote hosts in a platform independent
manner - Wide range of applications
- Semantic web
- Further study
- Look into SOAP, WSDL
- Tinker with Eclipses web service extensions