IT8074 - Service Oriented Architecture
IT8074 - Service Oriented Architecture
Service Oriented
Architecture
Pranjali Deshpande
M.E. (Comp. Engg.), Ph.D (Pursuing), DoT, SPPU.
Assistant Professor,Department of Computer Engineering,
MKSSS's Cummins College of Engineering for Women,
Pune
Soudamini Patil
M.E. (Computer Science and Engineering)
Formerly Assistant Professor,
Department of Computer Engineering,
MKSSS's Cummins College of Engineering for Women,
Pune
® ®
TECHNICAL
PUBLICATIONS
SINCE 1993 An Up-Thrust for Knowledge
(i)
Service Oriented Architecture
Subject Code : IT8074
Published by :
® ®
Amit Residency, Office No.1, 412, Shaniwar Peth,
TECHNICAL Pune - 411030, M.S. INDIA, Ph.: +91-020-24495496/97
PUBLICATIONS
SINCE 1993 An Up-Thrust for Knowledge Email : [email protected] Website : www.technicalpublications.org
Printer :
Yogiraj Printers & Binders
Sr.No. 10/1A,
Ghule Industrial Estate, Nanded Village Road,
Tal. - Haveli, Dist. - Pune - 411041.
ISBN 978-93-90041-48-0
9 789390 041480 AU 17
Authors
Pranjali Deshpande
Soudamini Patil
Dedicated to God.
(iii)
Syllabus
Service Oriented Architecture - IT8074
UNIT - I XML
XML document structure - Well-formed and valid documents - DTD - XML Schema - Parsing XML
using DOM, SAX - XPath - XML Transformation and XSL - Xquery. (Chapter - 1)
(iv)
Table of Contents
Unit - I
1.1 Introduction....................................................................................................... 1 - 2
1.2 XML Document Structure .................................................................................. 1 - 7
1.3 Well-formed and Valid DSocuments ............................................................... 1 - 11
1.4 DTD .................................................................................................................. 1 - 13
1.5 XML Schema .................................................................................................... 1 - 19
1.6 Parsing XML using DOM, SAX, XPATH ............................................................. 1 - 32
1.7 XML Transformation & XSL ............................................................................. 1 - 44
1.8 XQuery ............................................................................................................. 1 - 50
Unit - II
(2 - 1) to (2 - 48)
2.1 Introduction....................................................................................................... 2 - 2
2.2 Characteristics of SOA ..................................................................................... 2 - 13
2.3 Benefits of SOA................................................................................................ 2 - 28
2.4 Comparing SOA with Client-Server & Distributed Architectures .................... 2 - 33
2.5 Principles of Service Orientation ..................................................................... 2 - 42
2.6 Service Layers .................................................................................................. 2 - 43
Unit - III
(v)
3.2 Service Descriptions (with WSDL) ..................................................................... 3 - 5
3.3 Messaging with SOAP ........................................................................................ 3 - 9
3.4 Service Discovery and Description Advertisement ......................................... 3 - 13
3.5 Orchestration .................................................................................................. 3 - 16
Unit - IV
(vi)
4.5 WS-Transactions .............................................................................................. 4 - 21
4.5.1 Atomic Transaction Protocols ........................................................................... 4 - 22
4.5.2 The Atomic Transaction Coordinator ................................................................ 4 - 22
4.5.3 The Atomic Transaction Process ....................................................................... 4 - 23
4.5.4 Atomic Transaction and SOA ............................................................................. 4 - 24
4.6 WS-Security ..................................................................................................... 4 - 24
4.6.1 Identification, Authentication and Authorization ............................................. 4 - 25
4.6.2 Single Sign On .................................................................................................... 4 - 26
4.6.3 Confidentiality and Integrity ............................................................................. 4 - 26
4.6.4 Transport-Level Security and Message Level Security ...................................... 4 - 28
4.6.5 Encryption and Digital Signatures ..................................................................... 4 - 28
4.6.6 Security and SOA ............................................................................................... 4 - 29
Unit - V
(vii)
Notes
(viii)
UNIT - I
1 XML
Syllabus
XML document structure - Well-formed and valid documents - DTD - XML Schema -
ParsingXML using DOM, SAX - XPath - XML Transformation and XSL – Xquery.
Contents
1.1. Introduction
1.2 XML Document Structure
1.3 Well-formed and Valid Documents
1.4 DTD
1.5 XML Schema
1.6 Parsing XML using DOM, SAX, XPATH
1.7 XML Transformation & XSL
1.8 XQuery
(1 - 1)
Service Oriented Architecture 1-2 XML
1.1 Introduction
Using XML eliminates the challenge of working with different data formats in
different applications across multiple platforms.
XML has the benefit of ease of representation, being text-based, flexible, and
extensible by nature.
What is XML ?
eXtensible Mark-up Language (popularly known as XML) is a software - and
hardware-independent tool for storing and transporting data.
XML is a mark-up language, which is mainly used to represent the structured data.
Structured data is the one which contains the data along with the tag / label to
indicate what is that data.
It is like a data with tag as a column name in RDBMS. One may think why we need
to XML rather than simply documenting the data with simple tags. In short -
o XML is a mark-up language much like HTML.
o XML was designed to store and transport data.
o XML was designed to be self-descriptive.
o XML was designed to be both human- and machine-readable.
o XML is a W3C Recommendation.
Although the XML and HTML both are mark-up languages used in web
technologies, there are some key difference between XML and HTML. These are -
o XML and HTML were designed with different goals.
o XML was designed to carry data - with focus on what data is.
o HTML was designed to display data - with focus on how data looks.
o XML tags are not predefined like HTML tags.
</note> <from>Tanu</from>
<note> <heading>Message</heading>
<to>Shyam</to> <body>Eat your lunch on time</body>
<from>Jaya</from> </note>
<heading>Alert</heading> </notebook>
<body>Tomorrow is medicine day</body>
</note>
XML file can be generated using special editors as well as with very simple editors
like notepad (on windows) or gedit (on Linux and equivalents). Refer Fig. 1.1.3
XML files are normally used in the web applications. Hence browser applications
like Google Chrome, Firefox or Internet Explorer can be used to view the file. Refer
Fig. 1.1.4 below to see how xml file looks when opened in the browser.
Advantages of XML
In XML document, the presence of the tags makes the message self-documenting;
that is, a schema need not be consulted to understand the meaning of the text.
The format of the document is not rigid. The tag is required for items that are
ordered by weight or volume, and may be omitted for items that are simply ordered
by number.
The ability to recognize and ignore unexpected tags allows the format of the data to
evolve over time, without invalidating existing applications.
Similarly, the ability to have multiple occurrences of the same tag makes it easy to
represent multivalued attributes.
XML allows nested structures. Such information would have been split into
multiple relations in a relational schema.
Since the XML format is widely accepted, a wide variety of tools are available to
assist in its processing, including programming language APIs to create and to read
XML data, browser software, and database tools.
o Scientific measurements
o News information
o Weather services
The syntax rules of XML are very simple and logical. Every XML document has -
o Elements - These are the user defined XML tags. For example : <note> </note>.
The Element can hold information in following forms.
An element can contain :
Nothing • Text
Attributes • Other Elements
Or a mix of all the above
o Empty Element - When nothing is written inside <ELEMENT>
</ELEMENT>, it is treated as an empty element.
It can also be referred as self-closing tag <ELEMENT/>
Empty elements can have attributes. Refer Element Attributes section in
the later part.
o Element Text - It is the string data held inside the <ELEMENT>
</ELEMENT>. For example :
<heading>Reminder</heading>. In this example Reminder is the Text data.
<cost> 200 </cost>. Here 200 is the Text data.
o Element Attributes -
Like HTML, XML elements can have attributes.
e.g. <cost currency=”USD”> 200 </cost>
In this example, currency is an attribute of cost and attribute value is USD
Attributes are always in name - value pair
Attributes are designed to contain data (called as value) related to a
specific element.
Attribute values must be enclosed inside single or double quotes.
Attribute values can use character strings or entities supported by xml
encoding.
There are various types of XML encodings available. E.g.
Unicode/ISO-10646 encodings (UTF-8, UTF-16, ISO-10646-UCS-2,
and ISO-10646-UCS-4)
8-bit Latin character encodings (ISO-8859-1 and ISO-8859-2 )
XML Relations - Every element in the XML file has following type of possible
relations as -
o Root - XML Documents Must Have a Root Element. The highest level element
in the valid XML file is the root element.
o Parent - One element can be a parent of another element. A parent node
encloses all its child elements.
o Child - Every XML element enclosed inside another XML element is a child
element.
o Sibling - Sibling elements are children elements on the same level or Sibling
elements are those XML elements that have same parent element.
XML documents are formed as element trees.
An XML tree starts at a root element and branches from the root to child elements.
All elements can have sub elements (child elements).
The terms parent, child, and sibling are used to describe the relationships between
elements.
Parents have children. Children have parents. Siblings are children on the same
level.
XML DOM Properties - There are some typical DOM properties, if x is a node object,
then,
x.nodeName - the name of x
x.nodeValue - the value of x
XML DOM Methods - There are some typical DOM methods, if x is a node object, then
x.getElementsByTagName(name) - get all elements with a specified tag name
x.appendChild(node) - insert a child node to x
x.removeChild(node) - remove a child node from x
Camel case <postalCode> Uppercase first letter in each word except the first.
<notebook>
<note>
<to>Jaya</to>
<from>Seeta</from>
<heading>Reminder</heading>
<body>Don't forget to meet me this weekend!</body>
</note>
<note>
<to>Shyam</to>
<from>Jaya</from>
<heading>Alert</heading>
<body>Tomorrow is medicine day</body>
</note>
<note>
<to>Renu</to>
<from>Rama</from>
<heading>Alert</heading>
<body>Petrol level went down</body>
</note>
<note>
<to>Rama</to>
<from>Tanu</from>
<heading>Message</heading>
<body>Eat your lunch on time</body>
</note>
</notebook>
ENTITY
o In a Document Type Definition (DTD) an attributes type can be set to be
ENTITY.
o For a value to be a valid ENTITY the following must be true.
o It must conform to the EBNF for "Name". In simple terms this means a "Name"
has to start with a letter or ':' or '_'. The rest of the characters must be numbers,
letters ':', '_', '-', or '.' it can not contain any spaces.
o The value of the ENTITY attribute also has to match an ENTITY that has been
declared elsewhere within the DTD.
o Declaring an ENTITY Attribute in a DTD
<!ELEMENT MyElement EMPTY>
<!ATTLIST MyElement myEntityTest ENTITY #REQUIRED>
<!ENTITY myEntityA "Some Entity Value A">
<!ENTITY myEntityB "Some Entity Value B">
o Sample XML
<MyElement myEntityTest="myEntityA"/>
ID
o In a Document Type Definition (DTD) an attributes type can be set to be ID.
o For a value to be a valid ID the following must be true.
o It must conform to the EBNF for "Name". In simple terms this means a "Name"
has to start with a letter or ':' or '_'. The rest of the characters must be numbers,
letters ':', '_', '-', or '.' it can not contain any spaces.
o It must be unique across all the ID values declared within the XML Document.
o An element may only have a single ID value declared against it.
o An attribute declared of type ID must be defined as either #IMPLIED or
#REQUIRED.
o Declaring an IDREF Attribute in a DTD.
<!ELEMENT artist EMPTY>
<!ATTLIST artist name CDATA #REQUIRED>
<!ATTLIST artist artistID ID #REQUIRED>
<!ELEMENT album EMPTY>
<!ATTLIST album name CDATA #REQUIRED>
<!ATTLIST album albumArtistID IDREF #IMPLIED>
<!ATTLIST album contributingArtistIDs IDREFS #IMPLIED>
o Sample XML
<artist name="Nick Cave" artistID="NC"/>
<artist name="Kylie Minogue" artistID="KM"/>
<artist name="PJ Harvey" artistID="PJH"/>
<artist name="Shane MacGowan" artistID="SM"/>
<album name="Murder Ballads" albumArtistID="NC" contributingArtistIDs="KM PJH
SM"/>
IDREF
o In a Document Type Definition (DTD) an attributes type can be set to be
IDREF.
o For a value to be a valid IDREF the following must be true.
o It must conform to the EBNF for "Name". In simple terms this means a "Name"
has to start with a letter or ':' or '_'. The rest of the characters must be numbers,
letters ':', '_', '-', or '.' it can not contain any spaces.
o The value of the IDREF attribute has to match an ID value defined elsewhere
within the XML Document.
o Declaring an IDREF Attribute in a DTD
<!ELEMENT artist EMPTY>
<!ATTLIST artist name CDATA #REQUIRED>
<!ATTLIST artist artistID ID #REQUIRED>
<!ELEMENT album EMPTY>
<!ATTLIST album name CDATA #REQUIRED>
<!ATTLIST album albumArtistID IDREF #IMPLIED>
o Sample XML
<artist name="Nick Cave" artistID="NC"/>
<album name="Murder Ballads" albumArtistID="NC"/>
NMTOKEN
o In a Document Type Definition (DTD) an attributes type can be set to be
NMTOKEN (name token).
o For a value to be a valid NMTOKEN the following must be true:-
o It must conform to the EBNF for "Nmtoken". In simple terms it can contain
numbers letters, and ':', '_', '-', or '.' it can not contain spaces or whitespace.
o Declaring an IDREF Attribute in a DTD
<!ELEMENT invoice EMPTY>
<!ATTLIST invoice invoiceID NMTOKEN #REQUIRED>
o Sample XML
<invoice invoiceID="45684"/>
PCDATA
o In a Document Type Definition (DTD) an element can contain #PCDATA.
o PCDATA in this context means mixed content, elements may contain
character data, optionally interspersed with child elements.
o Sample PCDATA Usage within a DTD.
<!ELEMENT b (#PCDATA)>
o Sample XML
<b>character data</b>
o The element b may contain character data, and nothing else.
o If used correctly in conjunction with other element types it can allow the
element to contain mixed content.
o Sample PCDATA Usage within a DTD
<!ELEMENT c (#PCDATA|d|e)*>
o Sample XML
<c>character data <d/> more text <d/> and more <e/></c>
o However PCDATA is not the semantic term for character data, and must
appear as the first item within a 0-n choice.
A choice between independent DTD and In-line DTD -
In-line DTD is easy to write and interpret. However, it is suitable only for the small
size XML files.
In-line DTD exposes the structure of Data within the XML file. Hence it is
vulnerable to security attacks.
The independent DTD is useful for large applications as it provides data and data
definition separately.
The independent DTD is suitable when the data in XML file is large in size.
As data and definition are in the separate files, the modifiability of both is easy, in
case of independent DTD.
Validation and transformation of XML data is easy with in-line DTD over
independent DTD as it reduces number of files to be read.
An XML Schema
The following example is an XML Schema file called "note.xsd" that defines the
elements of the XML document above ("note.xml") :
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="https://www.myXML.com"
xmlns="https://www.myXML.com"
elementFormDefault="qualified">
<xs:element name="notebook">
<xs:complexType>
<xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:complexType>
</xs:element>
</xs:schema>
The note element is a complex type because it contains other elements. The other
elements (to, from, heading, body) are simple types because they do not contain
other elements. You will learn more about simple and complex types in the
following chapters.
A Reference to an XML Schema
This XML document has a reference to an XML Schema :
<?xml version="1.0"?>
<note
xmlns="https://www.myXML.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.myXML.com/xml notebook.xsd">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
The <schema> Element
The <schema> element is the root element of every XML Schema :
<?xml version="1.0"?>
<xs:schema>
...
...
</xs:schema>
The <schema> element may contain some attributes. A schema declaration often looks
something like this :
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="https://www.myXML.com"
xmlns="https://www.myXML.com"
elementFormDefault="qualified">
...
...
</xs:schema>
The following fragment indicates that the elements and data types used in the
schema come from the "http://www.w3.org/2001/XMLSchema" namespace. It also
specifies that the elements and data types that come from the
"http://www.w3.org/2001/XMLSchema" namespace should be prefixed with xs :
xmlns:xs="http://www.w3.org/2001/XMLSchema"
The below fragment indicates that the elements defined by this schema (note, to,
from, heading, body.) come from the "https://www.myXML.com" namespace.
targetNamespace="https://www.myXML.com"
Following fragment indicates that the default namespace is
"https://www.myXML.com".
xmlns="https://www.myXML.com"
This fragment indicates that any elements used by the XML instance document
which were declared in this schema must be namespace qualified.
elementFormDefault="qualified"
<note xmlns="https://www.myXML.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.myXML.com note.xsd">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
Example :
Here are some XML elements
<lastname>Refsnes</lastname>
<age>36</age>
<dateborn>1970-03-27</dateborn>
And here are the corresponding simple element definitions:
<xs:element name="lastname" type="xs:string"/>
<xs:element name="age" type="xs:integer"/>
<xs:element name="dateborn" type="xs:date"/>
XSD Attributes
All attributes are declared as simple types.
Simple elements cannot have attributes. If an element has attributes, it is considered
to be of a complex type. But the attribute itself is always declared as a simple type.
The syntax for defining an attribute is :
<xs:attribute name="xxx" type="yyy"/>
where xxx is the name of the attribute and yyy specifies the data type of the
attribute.
XML Schema has a lot of built-in data types. The most common types are :
o xs:string
o xs:decimal
o xs:integer
o xs:boolean
o xs:date
o xs:time
Example :
Here is an XML element with an attribute :
<lastname lang="EN">Smith</lastname>
And here is the corresponding attribute definition :
<xs:attribute name="lang" type="xs:string"/>
Restrictions on Content
When an XML element or attribute has a data type defined, it puts restrictions on
the element's or attribute's content.
If an XML element is of type "xs:date" and contains a string like "Hello World", the
element will not validate.
With XML Schemas, you can also add your own restrictions to your XML elements
and attributes. These restrictions are called facets. You can read more about facets in
the next chapter.
XSD Restrictions/Facets
Restrictions are used to define acceptable values for XML elements or attributes.
Restrictions on XML elements are called facets.
Restrictions on Values
The following example defines an element called "age" with a restriction. The value
of age cannot be lower than 0 or greater than 120 :
<xs:element name="age">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:minInclusive value="0"/>
<xs:maxInclusive value="120"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:restriction>
</xs:simpleType>
</xs:element>
The next example defines an element called "initials" with a restriction. The only
acceptable value is THREE of the UPPERCASE letters from a to z :
<xs:element name="initials">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[A-Z][A-Z][A-Z]"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
The next example also defines an element called "initials" with a restriction. The
only acceptable value is THREE of the LOWERCASE OR UPPERCASE letters from a
to z :
<xs:element name="initials">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[a-zA-Z][a-zA-Z][a-zA-Z]"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
The next example defines an element called "choice" with a restriction. The only
acceptable value is ONE of the following letters: x, y, OR z :
<xs:element name="choice">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[xyz]"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
The next example defines an element called "prodid" with a restriction. The only
acceptable value is FIVE digits in a sequence, and each digit must be in a range from
0 to 9 :
<xs:element name="prodid">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:pattern value="[0-9][0-9][0-9][0-9][0-9]"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
This example defines an element called "username" with a restriction. The value
must be exactly eight characters :
<xs:element name="username">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:length value="8"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
This example defines another element called "password" with a restriction. The
value must be minimum five characters and maximum eight characters:
<xs:element name="password">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="5"/>
<xs:maxLength value="8"/>
</xs:restriction>
</xs:simpleType>
</xs:element
Restrictions for Datatypes
Constraint Description
enumeration Defines a list of acceptable values.
fractionDigits Specifies the maximum number of decimal places allowed. Must be equal to or
greater than zero.
length Specifies the exact number of characters or list items allowed. Must be equal to or
greater than zero.
maxExclusive Specifies the upper bounds for numeric values (the value must be less than this
value).
maxInclusive Specifies the upper bounds for numeric values (the value must be less than or
equal to this value).
maxLength Specifies the maximum number of characters or list items allowed. Must be equal
to or greater than zero.
minExclusive Specifies the lower bounds for numeric values (the value must be greater than
this value).
minInclusive Specifies the lower bounds for numeric values (the value must be greater than or
equal to this value).
minLength Specifies the minimum number of characters or list items allowed. Must be equal
to or greater than zero.
totalDigits Specifies the exact number of digits allowed. Must be greater than zero
whiteSpace Specifies how white space (line feeds, tabs, spaces, and carriage returns) is
handled
Both Validating and non-validating parser checks for the well-formed ness of XML
document.
The SAX and DOM parsers are standards that are implemented in several different
languages.
//Build Document
xmlDoc = parser.parseFromString(text,"text/xml");
DOM APIs
In below example code, refer the file notebook.xml in Fig1. This example starts
fetching information and printing it on console.
//Build Document
Document document = builder.parse(new File("notebook.xml"));
SAX Parser
SAX (Simple API for XML) is an event-driven online algorithm for parsing XML
documents, with an API developed by the XML-DEV mailing list.
SAX provides a mechanism for reading data from an XML document that is an
alternative to that provided by the Document Object Model (DOM).
The DOM operates on the document as a whole—building the full abstract syntax
tree of an XML document But SAX parsers operate on each piece of the XML
document sequentially, issuing parsing events while making a single pass through
the input stream. So it is memory efficient.
Unlike DOM, there is no formal specification for SAX. SAX processes documents
state-independently, in contrast to DOM which is used for state-dependent
processing of XML documents.
Rather than building a complete representation of the document, a SAX parser fires
off a series of events as it reads the document from beginning to end. Those events
are passed to event handlers, which provide access to the contents of the document.
Event Handlers
There are three classes of event handlers :
o DTD Handlers, for accessing the contents of XML Document-Type Definitions.
o Error Handlers, for low-level access to parsing errors; and, by far the most
often used.
o Document Handlers, for accessing the contents of the document.
A SAX processor will pass the following events to a Document Handler :
o The start of the document.
o A processing instruction element.
o A comment element.
o The beginning of an element, including that element's attributes.
o The text contained within an element.
o The end of an element.
o The end of the document.
Advantages of SAX
o It is simple to program.
o It is memory efficient as SAX parser does not keep any of the document tree in
memory.
Disadvantage of SAX
o The data is broken into pieces and clients never have all the information as a
whole unless they create their own data structure.
DOM Vs. SAX
DOM SAX
Stores the entire XML document into memory Parses node by node.
before processing.
Insertion and deletion of node is possible. Insertion and deletion of node is not possible.
XPATH
XPath (XML Path Language) is a query language for selecting nodes from an XML
document.
In addition, XPath may be used to compute values (e.g., strings, numbers, or
Boolean values) from the content of an XML document. XPath was defined by the
World Wide Web Consortium (W3C).
The primary purpose of XPath is to address the nodes of XML trees. XPath gets its
name from its use of a path notation for navigating through the hierarchical
structure of an XML document.
XPath uses a compact, non-XML syntax to facilitate use of XPath within URIs and
XML attribute values.
XPath is a major element in the XSLT standard. It can be used to navigate through
elements and attributes in an XML document.
XPath is syntax for defining parts of an XML document.
XPath uses path expressions to navigate in XML documents.
XPath contains a library of standard functions.
XPath is a major element in XSLT and in XQuery.
XPath is a W3C recommendation.
// Selects nodes in the document from the current node that match the
selection no matter where they are.
@ Selects attributes.
Some path expressions and the result of the expressions on the XML file.
(Refer Fig. 1.1.2)
Path Expression Result
note Selects all nodes with the name "note".
//note Selects all note elements no matter where they are in the document
notebook//note Selects all note elements that are descendant of the notebook element, no
matter where they are under the notebook element.
Predicates
Predicates are used to find a specific node or a node that contains a specific value.
Predicates are always embedded in square brackets.
In the table below we have listed some path expressions with predicates and the
result of the expressions.
/notebook/note[last()] Selects the last note element that is the child of the notebook element.
/notebook/note[last()-1] Selects the last but one note element that is the child of the notebook
element.
/notebook/note[position()<3] Selects the first two note elements that are children of the notebook
element.
//title[@lang] Selects all the title elements that have an attribute named lang.
//title[@lang='en'] Selects all the title elements that have a "lang" attribute with a value of
"en".
Wildcard Description
* Matches any element node
//title | //price Selects all the title AND price elements in the document.
/notebook/note/title | //price Selects all the title elements of the note element of the notebook
element AND all the price elements in the document.
XPath Axes
An axis represents a relationship to the context (current) node, and is used to locate
nodes relative to that node on the tree.
Axis Name Result
ancestor Selects all ancestors (parent, grandparent, etc.) of the current node.
ancestor-or-self Selects all ancestors (parent, grandparent, etc.) of the current node and the
current node itself.
descendant Selects all descendants (children, grandchildren, etc.) of the current node.
descendant-or-self Selects all descendants (children, grandchildren, etc.) of the current node and the
current node itself.
following Selects everything in the document after the closing tag of the current node.
preceding Selects all nodes that appear before the current node in the document, except
ancestors, attribute nodes and namespace nodes.
Example Result
child::note Selects all note nodes that are children of the current node.
ancestor-or- Selects all note ancestors of the current node - and the current as well if it is a
self::note note node.
XPath Operators
An XPath expression returns either a node-set, a string, a Boolean, or a number.
Below is a list of the operators that can be used in XPath expressions.
Operator Description Example
+ Addition 6+4
- Subtraction 22-18
* Multiplication 6*4
XPATH Example
Here is a new XML file referred to understand the use of XPATH.
<?xml version="1.0" encoding="utf-8"?>
<mypage>
<devteam>
<release name="europe" launch="2012-01-05">
<sprint>
<page language="English">en.mypage.com</page>
<page language="German">de.mypage.com</page>
<page language="French">fr.mypage.com</page>
<page language="Polish">pl.mypage.com</page>
<page language="Spanish">es.mypage.com</page>
</sprint>
</release>
<release name="local" launch="2019-12-12">
<sprint>
<page language="English">en.local.mypage.com</page>
<page language="French">fr.local.mypage.com</page>
<page language="Vietnamese">vi.local.mypage.com</page>
<page language="Turkish">tr.local.mypage.com</page>
<page language="Spanish">es.local.mypage.com</page>
</sprint>
</release>
</devteam>
</mypage>
Fig. 1.6.4 Sample XML file (mypage.xml) for Agile Project - www.mypage.com
The XPath expressions (Refer Fig. 1.6.5 for understanding the expressions below).
Selects name attributes for all devteam, and
/mypage/devteam/release/@name
Selects all sprint of all devteam
/mypage//sprint
Selects addresses of all English mypage devteam (text of all page elements where
language attribute is equal to English).
/mypage/devteam/release/sprint/page[@language='English']/text()
Selects addresses of all mypages (text of all page elements that exist under release
element with a name attribute of mypage).
/mypage/devteam/release[@name='mypage']/sprint/page/text()
XSLT Syntax
Root of an XSLT file stylesheet
An XSLT program is an XML document. Its top-level skeleton looks like this :
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
....
</xsl:stylesheet>
Mandatory "elements"
o An XML declaration on top of the file
o A stylesheet root tag, including version and namespace attributes as
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
Usually the "xsl" prefix is used for XSLT tags, but you also can find "xs" or none if
you look at examples.
XSLT must be well-formed and valid, i.e. obey the XSLT specification.
XSLT files usually have the *.xsl extension and should have the text / xsl or
application/xml mime type when served by http (a web server).
XSLT Structure
XSLT Elements
XSLT <xsl:template> Element
o An XSL style sheet consists of one or more set of rules that are called
templates.
o A template contains rules to apply when a specified node is matched.
o The match attribute is used to associate a template with an XML element.
o The match attribute can also be used to define a template for the entire XML
document.
o The value of the match attribute is an XPath expression (i.e. match="/" defines
the whole document).
e.g. <xsl:template match="/">
XSLT<xsl:value-of> Element
o The <xsl:value-of> element can be used to extract the value of an XML element
and add it to the output stream of the transformation.
e.g. <xsl:value-of select="/News/Players/Player"/>
XSLT Example
XSLT uses XPath to identify subsets of the source document tree and perform
calculations. XPath also provides a range of functions, which XSLT itself further
augments.
This example demonstrates the basics of setting up an XSLT transformation in a
browser. The example will take an XML document that contains information (Team,
list of Players and body text) about News and present it in a human readable form.
The XML document (example.xml) contains the information about the News. Using
the ?xml-stylesheet? processing instruction, it links to the XSLT stylesheet
(example.xsl) via its href attribute.
An XSLT stylesheet starts with the xsl:stylesheet element, which contains all the
templates used to create the final output.
This example has two templates -
o Template that matches the root node
o Template that matches Player nodes.
The template that matches the root node outputs the News's Team and then says to
process all templates (via apply-templates) that match Player nodes which are
children of the player’s node.
Source / input file XML Document (example.xml).
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="example.xsl"?>
<News>
<Team>My News</Team>
<Players>
<Player>Jay</Player>
<Player>Ajay</Player>
<Player>Vijay</Player>
<Player>Sanjay</Player>
</Players>
<Body>This is my News text.</Body>
</News>
XSL Stylesheet (example.xsl) :
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">
News - <xsl:value-of select="/News/Team"/>
Players: <xsl:apply-templates select="/News/Players/Player"/>
</xsl:template>
<xsl:template match="Player">
- <xsl:value-of select="." />
</xsl:template>
</xsl:stylesheet>
Open the example.xml in the browser application to see following output.
News - My News
Players :
- Jay
- Ajay
- Vijay
- SanjayS
1.8 XQuery
XQuery (XML Query) is a query and functional programming language that queries
and transforms collections of structured and unstructured data, usually in the form
of XML, text and with vendor-specific extensions for other data formats (JSON,
binary, etc.).
The language is developed by the XML Query working group of the W3C. The work
is closely coordinated with the development of XSLT by the XSL Working Group;
the two groups share responsibility for XPath, which is a subset of XQuery.
The latest version of XQuery is XQuery 3.1 as a W3C Recommendation on March 21,
2017.
XQuery provides the means to extract and manipulate data from XML documents
or any data source that can be viewed as XML, such as relational databases or office
documents.
The language is based on the XQuery and XPath Data Model (XDM) which uses a
tree-structured model of the information content of an XML document, containing
seven kinds of nodes: document nodes, elements, attributes, text nodes, comments,
processing instructions, and namespaces.
Query is the query language used to query the records in the XML document. It is
similar to the SQL query in RDBMS. It is the functional language independent of the
format of the XML data in the document. This can be used to query XML document,
XML database or relational database with XML data.
XQuery has following characteristics :
o It is a functional language used to retrieve the XML data from any document
or database.
o This is similar to SQL in RDBMS, and queries / traverses XML data.
o It uses XPaths to traverse through XML data to fetch the records.
o XQuery is supported by almost all database system.
Though the expressions that we have seen above to point to different nodes, simply
writing the expression will not give the required results. Those expressions will
simply point to the nodes specified by the expressions. It should have proper
querying to pull the values at that node. That is done by XQuery.
Consider the below XML document of addresses of different people in US. Let the
name of the document be address.xml. Now we know that if we need to access any
node element within this document, we have to use XPath expressions. But these
expressions cannot be written within this xml document. We need to have separate
file or platform for writing the expression. That means the expressions are written
outside the address.xml file.
<Contact>
<Address Name=”Rose”>
<ApartmentNum>APT 201 </ ApartmentNum>
<Street>Lakeside Village Drive </Street>
<Town> Clinton Township </Town>
<State> MI </State>
<Country> US </Country>
</Address>
<Address Name=”William”>
<ApartmentNum>APT 671 </ ApartmentNum>
<Street>Fraser Village Drive </Street>
<Town> Fraser Township </Town>
<State> NY </State>
<Country> US </Country>
</Address>
<Address Name=”Robert”>
<ApartmentNum>APT 232 </ ApartmentNum>
<Street>Seianna Drive </Street>
<Town> Danbury </Town>
<State> CT </State>
<Country> US </Country>
</Address>
</Contact>
Advantages of XQuery
XQuery can be used to traverse both tabular as well as hierarchical data, provided
they are in XML format.
These can be used to traverse graphical and tree like structures.
It can be used to transform XML documents.
It can be used to traverse and build WebPages.
FLOWR Expressions
XQuery gives the touch of query to above expression using FLWOR – ‘For Let
Where Order By Return’. i.e.;
o for : This clause selects all the elements under the given XPath expression.
o Let : It stores the elements selected in for clause into a variable $x. In XQuery
variables starts with ‘$’ symbol.
o where : This clause is used to indicate any predicates / conditions.
o order by : This clause will sort the result set.
o return : This clause will have the elements that need to be returned.
In order to make the expression to access the address.xml file, XQuery uses a
function doc(). This function creates a link between the XQuery and XPath. That
means the XPath expressions are written based on the file pointed by doc() function.
doc (“file_name”)
doc (“address.xml”)
Path Expressions
Once doc function is used, the XQuery is now pointing to the xml file that it needs
to traverse. Now it can use XPath expressions to traverse the nodes within this xml
file. i.e.;
doc (“address.xml”)/Contact/Address/Street
doc (“address.xml”)/Contact/Address[State = “NY”]
Above expression will select all the Addresses whose state is ‘NY’. That means, it
will select whole set of details like below.
<Address Name=”William”>
<ApartmentNum>APT 671 </ ApartmentNum>
<Street>Fraser Village Drive </Street>
<Town> Fraser Township </Town>
<State> NY </State>
<Country> US </Country>
</Address>
Suppose we have to select only particular field from above list rather than selecting
whole details, say street of each addresses in ‘NY’, then we can modify the
expression like below :
doc (“address.xml”)/Contact/Address[State = “NY”]/Street
This expression will pull all the streets in the addresses whose state is ‘NY’. This is
how we get particular element from the xml file using XPath’s expression and
predicate. But same can be done in XQuery using same XPath expression is little
different way.
Contents
2.1 Introduction
2.2 Characteristics of SOA
2.3 Benefits of SOA
2.4 Comparing SOA with Client-Server & Distributed Architectures
2.5 Principles of Service Orientation
2.6 Service Layers
(2 - 1)
Service Oriented Architecture 2-2 Service Oriented Architecture (SOA) Basics
2.1 Introduction
Large Enterprise of business applications (e.g. Core Banking & Credit Card
System, Insurance Systems, Mobile Service Providers and many more) are
normally designed with the help of various components, providing the business
specific functionalities.
Software architecture refers to the fundamental structures of a software system
and the discipline of creating such structures and systems. Each structure
comprises software elements, relations among them, and properties of both
elements and relations.
Enterprise Architecture
Fig. 2.1.2
o In larger IT environments, the need to control and direct IT infrastructure is
critical. When numerous, disparate application architectures co-exist and
sometimes even integrate, the demands on the underlying hosting platforms can
be complex and onerous.
o Therefore, it is common for a master specification to be created, providing a high-
level overview of all forms of heterogeneity that exist within an enterprise, as well
as a definition of the supporting infrastructure.
Service Oriented Architecture
Service in SOA
A SOA service is a discrete unit of functionality that can be accessed remotely and
acted upon and updated independently, such as retrieving a e-wallet statement
online.
SOA encourages individual units of logic to exist autonomously yet not isolated
from each other. Units of logic are still required to conform to a set of principles
that allow them to evolve independently, while still maintaining a sufficient
amount of commonality and standardization. Within SOA, these units of logic are
known as services.
A service has four properties according to one of many definitions of SOA
o It logically represents a business activity with a specified outcome.
o It is self-contained.
o It is a black box for its consumers, meaning the consumer does not have to be
aware of the service's inner workings.
o It may consist of other underlying services.
Services encapsulate logic within a distinct context to retain their independence.
Due to this the context can for a given service may be specific to a business task, a
business entity, or some other logical grouping.
The concern addressed by a service can be small or large. Hence the size and
scope of the logic for the given service can vary. Further, service logic can
encompass the logic provided by other services. They are referred as collective
services when composed of many smaller services together.
Different services can be used in conjunction to provide the functionality of a
large software application, a principle SOA shares with modular programming.
Logic encapsulation by Services
Services encapsulate business logic within a distinct context. The context can be
specific to a business task, a business entity, or some other logical grouping. This
helps in retaining their independence within the system.
The concern addressed by a service can be small or large. Hence the size and
scope of the service can be different. Also, the service logic of one service can
include logic provided by other services. In such scenario, it is referred as
collective service.
A service can even encapsulate the entire process logic. In the latter two cases, the
larger scope represented by the services may encompass the logic encapsulated by
other services.
Example : Building Automation Solutions using SOA.
o Business automation solutions are typically an implementation of a business
process.
o This process is comprised of logic that dictates the actions performed by the
solution. The logic is decomposed into a series of steps that execute in
predefined sequences according to business rules and runtime conditions.
o When building an automation solution consisting of services, each service can
encapsulate a task performed by an individual step or a sub-process comprised
of a set of steps.
Fig. 2.1.4 Different logics are implemented by different services within a process block
The execution of business activities can be run as a service that use the logic and
also encapsulate included services. For this the including service they must form
distinct relationships with those services that want to use them.
Within SOA, services can be used by other services or other programs. For this it
is mandatory for services to be aware about existence of other services. For this
purpose, Service descriptions are used.
A service description establishes the name of the service and the data expected
and returned by the service. In SOA a service use other services in a loosely
coupled manner.
Services must exchange information in order to interact and accomplish a
meaningful business task. Hence SOA needs a communications framework that
can achieve their loosely coupled relationship. Messaging framework is used to
achieve the communication between services.
Refer Fig. 2.1.5 below. It shows that service A is aware of service B because it
holds service B’s service description.
Designing services
Web services can make the functional building-blocks accessible over standard
Internet protocols that are independent of platforms and programming languages.
These services can represent either new applications or just wrappers around
existing legacy systems to make them network-enabled.
Following are the major vendor platforms currently support the creation of
service-oriented solutions -
o Web services based on WSDL and SOAP (Simple Object Access Protocol)
o Messaging, e.g., with ActiveMQ, JMS, RabbitMQ
o RESTful HTTP, with Representational state transfer (REST) constituting its own
constraints-based architectural style
o OPC-UA (OPC Unified Architecture)
o WCF (Microsoft's implementation of Web services, forming a part of WCF)
o Apache Thrift
o gRPC (gRPC Remote Procedure Calls)
o SORCER (A distributed computing platform implemented in Java.)
Primitive SOA
SOA is a constantly growing field with various vendors developing SOA products
regularly.
A baseline service-oriented architecture that is suitable to be realized by any
vendor is known as the primitive SOA.
The fundamental characteristics of service encapsulation, loose-coupling, and
messaging, service-orientation principles and the Web services technology
together satisfy the implementation of a primitive SOA. Refer Fig. 2.1.8.
Note : In the next section we will discuss about the contemporary SOA.
The primary external influences that shape and affect contemporary SOA are first-
and second-generation Web services specifications and the principles of service-
orientation.
o Because contemporary SOA is built building upon and extending the primitive
SOA model, Contemporary SOA represents an architecture that promotes
service-orientation through the use of Web services.
Contemporary SOA is based on open standards -
o This is a natural by-product of basing SOA on the Web services technology
platform and its ever-growing collection of WS -* specifications. The majority of
Web services specifications are open and vendor-neutral.
o It is the most significant characteristic of Web services is the fact that data
exchange is governed by open standards.
o After a message is sent from one Web service to another it travels via a set of
protocols that is globally standardized and accepted.
o Further, the message itself is standardized, both in format and in how it
represents its payload.
o The use of SOAP, WSDL, XML, and XML Schema allow for messages to be
fully self-contained and support the underlying agreement that to
communicate, services require nothing more than knowledge of each other’s
service descriptions.
o The use of an open, standardized messaging model eliminates the need for
underlying service logic to share type systems and supports the loosely
coupled paradigm.
o Contemporary SOAs fully leverage and reinforce this open, vendor-neutral
communications framework (Refer Fig. 2.2.3).
o For the most part, the specifications that comprise the WS-* landscape fully
enable architectural composability by allowing a given SOA to only implement
extensions it actually requires.
Fig. 2.2.13 Loose coupling between business logic and application technology
o SOA can establish an abstraction of business logic and technology that may
introduce changes to business process modelling and technical architecture,
resulting in a loose coupling between these models.
o SOA is an evolution of past platforms, preserving successful characteristics of
traditional architectures, and bringing with it distinct principles that foster
service-orientation in support of a service-oriented enterprise.
o SOA is ideally standardized throughout an enterprise, but achieving this state
requires a planned transition and the support of a still evolving technology set.
A supplementary definition that can be applied to both primitive and
contemporary SOA is as follows -
o SOA is a form of technology architecture that adheres to the principles of
service-orientation. When realized through the Web services technology
platform, SOA establishes the potential to support and promote these
principles throughout the business process and automation domains of an
enterprise
Separating concrete characteristics
After removing the concrete SOA characteristics that are directly supported or
provided by identified external influences (Refer Fig. 2.2.1), here are the four
remaining characteristics of contemporary SOA. These are -
o Enterprise-wide loose coupling
o Support for service-oriented business modelling
o Organizational agility
o Layers of abstraction
Incorporating the key qualities into SOA requires that some very fundamental
decisions be made, long before the building process of individual services
commence.
Relevance of SOA
The primary goal of Service Oriented Architecture is to align business users with
Information Technologies (IT).
Service-Oriented Architecture (SOA) enables increased business agility, improved
business workflows, extensible architecture, enhanced reuse, and a longer life
span of applications.
Adopting Service Oriented Architecture realize many benefits.
Inherent reuse
o Service-orientation promotes the design of services that are inherently reusable.
o Building service-oriented solutions fulfill immediate application-level
requirements. It supports a degree of reuse by future potential requestors.
o It also establishes an environment wherein investments into existing systems
can be leveraged and re-leveraged as new solutions.
o Building services to be inherently reusable results in a moderately increased
development effort and requires the use of design standards.
o Subsequently leveraging reuse within services lowers the cost and effort of
building service-oriented solutions.
o SOA compliance to web services and hence applications running on either
platform can also consume services running on the other as web services that
facilitate reuse.
o Properly designed implemented SOA application provide infrastructure that
makes reuse possibilities in heterogeneous environment such as C, C++,Java,
.Net etc.
o Managed environments can also wrap COBOL legacy systems and present
them as services. This has extended the useful life of many core legacy systems
indefinitely, no matter what language they originally used.
o Hence the cost and effort of integrating legacy and contemporary solutions is
lowered. The need for legacy systems to be replaced is potentially lessened.
Establishing standardized XML data representation
o On its most fundamental level, SOA is built upon and driven by XML. As a
result, an adoption of SOA leads to the opportunity to fully leverage the XML
data representation platform.
o A standardized data representation format (once fully established) can reduce
the underlying complexity of all affected application environments.
o Some of such examples include :
XML documents and accompanying XML Schemas (packaged within
SOAP messages) passed between applications or application components
fully standardize format and typing of all data communicated. The result
is a predictable and therefore easily extensible and adaptable
communications network.
XML’s self-descriptive nature enhances the ability for data to be readily
interpreted by architects, analysts, and developers. The result is the
potential for data within messages to be more easily maintained, traced,
and understood.
The standardization level of data representation lays the groundwork for
intrinsic interoperability. Specifically, by promoting the use of
standardized vocabularies, the need to translate discrepancies between
how respective applications have interpreted corporate data models is
reduced.
o With contemporary SOA, establishing XML data representation architecture
becomes a necessity, providing organizations the opportunity to achieve a
broad level of standardization.
o Hence the cost and effort of application development is reduced after a
proliferation of standardized XML data representation is achieved.
Focused investment on communications infrastructure
o Because Web services establish a common communications framework for
SOA, SOA can centralize inter-application and intra-application
communication as part of standard IT infrastructure.
o This allows organizations to evolve enterprise-wide infrastructure by investing
in a single technology set responsible for communication.
Disadvantages
SOA is not considered suitable for applications with GUI functionalities. Those
applications become more complex if they use SOA which requires heavy data
exchange. Also application requiring asynchronous communication can’t make
use of SOA. Also in case of standalone and short lived applications’
implementations, SOA will become an added burden.
o It replaced the custom software client component with the browser and
radically alters user-interface design, with major shift of application logic to the
server.
o With the development of www, Hyper Text Transport Protocol (HTTP)
replaced the proprietary RPC protocols used to communicate between the
user’s workstation and the server.
o From the late 90s to the mid-2000s, distributed Internet architectures
represented the default and most popular computing platform for custom
developed enterprise solutions.
• Distributed Internet Architecture vs. SOA
The comparison of SOA provided in this section is with traditional distributed
Internet architecture in the manner in which these are commonly designed.
Distributed Internet Architecture Service Oriented Architecture
technologies - HTML and HTTP. Thus, XML and Web services are
optional for distributed Internet
Improvements in middleware
architecture but not for
allowed for increased processing
contemporary SOA.
power and transaction control.
The emergence of XML introduced
sophisticated data representation
that actually gave substance to
content transmitted via Internet
protocols.
The subsequent availability of Web
services allowed distributed Internet
applications to cross proprietary
platform boundaries.
The service layer can be considered as a bridge between the higher and lower
layers, and is characterized by a number of services that are carrying out
individual business functions.
The service interface layer is located between the business process and application
layers.
This is where service connectivity resides; hence it is the most dominant layer in
the service-oriented architecture.
Before implementing the quality services of SOA (primarily enterprise-wide loose
coupling, support for service-oriented business modelling, organizational agility
and the layers of abstraction) Application architects should get clarity on the
below questionnaire. This list gets studied and answered during SOA analysis
phase. The list is as -
o What logic should be represented by services ?
o How should services relate to existing application logic ?
o How can services best represent business process logic ?
o How can services be built and positioned to promote agility ?
Based on this questionnaire, the three layers of abstraction identified are
o Application Service Layer
o Business Service Layer
o Orchestration Service Layer
The positioning of these primary service layers is detailed out in the following
sections. (Refer Fig. 2.6.2)
Within the orchestration service layer, process services compose other services
that provide specific sets of functions, independent of the business rules and
scenario-specific logic required to execute a process instance.
Orchestration abstracts business rules and service execution sequence logic from
other services, promoting agility and reusability.
A reality check
Theoretically there are clearly identified service layers in SOA; the real SOAs
rarely show such separation. In real scenario, one may come across following
kind of service compositions.
o Hybrid application services (services containing both business process and
application logic)
o Utility application services (services containing reusable application logic)
o Task-centric business services (services containing business process logic)
o Entity-centric business services (services containing entity business logic)
o Process services (services representing the orchestration service layer)
To summarize
o SOAs are configured in different shapes and sizes, depending primarily on the
types of services from which they are comprised.
o Hybrid application services are found more commonly when service-oriented
environments include legacy distributed application logic.
o By strategically positioning business and process services, an enterprise’s
business logic can be abstracted successfully from the underlying application
logic.
Contents
3.1 Web Services Platform
3.2 Service Descriptions (with WSDL)
3.3 Messaging with SOAP
3.4 Service Discovery and Description Advertisement
3.5 Orchestration
(3 - 1)
Service Oriented Architecture 3-2 Web Services (WS) and Standards
Points to remember
Web service is a standardized medium to propagate communication between the
client and server applications on the World Wide Web. A web service is a software
module that is designed to perform a certain set of tasks.
A web service is any piece of software that makes itself available over the internet
and uses a standardized XML messaging system.
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.
Unlike traditional client / server models, such as a Web server / Web page system,
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. The applications interface, not the users. Developers can then add the Web
service to a GUI (such as a Web page or an executable program) to offer specific
functionality to users.
The term Web services describes a standardized way of integrating Web-based
applications using the XML, SOAP, WSDL and UDDI open standards over an
Internet protocol backbone. XML is used to tag the data, SOAP is used to transfer
the data, WSDL is used for describing the services available and UDDI is used for
listing what services are available.
The client would invoke a series of web service calls via requests to a server which
would host the actual web service.
These requests are made through what is known as remote procedure calls. Remote
Procedure Calls (RPC) is calls made to methods which are hosted by the relevant
web service.
As an example, Amazon provides a web service that provides prices for products
sold online via amazon.com. The front end or presentation layer can be in .Net or
Java but either programming language would have the ability to communicate with
the web service.
The main component of a web service is the data which is transferred between the
client and the server and that is XML, XML (Extensible Markup Language) is a
counterpart to HTML and easy to understand the intermediate language that is
understood by many programming languages.
So when applications talk to each other, they actually talk in XML. This provides a
common platform for application developed in various programming languages to
talk to each other.
Web services use something known as SOAP (Simple Object Access Protocol) for
sending the XML data between applications. The data is sent over normal HTTP.
The data which is sent from the web service to the application is called a SOAP
message. The SOAP message is nothing but an XML document. Since the document
is written in XML, the client application calling the web service can be written in
any programming language.
Modern day business applications use variety of programming platforms to develop
web-based applications. Some applications may be developed in Java, others in
.Net, while some other in Angular JS, Node.js, etc.
Most often than not, these heterogeneous applications need some sort of
communication to happen between them. Since they are built using different
development languages, it becomes really difficult to ensure accurate
communication between applications. Here is where web services come in. Web
services provide a common platform that allows multiple applications built on
various programming languages to have the ability to communicate with each
other.
To understand the concept of web services let’s consider the story of four friends : I
get a chance to meet my school friends, Devika and Aastha occasionally. We have
one more friend Neela, but we haven't met her for many years. We don't know
about the current details of Neela, so we decided to contact an agency called
"Reconnect".
ln this scenario, reconnect agency is providing a service, so it can be considered as a
service provider. We want to avail the service so we are service requestors.
To use the service offered by Reconnect we need to follow the below steps.
a. We need to find out or discover how to contact this agency.
b. We need to formulate the request by providing the information about Neela to
the Reconnect agency.
c. Forward this information or issue the request to agency.
2. Concrete description :
This section includes connection of abstract interface to implemented technology i.e.
a physical transport protocol.
It consists of three parts.
o Binding
o Port
o Service
Binding is a transport technology which is used by service for communication.
For example : SOAP which described how physical connections can be established
with the service.
Port is a physical address through which service can be accessed via specific
Service in WSDL language is a group of endpoints.
Fig. 3.2.3 A service contract comprised of a collection of service descriptions and possibly
additional documents
As shown in Fig. 3.2.3, collection of these is used to establish a service contract
which is a set of conditions which must be met and accepted by potential service
requester for successful communication.
Semantic Descriptions :
Typically the service description documents talks about the technical information
corresponding to data representation and processing requirements. But, they do not
say much about the behaviour characteristics of the service which is a challenging
part to explain in web service descriptions.
Some of the examples of service semantic are behaviour and response of a service
under certain conditions suitable task for a service.
Generally, this requires human intervention as sufficient semantic information need
to be conveyed in structured manner.
Messages :
The main aim of SOAP is to define a standard
message format.
SOAP message format includes :
o Envelope
o Header
o Body
Fig 3.3.1 The basic structure of a
The basic structure of SOAP message is shown in SOAP message
Fig. 3.3.1.
Attachments :
The data which is difficult to format in XML document can be delivered by SOAP
attachment technology.
The data is bundled in a specific encoding type in the specific format supported by
SOAP message.
Typically binary files images ex. images are sent as SOAP attachments.
Faults :
Exception handling is included in SOAP message in fault section.
It is an optional section which is included in the body area.
This section contains simple message used to deliver error condition information in
case of exception occurrence.
Nodes :
SOAP messages need to be exchanged and processed by a physical communication
medium.
This physical medium i.e. the programs which are used to transmit and receive
SOAP messages is called as SOAP nodes.
Fig. 3.3.2 shows the structure of a SOAP node for the transmitting a SOAP message
received by the service logic.
Fig. 3.3.2 A SOAP node transmitting a SOAP message received by the service logic
SOAP nodes must follow the processing standard catering to the supported version
of SOAP specification.
Node Types :
The labels are given to identify the type of SOAP node.
SOAP types or labels are called as concept.
Following are the labels associated with SOAP nodes.
o SOAP sender - Node which transmits a message.
o SOAP receiver - Node which receives a message.
SOAP Intermediaries :
As shown in Fig. 3.3.3 intermediary node, this node plays role of SOAP receiver and
sender while processing a message.
Fig. 3.3.3 Different types of SOAP nodes involved with processing a message
Message Paths :
It is a route taken by message from service to destination.
As shown in Fig. 3.3.4, message part must have :
o At least one initial sender.
o One ultimate receiver.
o Zero or more intermediaries.
UDDI
The above context of service discovery and description advertisement Universal
Description Discovery and Integration (UDDI) protocol is an approved OASIS
standard and key member of web services stack.
UDDI in tested to structure the registered for keeping track of service description as
shown in Fig. 3.4.1.
The search of these registries can be done manually or they can be assessed
programmatically through standard API.
3.5 Orchestration
To understand orchestration lets revisit the story of four friends. If new company
needs to be started the various types of car need to be handled for clearing. Some
new requirements are needed to facilitate this. These include : Need of extra help in
peak hours and in return of usage of space the help can be provided to gas pumping
station. To accomplish this various tasked and operations need to manage according
to the conditions. Some of the conditions include task allocation when extra workers
are presents etc. To handle this plan should be there to join individual steps with
processes partitioned by decision points. This is called as or orchestration which
manger individual process requirements and related resources.
Orchestration is centrally controlled set of workflow logic which facilities
interoperability between two or more applications.
Orchestration connects different process without the need of redevelopment of the
solutions.
It helps to represent and express business logic in a standardized, receives based
venue.
Fig. 3.5.1 describes the concept of orchestration.
Fig. 3.5.3 The process service, after first being invoked by a partner service, then invokes another
partner service
The organizational agility increases due to orchestration as the workflow logic can
be altered at a central location, business process can be merged it supports the
evolution of diversely featured enterprise.
Choreography
Choreography is a collaboration process which allows intersection of the
organizations in partnership considering that an environment is not owned by any
one partner.
To understand Choreography let’s consider the example of car washing company
example. After successful operation is some months the company was contracted by
the nearby companies to enhance the profit. But it was observed that this
partnership started affecting our business. So these in a need of new process which
includes new conditions and constraints. So after discussion with Partner Company
the agreement was made for facilitating flexible collaboration process. This
collaboration process is called as Choreography.
The web services choreography description language (WS-CDL) in the specification
which is used to facilitate information process is called as Choreography.
Fig. 3.5.5 explains the concept of Choreography.
Collaboration :
Public message exchange is the main characteristics of choreography.
To facilitate this, there is need of establishment of organized collaboration between
services taking care that a single organization should not context the collaboration
logic.
Roles and Participants :
Role of a web service within a specific choreography tells that what work the service
does and what it can do for a business task. Role is associated under WSDL
destination.
Participants are the services which follow the same rules.
Relationships and channels
Relationship is an exchange of two roles in choreography.
Channel is the means of conversation. They do that by characteristic definition of
the message exchange between two roles.
Syllabus
WS-Addressing - WS-ReliableMessaging - WS-Policy - WS-Coordination – WS-Transactions
- WS-Security – Examples.
Contents
4.1 WS-Addressing
4.2 Reliable Messaging
4.3 WS-Policy
4.4 WS-Coordination
4.5 WS-Transactions
4.6 WS-Security
(4 - 1)
Service Oriented Architecture 4-2 Web Services Extensions
Points to remember
To support the concepts of services oriented architecture WS.* extensions are used.
They play important role in the areas of SOAP messaging framework, message level
security and certain and exchange of metadata.
The first web services specification is WS-addressing.
4.1 WS-Addressing
Consider the communication happening in Fig. 4.1.1.
To understand addressing, consider the example of bill in shipping process.
Irrespective of the in between stoppages, the destination as whoever is viewing it
will come to know the source from where it is coming, the address of destination,
the person to whom it must be delivered and the address where it should reach in
case of father delivery to the required destination.
Fig. 4.1.2 A SOAP message containing a reference to the instance of the service that sent it
Fig. 4.1.3 A SOAP message with message information headers specifying exactly how the
recipient service should respond to its arrival
sending company to tell them the number of workers arrived. This acknowledgment
builds reliability into resource sharing arrangement.
As message transmission is a loosely coupled it’s difficult to know it the messages
are successful delivered in the
same sequence or there is failure
in delivered in the same sequence
or there is failure in delivery so
they need to retransmit or not.
This problem is solved by reliable
messaging by means of
notification as shown in Fig. 4.2.1. Fig. 4.2.1 Reliable messaging provides a guaranteed
notification of delivery success or failure
WS-Reliable messaging ensures :
1) Notification to service provider regarding success or failure of message
transmission.
2) The sequence in which the messages are sent are arriving in the same sequence or
not.
As shown in the Fig. 4.2.2 the description of the various blocks are given as :
o Application source : It is a service application logic responsible for sending
the message to Reliable messaging (RM) source.
o RM source : It is a physical processor or node which performs actual wire
transmission.
o RM destination : It is a target processor or node that receives the message.
o Application destination : The message from RM destination as finally
delivered to application destination.
4.2.2 Sequences
As shown in Fig. 4.2.3, sequence is responsible for the order of delivery of the
message.
Every message in a sequence is labelled with message number.
Message number identifies position of message in a sequence.
The last message in the sequence is tagged by last message identifier.
4.2.3 Acknowledgments
It is a notification system between RM destination and RM source as shown in
Fig. 4.2.4.
When the last message, containing last message identifier reaches RM destination, it
issues a sequence acknowledgment.
Acknowledgment message tells RM source which messages are arrived.
A sequence acknowledgment sent by the RM destination after the successful
delivery of a sequence of messages.
It is a job of RM source to match the number of received messages to original
messages.
RM source will not wait for RM destination for the acknowledgment.
Rather RM source can request the acknowledgment by RM destination by issue of
request acknowledgment at any time as shown in Fig 4.2.4.
Fig. 4.2.5 A negative acknowledgement sent by the RM destination to the RM source, indicating
a failed delivery prior to the completion of the sequence
4.3 WS-Policy
Every task in any business should follow some rules and constraints.
These rules and restrictions are subject to actual business level requirements, the
nature of data which can be exchanged and organizational security measures.
To understand the concept of policy let us consider the scenario of process of car
wash when driver brings the car for washing they see the list of points like :
o After entering car wash area, turn-off the engine and exit the car.
o Beware; power washing equipment can be loud.
o We recommend that you wait inside the gas station until the car wash has
completed.
Among the above three, first is the rule to be followed by customers. A second
state the behaviourial characteristics of car wash, third is the company preference
for smooth work handling. These points form a policy.
As shown in Fig. 4.3.1 the policies helps a service to express characteristics and
preferences and their implementation by enforcing rules and constraints in a custom
manner.
Fig. 4.3.1 Policies can express a variety of service properties, including rules
4.4 WS - Coordination
Every activity that takes place consists of small tasks which are executed for certain
time and possess certain context.
The description of context is called as context information.
As the complexity of activity increases the context information also increases.
Typically the complexity of activity depends on : amount of participating services,
duration of activity, frequency of changes in activity, concurrent execution of the
multiple instances of activity.
This scenario can be understood from Fig. 4.4.1.
Fig. 4.4.1 Coordination provides services that introduce controlled structure into activities
4.5 WS-Transactions
Transactions are the important part of automated computed solutions.
As shown in Fig. 4.5.1 atomic transactions are applied as part of an activity.
ACID Transactions :
The characteristics of ACID transactions are :
o Atomic : with scope of transaction all the changes succeed or none of them
succeed.
o Consistent : Data changes from request of transactions should not violate the
validity of associated data models.
Fig. 4.5.3 The coordinator requesting that transaction participants prepare to vote
Fig. 4.5.4 The transaction participants voting on the outcome of the atomic transaction
2. Commit phase : After receiving the atomic transaction coordinator review the
votes and decides whether to commit or rollback the transaction.
If all votes are for commit the transaction is declared as successful and further
commitment action is taken.
If any of the votes is abort or the participants fail to respond, transaction is
aborted and roll back is done as shown in Fig. 4.5.5.
4.6 WS-Security
Service oriented applications need to handle the demands of protecting information.
The three core specifications considered in security are -
o WS-security
o XML-Signature
o XML-Encryption
In this section five security requirements are discussed : identification,
authentication, authorization, confidentiality and integrity.
As shown in Fig. 4.6.2 through authentication the service needs to provide proof to
tell that claimed identify is true.
As shown in Fig. 4.6.3 through authorization the recipient of the message can
determine what is requestor is allowed to do.
Fig. 4.6.5 Confidentiality means that the privacy of the message has been protected throughout
its message path
Fig. 4.6.9 Security, as it relates to policies, SOAP messages and Web services
Contents
5.1 SOA Delivery Strategies
5.2 Service Oriented Analysis
5.3 Service Modelling
5.4 Service Oriented Design
5.5 Standards and Composition Guidelines
5.6 Service Design
5.7 Business Process Design
(5 - 1)
Service Oriented Architecture 5-2 Service Oriented Analysis and Design
Please note that unlike the other phases, first two phases are termed as service
oriented as SOA characteristics and service orientation principles are used for
building the solution.
These life cycle phases are described as below :
1. Service oriented analysis :
o In this first stage the scope of SOA is determined.
o Other activities include :
Mapping of service layers
Modeling of individual services as service candidates
2. Service oriented design :
o This is a standard driven phase which includes industry conventions and
service orientation principles for designing the services.
o For formal business process deformation is obtained among or layer in this
phase.
o In this phase service designer can decide the key decisions to be taken for
establishing the logic boundaries included in the services.
3. Service development :
o This is an actual construction phase
o Choice of programming language in suitable development environment is
done.
o This helps in knowing the physical form of services and orchestrated business
process according to design.
4. Service testing :
o As the services can be reused the rigorous testing is required before the
deployment.
o Some key factors which can be considered one types of service requestors,
fulfillment of policy assertions, communication of service semantics by service
descriptions, case in composition, data type related etc.
5. Service deployment :
o In this phase the installation and configuration of distributed components is
done along with service interfaces, middleware products on production
servers.
o Some of the issues which may be faced are distribution of services,
infrastructural adequacy for fulfilling processing requirements, effect of new
services on existing services, version management, scalability requirement
analysis, etc.
6. Service administration :
o This phase focuses on various applications management and administration
concerns for distributed and component based application.
o The issues which may be faced in this phase are :
Monitoring of the services.
Version control management of service description documents.
Tracing and management of messages.
Detection of performance bottlenecks.
Please note that it is assumed that business requirements are already collected and
defined.
The stepwise description can be given as :
Step 2 : Align relevant business models (including entity models) with new of revised
ontology.
o In this step business models are adjusted to represent the ontology given by
ontology in business modeling terms.
Step 2 : When the top down analysis has sufficiently progressed, perform service
oriented analysis.
o In this step, it is determined that ongoing top down analysis is enough
matured to proceed with creation of business service models.
oriented solution.
o The requirements collection for the given scope and their documentation is
needed.
o For defining high level automation process the requirements should be
properly defined.
Process description
The sample service modelling process consists of 12 steps as shown in Fig. 5.3.1.
Fig. 5.5.3 Designated service layers organize and standardize Web services within SOA.
As shown in Fig. 5.5.3 this step includes configuration of service layer within your
environment.
To take the decisions like whether to build business services and other decisions
related to service layers.
Some guidelines which are very helpful are :
o Existing configuration : For the standardized service layered within
enterprise, new service designs can be added.
o Required standards : New type of services or service layers can be built
according to written design standards which are applicable to the current and
future projects.
o Service composition performance : Carrying out performance tests in
essential which deciding multi-level service layer configuration to handle the
validation deserialization and serialization steps to process contents of soft
messages.
o Service deployment : While designing service layered the latency can be
induced in deployment due to centrally located reusable services. Redundant
deployment of the services can be done to address this problem.
o Service versioning : The versioning system should be in place to handle the
additional extensions to complete the features set.
o Business services and XSD schema design : To consider existing set of XSD
schema is important while using the entity centric business services as they
process document entities accompanied by entity centric schema.
o Business Service maintenance : To cater with agile delivery strategy ongoing
maintenance of business service is required separate administration process is
needed for keeping the business logic representation of the services in
synchronization.
Consideration for positioning core SOA standards :
Establishment of standards is very important in SOA composition. Some standards
which can which can be used are described in this section.
Industry standards and SOA
The SOA should be standardized in fundamental layer of technology architecture
w.r.t versions
The core specifications found in SOA are shown in Fig. 5.5.4.
While designing the care should be taken to adher to the firm set of design
standards to achieve successful SOA.
1. Entity centric business service design :
As shown in Fig. 5.6.1 the purpose of entity centric business service is accurate
representation of data entities in organizational business model.
These services can be reused by any application which wants to access or manage
information of particular entity.
The step by step design process description of entity centric business service design
is shown in Fig. 5.6.2. (See Fig. 5.6.2 on next page)
Please note that the order of executions these step can be altered according to the
need.
But at the end the case should be taken to apply the design standards equally to all
the operations.
The process can be described step by step as follows :
Step 1 : Review existing services :
o It is necessary to confirm that the service which is getting designed in required
or not.
o It is should be ensured that if these exists a service which is providing all the
functionalities or the context in the operation candidates.
Process Description
Fig. 5.6.4 shows the step of application service design process.
The stepwise description can be given as follows :
Fig. 5.6.3 Application service establish the bottom sub-layer of the service layer
Fig. 5.6.5 Task-centric business services can comprise the business service layer,
along with entity-centric neighbors
Process description
Fig. 5.6.6 shows the task centric business service design process.
Fig. 5.7.1 A concrete definition of a process service designed using a process modeling tool
The gap can be eliminated by operational business modeling languages like WS-
BPEL, through which technical analyst and architects graphically create business
process diagrams.
The requirement of using these tools is uses should have sufficient knowledge of
these tools.
Fig. 5.7.1 explains this, where analysts vision of the process of front end and
computer executable process on back end is given to architects and developers for
immediate implementation.
Process description :
Similar to task-centric business service design the high level process of designing
business process can be formulated as shown in Fig. 5.7.2.
These steps is the guideline WS-BPEL process definition
The stepwise description can be given as follows :