(1)CST6445: Web Services
Development with Java and XML
Lesson 1 Introduction To Web
Services
(2)Opening Night
§
Course Overview
§
Perspective
§
Business Case
§
Technology
§
Development
§
Summary
§
References
(3)Session 1
Introduction To Web Services
Session 2
Processing XML (Part 1)
Session 3
Processing XML (Part 2)
Session 4
Web Service Interaction (Part 1)
Session 5
Web Service Interaction (Part 2)
Session 6
Web Services Workshop
Session 7
Standards
Lecture 1
Architecture
XML
JWSDP
Lab 1
Web Service Deployment
Lecture 2
XML DTD
JAXP SAX
Lab 2
Parsing XML SAX
Lecture 3
XML Schema
JAXP DOM
Lab 3
Parsing XML DOM
Lecture 4
XSLT
SOAP
SAAJ API
Lab 4
SAAJ
Lecture 5
UDDI
WSDL
JAXR
JAXRPC
Lab 5
JAXRPC Services
Lecture 6
Workshop Goals
Lab 6
Develop/Deploy Web Service
Lecture 7
Web Service Standards
Course Summary
Lab 7
Workshop Evaluation
Required Text :J2EE Platform Web Services
Ray Lai Prentice Hall
Recommended Text Building Web Services with Java:
Making Sense of XML, SOAP, WSDL, and UDDI (2nd Edition)
Labs – 50%
Final – 50%
Final Exam
CST6445 Course Overview
(4)What is a Web Service?
§
Used primarily as a means for businesses to
communicate with each other and with
clients, Web services allow organizations to
communicate data without intimate
knowledge of each other's IT systems
behind the firewall.
§
Web services do not provide the user with a
GUI Web services instead share business
logic, data and processes through a
programmatic interface across a network.
(5)What is a Web Service?
§
Web services describes a standardized way
of integrating applications (or some
functionality of an app) using open
standards such as XML, SOAP, WSDL and
UDDI over an Internet Protocol backbone.
§
Communicating data in standardized way.
Web
Service
Consumer
Web
Service
Producer
(6)What is a Web Service?
§
The W3C defines a Web service as a
software system designed to support
interoperable machinetomachine
(7)Perspective: Overview
§
Good deal of hype and promise to
solve the needs of business with a
single all encompassing solution.
§
In reality, we know this to be a
natural occurrence while things are
evolving.
§
However, there are technologies and
practices we can use today that
mitigate risk and solve both short and
long term business goals.
(8)Perspective: Business Relevance
§
Primary goals of any business are to
solve information delivery problems
to achieve a high degree of customer
satisfaction and improve crucial
business processes.
§
There is a definite trend away from
proprietary point to point and rich
client interfaces.
§
Web Services are becoming the de
facto approach to implementing B2C
and B2Bi.
(9)Perspective: Industry Trends
§
“White label” services
§
Post bubble economics
§
Broadband availability
§
Destructive client technology
§
Mobile clients
§
Customer Expectations
§
Standards for interoperability
§
Platforms and frameworks
(10)Perspective: Why Web Services?
§
Internet and pervasiveness of the WWW.
§
Customer experience.
§
Interoperability standards.
§
Patterns and tools for accessing legacy
information systems.
§
IT and development costs.
§
Quality of service “ilities”. (e.g. scalabilty, availabilty)
§
Language and platform independence.
(11)Perspective: Why Web Services?
§
Technology enabler for legacy
systems integration and cross
platform interoperability.
§
Proliferation of XML, Java technology
and B2B
§
Business drivers
• Cost reduction
• B2B integration
• Time to market
• Legacy systems and mainframe integration
(12)Perspective: Why Web Services?
§
Technology drivers
• Single, common framework for many business
services and business partners
• Loose coupling with stable interfaces and
common code base
• Industry wide support in application servers
and middleware vendors: Sun, IBM, Microsoft
and BEA.
• Addresses data silos and restrictive ERP
architectures
• Mitigates risk from obsolete technology
(13)Business Case: Analysis
§
Web Services implementation should
consider the need to aggregate
business information from existing
monolithic business services.
§
Is there a requirement for a business
process engine to perform this
aggregation into meaningful business
information and customer services?
§
What are the characteristics?
(14)Business Case: Characteristics
§
Trading Partners
• More than one?
• Need to interoperate with backend legacy
systems and heterogeneous platforms?
§
Reusability
• No reuse? Don’t bother.
§
Branding
• Integrating two different services may need to
accommodate different constraints.
(15)Business Case: Characteristics
(cont’d)
§
Technology Constraints
• Backend business services will “never” be re
engineered.
• Need to coexist and leverage existing services.
§
Limited Delivery Time Window
• Must be easy and quick to deploy.
• Must support different protocols and message
formats.
• Support for a variety of industry standards
and platforms.
(16)Business Case: Benefits
§
Interoperability
• Low cost tool to meet time to market.
• Crossplatform and legacy systems
integration.
§
Reusability and Maintainability
• Business services exposed as Web Services.
• Service calls and interface easy to maintain.
§
ROI
• Deployable within weeks or months.
• Lower costs of integration and maintenance.
(17)Technology: Definition
§
Web services are units of business
services, applications, or system
functionality that can be accessible
over an IP network.
§
Web Services can enable legacy
system functionality to be exposed as
a reusable business service without
rewriting it.
§
Web services technology can be used
as a crosssystem or crossenterprise
integration.
(18)Technology: Components
§
Web services are units of business
services, applications, or system
functionality that can be accessible
over an IP network.
§
XML is the enabling technology on
which these are built.
§
SOAP and HTTP provide transport.
§
WSDL provides service description.
§
UDDI provides service registration.
§
J2EE provides the APIs.
(19)Technology: Components
§
Web services describes a standardized way
of integrating applications (or some
functionality of an app) using open
standards such as XML, SOAP, WSDL and
UDDI over an Internet Protocol backbone.
§
Communicating data in standardized way.
Web
Service
Consumer
Web
Service
Producer
(20)Technology: Actors
§
Service Provider
• Runs business services
• Defines, registers and publishes
§
Service Broker
• Defines, register and publishes on behalf of
Service Providers
§
Service Consumer
• Locates business services
• Retrieves and binds
(21)Service Oriented Architecture
§
With the trio of
• Service Provider
• Service Broker
• Service Consumer
we have the foundation for a Service Oriented
Architecture.
By the end of the course you will have a better
understanding of Web Services and will be
able to understand SOA.
(22)(23)Technology: XML
§
Markup language like HTML
§
Like SGML – used to define new grammars.
§
Semantics VS Presentation of data unlike
HTML
§
A language for describing Web application
languages/protocols
§
Describes data and/or process
§
Fundamental for Web service interactions
§
Global namespace support facilitates
standard service protocols (e.g. SOAP)
(24)Technology: XML Document
§
Representing Data
<customer>
<name>John Smith</name>
<address type=“billing”>
123 Anonymous St.
Someplace, Somewhere
</address>
<credit>
<type>VISA</type>
<number>99999999999</number>
<expiry>31/12/2003</expiry>
</credit>
</customer>
(25)Technology: XML Document
§
Representing Process
<method>
<name>GetCustomer</name>
<arg>
<name>CustomerName</name>
<value>John Smith</value>
</arg>
<arg>
<name>GetCreditInfo</name>
<value>true</value>
</arg>
</method>
(26)Technology: XML Document
§
Elements
• Encapsulate data or child elements
• Well formed: must have a matching end element or
element denoting no content (empty element):
• <starttag> some content </endtag>
• < selfclosingtag />
§
Attributes
• Additional information specific to an element
• Attribute data must be contained in quotes
• < starttag attribute=“attribute data”>…</ starttag
>
(27)Technology: XML Document
§
Processing Instructions
• XML processor directives
• <?target instructions?>
• Can be used to include code fragments
• <?xml … ?> reserved for XML standards
§
Character data
• Data between tags and in attributes
• Special notation can be used to pass data
through unprocessed.
§
<! This is a comment >
(28)Technology: XML Document
§
Plain text method for describing and
identifying data
§
Can be styled according to application
defined rules
§
Document inclusion, reuse and
standardization
§
Easily processed
• Well formedness rules
• Hierarchical representation
(29)Technology: XML Document
§
XML document consists of:
• Declarations and definitions
• Elements and attributes
• Processing instructions
• Character data and comments
§
Definitions section identifies element
and attribute names and declares
constants
§
Element and attribute names are
defined by application requirements
(30)Technology: XML DTD
§
Declarations and Definitions – DTD
• Document Type Definition
§
DTD is used for document validation
§
ELEMENT, ATTRIBUTE and ENTITY
declarations
§
Defines element relationships
• Parentchild, multiple occurrences
§
Entities are like constants
• &; is an entity declaration in the DTD for
XML
(31)Technology: XML XSD
§
XML Schema Definition (XSD)
§
Used for document validation
§
XML document
§
More concise description of document
structure
§
Strong typing and constraint
definition
§
Reuse and “object” definitions
(32)Technology: Some Terminology
§
URI
• Uniform Resource Identifier
§
URL
• Uniform Resource Locater
• defines how to locate a resource
§
URN
• Uniform Resource Name
• Tells something about a resource – the name
§
A URI is defined to be a locater, a
name or both. It is the more general
term.
(33)Technology: XML Namespaces
§
Namespaces
§
Differentiates elements with the same name
§
Addresses conflicting name issues when
exchanging documents with partners
§
xmlns=“URI” sets the default namespace
for elements and attributes
§
xmlns:PFI=“URI” sets the namespace for
elements prefixed with PID
• <PFI:name>...</PFI:name>
(34)Technology: XML Parsers
§
Parsers
§
SAX
• Simple API for XML processing
• event driven
§
DOM
• Document Object Model
• Hierarchy of elements
(35)Technology: XML
§
Many standards:
• SAX, DOM, OO models (JDOM, dom4j)
• DTD, XML Schema
• Namespaces
• XSL (XSLT, XPath, XSLFO), Xlink
• XHTML
• RDF, ebXML, WSDL, UDDI, SOAP
§
Many more to come …
• Thanks to an open and flexible specification
(36)Technology: J2EE APIs
§
JAXP
• Processing XML documents
§
JAXM
• Messaging with XML documents (SOAP)
§
JAXRPC
• Remote Procedure Calls with XML (SOAP)
§
JAXR
• Accessing Web service registries with XML
(37)Development: Programming
Details
§
Factory Design Pattern
§
Tree Structures
§
AttributeValue pairs
§
Event driven programs
(38)Development: Factory Design
Pattern
§
A helper class (factory) that
instantiates (produces) objects on
behalf of another object
§
Hides or abstracts implementation
details
§
Typically produces Interface types
§
Underlying concrete class can be
associated with the factory through a
java system property
§
This is the case for the XML
processors
(39)Development: Factory Design
Pattern
§
Typically a program must first get an
instance of a factory using a static
factory method
• FactoryClass.newInstance()
• FactoryClass.getInstance()
§
Factory classes are usually abstract
• FactoryClass.newInstance() returns a concrete
implementation of the abstract class
§
javax.xml.parsers.SAXParserFactory
(40)Development: Tree Structures
§
XML documents can be modeled using
a hierarchical (tree) data structure
§
Each node in the tree (regardless of
type) has a parent node and zero or
more child nodes
• The root node has no parent
• A node with no children is a leaf node
§
Access methods are provided to move
around in the tree structure
(41)Development: Tree Structures
§
Any node in the tree presents a
uniform view no matter what data is
contained or represented by the node
§
An interface or abstract class is used
to define the node contract
public interface TreeNode
{
TreeNode getParent();
void setParent(TreeNode);
TreeNode [] getChildren();
void addChild(TreeNode childNode);
void setNodeData(Object nodeData);
Object getNodeData();
}
(42)Development: Tree Structures
§
Recursion is often used to evaluate
trees
int countChildNodes(TreeNode startNode) {
int count = 0;
if ( startNode != null ) {
TreeNode children[] = startNode.getChildren();
count = children.length;
for(int i= 0; i < children.length; i++ ) {
count += countChildNodes(children[i]);
}
}
return count;
}
§
org.w3c.dom.Node
(43)Development: AttributeValue
Pairs
§
Names associated with values
• type="ordered"
• font="Arial"
• name="value"
§
Maps are data structures used to associate
one object with another object
• Hashtable, HashMap in java.util
§
String => String models attributevalue
pairs
• org.w3c.dom.NamedNodeMap
(44)Development: Event Driven
Programs
§
Event listener objects
• events classes and listener interfaces are
defined by an API
• java.awt.event.ActionEvent
• java.awt.event.ActionListener
§
Listener interface implementations
define the callback methods used by
the API to notify
§
Events are stream oriented
§
org.xml.sax.ContentHandler
(45)Summary
§
Web services are units of business
services, applications, or system
functionality that can be accessible
over the Web.
§
Web services technology provides
interoperability and integration
solutions while mitigating risk.
(46)Summary
§
XML is the technology enabler.
§
SOAP and HTTP provide transport
services.
§
WSDL provides service binding.
§
UDDI provides discovery and
retrieval.
§
J2EE provides the APIs.
(47)References
§
W3C – World Wide Web Consortium
• XML standards
• http://www.w3.org/
§
Sun Microsystems
• J2EE 1.4 Tutorial
• http://java.sun.com/j2ee/1.4/docs/tutorial/doc/index.ht
ml
§
J2EE Platform Web Services
• Ray Lai, Sun Microsystems Press, ISBN 0131014021
§
Wikipedia