Академический Документы
Профессиональный Документы
Культура Документы
PART-A
1. What is XML? (April/May 2017, Nov/Dec 2017)
XML stands for ―Extensible markup language‖ a language developed by the World wide
web consortium (W3C).It is considered a meta language because it is used To define other
languages through the use of markup language ,which add structure and Meaning to document.
1
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
7. What are the different revolution in which XML is playing a major role?
a)Data revolution b)Architectural revolution c)Software revolution
8. What are the advantages of xml?
Simplicity - XML files are human readable
Openness - Widespread industry support
Extensibility – There is no fixed set of tags. New tags can be created as they are needed (User
defined tags).
Major relational databases have the native capability to read and generate XML data
Large family of XML support technologies is available.
9. What are entities? Give Example.
Entities are used to create substitution strings within a xml document. Example: Xml and data
evaluation can be defined with short string using entity declaration in DTD
10. List the advantages of XML over HTML.
XML is not a replacement for HTML, XML and HTML were designed with different goals:
XML was designed to transport and store data, with focus on what data is
HTML was designed to display data, with focus on how data looks
HTML is about displaying information, while XML is about carrying information.
11. List the industries where XML is used.
For exchanging between data in the internet, there are thousands of XML formats exist, for many
industries, to describe day-today-transactions.
-Stocks and shares -Scientific measurements -Financial transactions - Medical data -New
information -Weather services -Mathematical data
12. What are the advantages of schema over DTD?
It provides more control over the type of data that can be assigned to elements and as
compared to DTD.
DTD does not enable you to define your own customized data types. But
schema definition enables you to create your own data types and also allows specifying
restrictions on data.
The syntax for defining DTD is different from the syntax used for creating an
xml document .But the syntax for defining XSD is the same as the syntax of an xml
document.
13. Define DTD and its types.
• Allows developers to create a set of rules to specify legal content and place restrictions on
an XML file, Parser generates error: if XML document does not follow the rules contained
within DTD
Well Formed XML-Syntax is correct, Valid XML-Well formed, Validated against
a DTD/Schema
14. What is DTD? How is it different from XML schema?
DTD stands for Document Type Definition
DTD is a description of the structure & the elements and attributes that define a class of
XML document.
DTD can be declared both internally in a XML document and as an external reference.
DTD Xml Schema
DTD is used to define the Xml schema is used to define the
structure of an xml document. structure of an xml document.
Data type for elements limited to Numerous predefined data types
text available.
Complex data types cannot be Ability to define complex type
defined. that map to application data
structure.
DTD document is stored as Xml schema document is stored
―filename.dtd‖ as ―filename.xml‖
2
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
15. What is W3C (World Wide Web)Consortium?
W3c is responsible for the development of web specifications that describe
communication protocols and technologies for the web .XML was defined by w3c to
ensure that structured data is uniform and independent of vendors of applications.W3c
has laid down certain rules that meet to be followed by the all xml applications.
Some of these rules are:
XML must be directly usable over the internet.
XML must support the wide variety of applications.
XML must be SGML.
XML documents must be human legible and clear.
XML design must be formal and concise.
3
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
21. What is an X-file?
XFiles is for hand coders. This means you will need to call the xFiles methods within your code,
for example self.Init(), self.Load() and self.Save(). This accessory is not purely template driven
and requires hand-coding to operate.
4
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
<staff id="1001">
<firstname>yong</firstname>
<lastname>mook kim</lastname>
<nickname>mkyong</nickname>
<salary>100000</salary>
</staff>
<staff id="2001">
<firstname>low</firstname>
<lastname>yin fong</lastname>
<nickname>fong fong</nickname>
<salary>200000</salary>
</staff>
</company>
2. Explain the XML document structure. (April/May 2017)
XML document consists of a number of discrete components or sections.
Although not all the sections of an XML document may be necessary, their use and inclusion helps to make
for a well-structured XML document that can easily be transported between systems and devices. The major
portions of an XML document include the following:
The XML declaration
The Document Type Declaration
The element data
The attribute data
The character data or XML content
a.XML Declaration
The first part of an XML document is the declaration.
is exactly as it sounds: It is a definite way of stating exactly what the document
A declaration
contains.
The XML declaration states that the following document contains XML content.
The XML declaration is a processing instruction of the form <?xml ...?>
Although it is not required, the presence of the declaration explicitly identifies the document as an
XML document and indicates the version of XML to which it was authored.
declaration indicates the presence of external markup declarations and
In addition, the XML
character encoding.
The XML declaration consists of a number of components.
5
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
The standalone document declaration defines whether an external DTD will be processed as part of the
XML document.
When standalone is set to ―yes‖, only internal DTDs will be allowed. When it is set to ―no‖, an
external DTD is required and an internal DTD becomes an optional feature.
Listing. illustrates a few valid XML declarations:
<?xml version= ―1.0‖ standalone= ―yes‖?>
<?xml version= ―1.0‖ standalone= ―no‖?>
<?xml version= ―1.0‖ encoding= ―UTF-8‖ standalone= ―no‖?>
The first declaration defines a well-formed XML document, whereas the second defines a well-formed
and valid XML document. The third declaration shows a more complete definition that states a typical
use-case for XML. Namely, the declaration states that the XML document complies with version 1.0
of the specification and requires external markup declarations that are encoded in UTF-8.
b.Document Type Declaration
Once we are aware that we are talking about a specific version of an XML document, the next step is
to be more specific about the content contained within. The Document Type Declaration
(DOCTYPE) gives a name to the XML content and provides a means to guarantee the document’s
validity, either by including or specifying a link to a Document Type Definition (DTD).
Eg. of DTD:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE note SYSTEM "Note.dtd">
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
Note.dtd
<!DOCTYPE note
[
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
Although well-formed XML documents don‟t require the inclusion of the DOCTYPE, valid XML
documents do.
A Document Type Declaration names the document type and identifies the internal content by
specifying the root element, in essence the first XML tag that the XML-processing tools will
encounter in the document.
A DOCTYPE can identify the constraints on the validity of the document by making a reference to
an external DTD subset and/or include the DTD internally within the document by means of an
internal DTD subset.
7
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
XML is a hierarchical tree -This means that XML elements exist within other elements and
can branch off with various children nodes. This means that a single XML element can
of child elements, and the depth of the XML tree can consist of any
contain any number
number of nodes.
e.Attributes
can be communicated to XML processors that modify the
Within elements, additional information
nature of the encapsulated content.
Eg: we may have specified a <price> element to create a <currency> subtag.
Attributes are name/value pairs contained within the start element that can specify text strings that
modify the context of the element.
LISTING. Attribute Examples
<price currency= ―USD‖>…</price>
<on_sale start_date= ―10-15-2001‖/>
There are times when we want to introduce special characters or make use of content thatis
constantly repeated without having to enter it multiple times. This is the role of the XML entity.
Entities provide a means to indicate to XML-processing applications that a special text string is to
follow that will be replaced with a different literal value.
Entities can solve some intractable problems.
would
For example, how do we insert a greater-than or less than sign in our text? XML processors
interpret those characters as parts of an XML tag, which may not be our desired result.
declaration in a DTD or XML
Each entity has a unique name that is defined as part of an entity
Schema. Entities are used by simply referring to them by name.
Entity references are delimited by an ampersand at the beginning and a semicolon at the ending.
The content contained between the delimiters is the entity that will be replaced.
For example, < entity inserts the less-than sign (<) into a document.
Elements can be encoded so they aren‟t processed or replaced by their entity equivalents in order
to be used for display or encoding within other element values.
For example, the string <element> can be encoded in an XML document as < element> and
it will not be processed.
There are 5 pre-defined entity references in XML:
9
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
This means that elements, entity references, comments, and processing instructions are all ignored
and passed as string literals to processing applications.
CDATA instructions must exist in the context of XML elements and not as standalone entities.
• In a namespace-aware XML application, all element and attribute names are considered
qualified names
– A qualified name has an associated expanded name that consists of a namespace name and a
local name
– Ex: <table> is a qualified name with expanded name <null, table>
– Ex: <h:table> is a qualified name with expanded name
< http://www.w3.org/TR/html4, table>
Name Conflicts
In XML, element names are defined by the developer. This often results in a conflict when
trying to mix XML documents from different XML applications. This XML carries HTML
table information:
<table>
<tr>
<td>Apples</td>
<td>Bananas</td>
</tr>
</table>
This XML carries information about a table (a piece of furniture):
<table>
<name>African Coffee Table</name>
<width>80</width>
<length>120</length>
</table>
If these XML fragments were added together, there would be a name conflict. Both contain a
<table> element, but the elements have different content and meaning.An XML parser will
not know how to handle these differences.
Solving the Name Conflict Using a Prefix
When using prefixes in XML, a so-called namespace for the prefix must be defined. The
namespace is defined by the xmlns attribute in the start tag of an element. The namespace
declaration has the following syntax.
xmlns:prefix="URI".
<root>
<h:table xmlns:h="http://www.w3.org/TR/html4/">
<h:tr> <h:td>Apples</h:td> <h:td>Bananas</h:td> </h:tr>
</h:table>
10
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
<f:table xmlns:f="http://www.w3schools.com/furniture">
<f:name>African Coffee Table</f:name>
<f:width>80</f:width>
<f:length>120</f:length>
</f:table>
</root>
4. Explain in detail the XML schema, built in and user defined data type in detail.
(Nov/Dec 2016)(Nov/Dec 2017)
XML SCHEMA
XML Schema is an XML-based alternative to DTD.
An XML schema describes the structure of an XML document.
The XML Schema language is also referred to as XML Schema Definition (XSD).
The purpose of an XML Schema is to define the legal building blocks of an XML document,
just like a DTD.
An XML Schema:
• defines elements that can appear in a document
• defines attributes that can appear in a document
• defines which elements are child elements
• defines the order of child elements
• defines the number of child elements
• defines whether an element is empty or can include text
• defines data types for elements and attributes
• defines default and fixed values for elements and attributes
DTD FILE:
<!ELEMENT note (to, from, heading, body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
note.xsd:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com"
elementFormDefault="qualified">
<xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
11
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Reference to Schema:
<?xml version="1.0"?>
<note
xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3schools.com note.xsd">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
Simple Element
A simple element is an XML element that contains only text. It cannot contain any other
elements or attributes.
A default value is automatically assigned to the element when no other value is specified.
<xs:element name="color" type="xs:string" default="red"/>
A fixed value is also automatically assigned to the element, and you cannot specify another
value.
<xs:element name="color" type="xs:string" fixed="red"/>
Complex Element
A complex element is an XML element that contains other elements and/or attributes.
Kinds of complex elements:
Empty elements
Elements that contain only other elements
A complex XML element, "product", which is empty:
<product pid="1345"/>
Define a complex element that contain attributes.
<xs:attribute name="lang" type="xs:string" default="EN"/>
<xs:attribute name="lang" type="xs:string" fixed="EN"/>
<xs:attribute name="lang" type="xs:string" use="required"/>
A complex XML element, "employee", which contains only other elements:
<employee>
<firstname>John</firstname>
<lastname>Smith</lastname>
</employee>
Define a complex element that contain other elements in an XML Schema two different ways
1. Only the "employee" element can use the specified complex type
<xs:element name="employee">
<xs:complexType>
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:sequence>
12
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
</xs:complexType>
</xs:element>
2. Several elements can refer to the same complex type
<xs:element name="employee" type="personinfo"/>
<xs:element name="student" type="personinfo"/>
<xs:element name="member" type="personinfo"/>
<xs:complexType name="personinfo">
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:sequence>
</xs:complexType>
5. Discuss in detail about XML DTDs, and their types with suitable examples.(Nov/Dec 2016)
XML DOCUMENT TYPE DEFINITION:
• Allows developers to create a set of rules to specify legal content and place restrictions on an
XML file
• Parser generates error, if XML document does not follow the rules contained within DTD
• Including a DTD
– Using internal declaration
– Using external file
– Both
• For custom documents
• Uses DOCTYPE declaration
Internal (standalone) DTD:
hello.xml:
<!DOCTYPE greeting [
<!ELEMENT greeting (#PCDATA)>
]>
<greeting>Hello, world!</greeting>
• Specify in XML declaration
<?xml version="1.0" standalone="yes"?>
greeting>Hello, world!</greeting>
External DTD:
• Most common dtd.
• Use DOCTYPE declaration before root element
hello.dtd:
<!DOCTYPE greeting [
<!ELEMENT greeting (#PCDATA)>
]>
hello.xml:
<!DOCTYPE greeting SYSTEM "hello.dtd">
<?xml version="1.0" standalone=―no"?>
<greeting>Hello, world!</greeting>
Example
<!ELEMENT message (from, to, body)>
<!ELEMENT address (street, city, zip)>
14
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
<!ELEMENT message (from, to, body)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT body (#PCDATA)>
<!ELEMENT address (street, city, zip)>
<!ELEMENT street (#PCDATA)>
<!ELEMENT city (#PCDATA)>
<!ELEMENT zip (#PCDATA)>
Occurrence Indicators:
Term Meaning Example
, Sequence Operators a, b, c
+ One or more a+
* Zero or more a*
? Single optional a?
() grouping (a)
DECLARING ATTRIBUTES:
General Syntax
<!ATTLIST elementName attributeName attributeType defaultType>
Example
<!ATTLIST HDD speed CDATA ―7200‖>
<!ATTLIST HDD unit CDATA #IMPLIED>
<!ATTLIST price currency CDATA ―INR‖>
<!ATTLIST question number ID #REQUIRED>
<HDD speed=―6000‖> … </HDD>
<price currency=―USD‖>10</price>
<question number=―1‖> … </question>
The attribute-type can be one of the following:
Type Description
15
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
Value Explanation
6. Describe in detail how to create well-formed XML and write about XML Parsers. (April/MAY
2017) (or) Brief well-formed XML document. Also differentiate well-formed and valid XML
document.
17
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
XML parsers
• Two types of XML parsers:
– Validating
• Requires document type declaration
• Generates error if document does not
– Conform with DTD and
– Meet XML validity constraints
» Example: every attribute value of type ID must be unique within the document
– Non-validating
• Checks for well-formedness
• Can ignore external DTD
XML
document
Optimize
XML XML d XML
schema Parser document
Error
message
DECLARING ELEMENTS:
An empty element
<!ELEMENT elementName (EMPTY)>
Example
<!ELEMENT br (EMPTY)>
<!ELEMENT Bool (EMPTY)>
Usage:
<br/>
<Bool Value="True"></Bool>
19
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
<!ELEMENT to (#PCDATA)>
<!ELEMENT body (#PCDATA)>
<!ELEMENT address (street, city, zip)>
<!ELEMENT street (#PCDATA)>
<!ELEMENT city (#PCDATA)>
<!ELEMENT zip (#PCDATA)>
DECLARING ATTRIBUTES:
General Syntax
<!ATTLIST elementName attributeName attributeType defaultType>
Example
<!ATTLIST HDD speed CDATA ―7200‖>
<!ATTLIST HDD unit CDATA #IMPLIED>
<!ATTLIST price currency CDATA ―INR‖>
<!ATTLIST question number ID #REQUIRED>
<HDD speed=―6000‖> … </HDD>
<price currency=―USD‖>10</price>
<question number=―1‖> … </question>
Type Description
Value Explanation
20
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
Examples--#REQUIRED:
DTD:
<!ATTLIST person number CDATA #REQUIRED>
Valid XML:
<person number="5677" />
Invalid XML:
<person />
Examples--#IMPLIED:
DTD:
<!ATTLIST contact fax CDATA #IMPLIED>
Valid XML:
<contact fax="555-667788" />
valid XML:
<contact />
Examples--#FIXED:
DTD:
<!ATTLIST sender company CDATA #FIXED "Microsoft">
Valid XML:
<sender company="Microsoft" />
Invalid XML:
<sender company="W3Schools" />
Examples—Enumerated:
DTD:
<!ATTLIST payment type (check|cash) "cash">
XML example:
<payment type="check" /> or <payment type="cash" />
DECLARING ENTITIES:
General Syntax
<!ENTITY entityName ―entityValue‖>
Example
<!ENTITY euro ―€‖> //€
<!ENTITY language ―XML‖>
<!ENTITY W3C ―World Wide Web Consortium‖>
<!ENTITY copyright ―©‖> //
<!ENTITY USD SYSTEM ―currency.dtd‖>
<tutorial>
&language; is standardized by &W3C;
©right; UKR
</tutorial>
8. Explain the element types and Order, Occurrence indicators in XML Schema.
Indicators
Order indicators:
Order indicators are used to define the order of the elements.
All
21
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
The <all> indicator specifies that the child elements can appear in any order, and that each child
element must occur only once:
Choice
The <choice> indicator specifies that either one child element or another can occur:
Sequence
The <sequence> indicator specifies that the child elements must appear in a specific order:
Occurrence indicators:
maxOccurs
The <maxOccurs> indicator specifies the maximum number of times an element can occur:
minOccurs
The <minOccurs> indicator specifies the minimum number of times an element can occur:
Schema:
<xs:element name="person">
<xs:complexType>
<xs:sequence> or <xs:choice> or <xs:all>
<xs:element name="full_name" type="xs:string"/>
<xs:element name="child_name" type="xs:string"
maxOccurs="10" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
Xml:
<person>
<full_name>Tove Refsnes</full_name>
<child_name>Hege</child_name>
<child_name>Stale</child_name>
<child_name>Jim</child_name>
<child_name>Borge</child_name>
</person>
9. Create an External DTD containing 5 Elements, 3 attributes and 2 Entities, then write an
XML code to match the corresponding DTD. (or) Create a DTD that defines the structure for
e-mail message; further create a XML document that refers to the created document type
definition. (Nov/Dec 2016)
tutorials.dtd:
<!ELEMENT tutorials (tutorial)+>
<!ELEMENT tutorial (name,url)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT url (#PCDATA)>
<!ATTLIST tutorials type CDATA #REQUIRED>
<!ATTLIST tutorial id ID #REQUIRED>
<!ENTITY copyright ―©‖>
tutorials.xml:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE tutorials SYSTEM "tutorials.dtd">
<tutorials type="web">
<tutorial id="1" >
<name>XML Tutorial ©right; </name>
<url>http://www.quackit.com/xml/tutorial</url>
</tutorial>
<tutorial id="2" >
<name>HTML Tutorial©right; </name>
<url>http://www.quackit.com/html/tutorial</url>
22
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
</tutorial>
</tutorials>
DTD that defines the structure for e-mail message
Syntax: <!ENTITY entity-name "entity-value">
DTD Example:
<!ENTITY writer "Donald Duck.">
<!ENTITY copyright "Copyright W3Schools.">
XML example:
<author>&writer;©right;</author>
A doctype declaration can also be used to define special characters and character strings, used in the
document:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE note [
<!ENTITY nbsp " ">
<!ENTITY writer "Writer: Donald Duck.">
<!ENTITY copyright "Copyright: W3Schools.">
]>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
<footer>&writer; ©right;</footer>
</note>
An External Entity Declaration
Syntax: <!ENTITY entity-name SYSTEM "URI/URL">
DTD Example:
<!ENTITY writer SYSTEM "http://www.w3schools.com/entities.dtd">
<!ENTITY copyright SYSTEM "http://www.w3schools.com/entities.dtd">
XML example:
<author>&writer;©right;</author>
Type Description
23
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
Value Explanation
24
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
General Syntax
<!ENTITY entityName ―entityValue‖>
Example
<!ENTITY euro ―€‖> //€
<!ENTITY language ―XML‖>
<!ENTITY W3C ―World Wide Web Consortium‖>
<!ENTITY copyright ―©‖> //
<!ENTITY USD SYSTEM ―currency.dtd‖>
<tutorial>
&language; is standardized by &W3C;
©right; UKR
</tutorial>
10. Explain XML files: XPath, XPointer and XLink in detail.(Nov/Dec 2016)
X-Files is a collection of classes for hand-coders. It was built primarily to provide a simple and
exceptionally high-performance method to convert xml files or strings to Clarion data structures, and
vice-versa. xFiles explains about XPath, XLink, and XPointer.
XPath
The XML Path Language (XPath) is a standard for creating expressions that can be
used to find specific pieces of information within an XML document.
XPath expressions are used by both XSLT (forwhich XPath provides the core
functionality) and XPointer to locate a set of nodes.
To understand how XPath works, it helps to imagine an XML document as a tree of
nodes consisting of both elements and attributes.
XPath expressions have the ability to locate nodes based on the nodes‟ type, name, or value or by
the relationship of the nodes to other nodes within the XML document.
In addition to being able to find nodes based on these criteria, an XPath expression can return any of
the following: A node set, A Boolean value, A string value and A numeric value.
Similarity between URLs and XPath expressions
URLs represent a navigation path of a hierarchical file system, and XPath expressions represent a
navigation path for a hierarchical tree of nodes.
Operators and Special Characters
XPath expressions are composed using a set of operators and special characters, each with its own
meaning. Table.1 lists the various operators and special characters used within the XML Path
Language.
TABLE.1 Operators and Special Characters for the XML Path Language
25
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
The above table provides a list of operators and special characters that can be used within an XPath
expression. The table does not indicate what the order of precedence is.
The priority for evaluating XPath expressions: 1. Grouping, 2. Filters, 3. Path operations
XPath Syntax
The XML Path Language provides a declarative notation, termed a pattern, used to select the desired
set of nodes from XML documents.
Each pattern describes a set of matching nodes to select from a hierarchical XML document. Each
pattern describes a ―navigation‖ path to the desired set of nodes similar to the URI.
Each ―query‖ of an XML document occurs from a particular starting node defines the context for the
query.
The context for the query has a very large impact on the results.
One possible result from performing an XPath query is a node set, or a collection of nodes matching
specified search criteria.
To receive these results, a ―location path‖ is needed to locate the result nodes.
These location paths select the resulting node set relative to the current context.
The XML document shown in Listing.1 describes how the current context node is defined.
</a>
X- Pointer
The
XML Pointer Language (XPointer), currently in thecandidate recommendation stage of the
W3C approval process, builds on the XPath specification.
An XPointer uses location steps the same as XPath but with two major differences:
Because an XPointer describes a location within an external document, an XPointer
can target a
point within that XML document or a range within the target XML document.
Because
XPointer builds on the XPath specification, the location steps within an XPointer are
comprised of the same elements that make up XPath location steps.
The axes for XPointer are the same as the axes for XPath.
The node tests for an XPointer are, for the most part, the same as for an XPath node test.
In
addition to the node tests already listed
for XPath expressions, XPointer provides two more
important node tests: point() and range().
Within XPointer, a location can be an XPath node, a point, or a range.
A point can represent the location immediately
before or after a specified character or the location
just before or just after a specified node.
A
range consists
of a start point and an endpoint and contains all XML information between those
two points.
As with XPath expressions, XPointer expressions have specific functions to deal with each specific
predicate type.
The XPointer specification also adds an additional function named unique().
This new function indicates whether an XPointer expression selects a single location rather than
multiple locations or no locations at all.
For
an XPath expression, the result from a location step is known as a node set; for an XPointer
expression, the result is known as a location set.
26
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
Four of the functions that return location sets, id(), root(), here(), and origin(), have the differences.
TABLE 1. Some XPointer Functions that return Location Sets
Points
Many
times a link
from one XML document into another must locate a specific point within the
target document.
Two different types of points can be represented using XPointer points:
Node points and Character points
Node points are location points in an XML document that are nodes that contain child nodes. For
these node points, the index position indicates after which child node to navigate to.
If 0 is specified for the index, the point is considered to be immediately before any child nodes. A
node point could be considered to be the gap between the child nodes of a container node.
When the origin node is a text node, the index position indicates the number of characters. These
location points are referred to as character points.
Because you are indicating the number of characters from the origin, the index specified must be an
integer greater than or equal to 0 and less than or equal to the total length of the text within the text node. By
specifying 0 for the index position in a character point, the point is considered to be immediately before the
first character in the text string.
For a character point, the point represents the space between the characters of a text
string.
How does the XPointer work?
Use the sample XML document shown in listing which is a XML document containing a list of names and
addresses.
LISTING . Sample3.xml Contains a Small List of Names and Addresses
<People>
<Person>
<Name>Dillon Larsen</Name>
<Address>
<Street>123 Jones Rd.</Street>
<City>Houston</City>
<State>TX</State>
<Zip>77380</Zip>
</Address>
</Person>
<Person>
<Name>Madi Larsen</Name>
<Address>
<Street>456 Hickory Ln.</Street>
<City>Houston</City>
<State>TX</State>
<Zip>77069</Zip>
</Address>
</Person>
TABLE 2. Examples of XPointer Points and the Resulting Locations
27
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
Ranges
An XPointer range defines just that—a range consisting of a start point and an endpoint.
A range will contain the XML between the start point and endpoint but does not
necessarily have to consist of neat subtrees of an XML document.
A range can extend over multiple branches of an XML document. The only criterion is
that the start point and endpoint must be valid.
TABLE 3. XPointer Range Functions
The following expression specifies a range beginning at the first character in the <Name> element for
Dillon Larsen and ending after the ninth character in the <Name> element for Dillon Larsen:
/People/Person[1]/Name/text()start-point()[position()=0] to ➥/People/Person[1]/Name/text()start-
point()[position()=9]
In this example, two node points are used as the starting and ending points for the range.
The result is the string Dillon La. Table lists the various range functions available.
The XML Pointer Language also has the ability to perform basic string matching by using a function
named string-range().
This function returns a location set with one range for every nonoverlapping match to the search string
by performing a case-sensitive search. The general syntax for string-range() is as follows: string-
range(location-set, string, [index, [length]])
The location-set argument for the string-range() function is any XPointer expression that would create
a location set as its result—for instance, /, /People/Person,/People/Person[1], and so on.
XLink:
The anchor element, <a>, within HTML indicates a link to another resource on an
HTML page. Thiscould be a location within the same document or a document
located elsewhere.
In HTML terms, the anchor element creates a hyperlink to another location. The
hyperlink
can either appear as straight text, a clickable image, or a combination of
both.
The XML Linking Language, XLink, addresses and overcomes these limitations by
allowing a link to another document to be specified on any element within an XML
document.
The XML Linking Language creates a link to another resource through the use of
attributes specified on elements, not through the actual elements themselves.
The XML Linking Language specification supports the attributes are listed below.
TABLE. XLink Attributes
28
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
XML Linking Language offers two major types of links: simple and extended.
Within XLink, a simple link is a convenient, shorthand notation by which to associate two resources. These
resources—one local and one remote—are connected by an arc, always making a simple link an outbound
link. An extended link associates any number of resources together. Those resources may be both local and
remote.
i.Simple Links
A simple link combines the functionality provided by the different pieces available through an extended link
together into a shorthand notation.
A simple link consists of an xlink:type attribute with a value of simple and, optionally, an xlink:href attribute
with a specified value.
A simple link may have any content, and even no content; it is up to the application to provide some means
to generate a traversal request for the link.
If no target resource is specified with the xlink:href attribute, the link is simply considered ―dead‖ and will
not be traversable.
ii.Extended Links
Within the XML Linking Language, extended links give you the ability to specify relationships
between an unlimited number of resources, both local and remote.
These links can involve multiple paths between the linked resources. Local resources are part of the actual
extended link, whereas remote resources identify external resources to the link.
An out-of-line link is created when there are no local resources at all for a link. LISTING.
Sample4.xml Contains a Modified Version of the Names List in Sample3.xml <People
xmlns:xlink= ―http://www.w3.org/1999/xlink‖
➥xlink:type= ―extended‖ xlink:title= ―Phone book‖>
<Person>
<Name>Dillon Larsen</Name>
<Address>
<Street>123 Jones Rd.</Street>
<City>Houston</City>
<State>TX</State>
29
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
<Zip>77380</Zip>
</Address>
</Person>
<Person xlink:type= ―resource‖ xlink:label= ―John‖>
<Name>John Smith</Name>
<Spouse xlink:type= ―resource‖ xlink:label= ―JohnSpouse‖>Jane Smith</Spouse>
<Address>
<Street>522 Springwood Dr.</Street>
<City>Houston</City>
<State>TX</State>
<Zip>77069</Zip>
</Address>
</Person>
<Marriage xlink:type= ―arc‖ xlink:from= ―JohnSpouse‖
➥xlink:to= ―Jane‖ xlink:actuate= ―onRequest‖ xlink:show= ―new‖/>
<Marriage xlink:type= ―arc‖ xlink:from= ―JaneSpouse‖
➥xlink:to= ―John‖ xlink:actuate= ―onRequest‖ xlink:show= ―new‖/>
</People>
11. Discuss XML attributes and entities in Detail.
DECLARING ATTRIBUTES:
General Syntax
<!ATTLIST elementName attributeName attributeType defaultType>
Example
<!ATTLIST HDD speed CDATA ―7200‖>
<!ATTLIST HDD unit CDATA #IMPLIED>
<!ATTLIST price currency CDATA ―INR‖>
<!ATTLIST question number ID #REQUIRED>
<HDD speed=―6000‖> … </HDD>
<price currency=―USD‖>10</price>
<question number=―1‖> … </question>
The attribute-type can be one of the following:
Type Description
30
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
Value Explanation
Examples--#FIXED:
DTD:
<!ATTLIST sender company CDATA #FIXED "Microsoft">
Valid XML:
<sender company="Microsoft" />
Invalid XML:
<sender company="W3Schools" />
Examples—Enumerated:
DTD:
<!ATTLIST payment type (check|cash) "cash">
XML example:
<payment type="check" /> or <payment type="cash" />
DECLARING ENTITIES:
General Syntax
<!ENTITY entityName ―entityValue‖>
Example
<!ENTITY euro ―€‖> //€
<!ENTITY language ―XML‖>
<!ENTITY W3C ―World Wide Web Consortium‖>
<!ENTITY copyright ―©‖> //
<!ENTITY USD SYSTEM ―currency.dtd‖>
<tutorial>
&language; is standardized by &W3C;
©right; UKR
</tutorial>
31
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
5. What is XQuery?
XQuery is a W3C initiative to define a standard set of constructs for querying and searching
XML documents. XQuery brings database query processing to XML.
6. What are all the Transformation techniques?
XSLT - it is an XML- based languages used to transform XML documents into others format such as
HTML for web display.
XLINK - highlighting that element or taking the user directly to that point in the document.
XPATH - xpath gets its name from its use of a payh notation to navigate through the hierarchical tree
structure of an XML document
7.
What isXQUERY
XForm? - it is W3C initiative to define a standard set of constructs for querying & searching
XMLXForm
document.
is an XML approach that overcomes the limitations of HTML forms. XForm
includes a variety of buttons, scrollbars and menus. It generates XML form data as output.
XForm's model has the capability to work with the variety of user interfaces.
32
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
10. What input files passed to XSLT Processor?
The Extensible Stylesheet Language (XSL) is an XML vocabulary typically used to transform XML
documents from one form to another form
SAX Parser − Parses an XML document on event-based triggers. Does not load the complete document into the
memory.
Disadvantages of SAX
We have no random access to an XML document since it is processed in a forward-only manner.
If you need to keep track of data that the parser has seen or change the order of items, you must write
the code and store the data on your own.
33
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
16. Write a simple stylesheet using XSL. (Nov/Dec 2016)
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<tr>
<td>.</td>
<td>.</td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
17. Explain any two XForm implementations?
X-Smiles - it is a java based XML browser.it implements a large part of X-forms & uses X-form together with
XSL-FO on user interface side. Mozquito Xforms preview - is an XML based Web developement s/w that
implements Xforms & gives current Web browser the ability to send,receive & process XML document.
34
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
22. How a table is represented un XML.
Each table of the database is represented by an element node with the records as its children:
<customer>
record1
record2
...
recordm
</customer>
23. How a database is modelled using XML.
We can model the database with a document node and its associated element node:
<?xml version=―1.0‖ ?>
<myDatabase>
table1
table2
...
tablen
</myDatabase>
Order of tables is immaterial
24. What are the major types of XML databases?
There are two major types of XML databases:
XML-enabled. These map all XML to a traditional database (such as a database), accepting XML as input and
rendering XML as output.
Native XML (NXD) The internal model of such databases depends on XML and uses XML documents as the
fundamental unit of storage.
25. What is meant by XSL Formatting? (April/May 2017)
XSL-Formatting or XSL-FO (XSL Formatting Objects) is a markup language for XML document
formatting that is most often used to generate PDF files. XSL-FO is part of XSL (Extensible
Stylesheet Language), a set of W3C technologies designed for the transformation and formatting of
XML data. The other parts of XSL are XSLT and XPath.
26. Compare CSS and XSL.
CSS XSL
CSS can be used with HTML XSL can‗t be used in HTML
CSS is not a transformation language XSL is a transformation language
CSS does not have the formatting object differently
from the source tree. XSL is having the formatting object differently from
the source tree.
CSS provides the inheritance of the formatting XSL cant provide the inheritance of the formatting
object that is related to the source tree Part-B object that is related to the source tree
1. Given an XSLT document and a source XML document explain the XSLT transformation
process that produces a single result XML document.(April/May 2017)
• The Extensible Stylesheet Language (XSL) is an XML vocabulary typically used to transform
XML documents from one form to another form
XSL document
35
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
• JAXP allows a Java program to use the Extensible Stylesheet Language (XSL) to extract data
from one XML document, process that data, and produce another XML document containing the
processed data.
For example, XSL can be used to extract information from an XML document and embed it within
an XHTML document so that the information can be viewed using a web browser.
TRANSFORMER:
Main.java:
import java.io.FileOutputStream;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
public class Main
{
static String xml="D://WebTech//trans.XML";
static String xslt="D://WebTech//trans.XSL";
static String output="D://WebTech//trans.HTML";
public static void main(String[] args)
{
try
{
TransformerFactory tf = TransformerFactory.newInstance();
Transformer tr = tf.newTransformer(new StreamSource(xslt));
tr.transform(new StreamSource(xml),new StreamResult(new FileOutputStream(output)));
System.out.println("Output to " + output);
}
catch(Exception e)
{
}
}
}
trans.xsl:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h1>Indian Languages details</h1>
<table border="1">
<tr>
<th>Language</th>
<th>Family/Origin</th>
<th>No. of speakers</th>
<th>Region</th>
</tr>
<xsl:for-each select="language">
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="family"/></td>
<td><xsl:value-of select="users"/></td>
<td><xsl:value-of select="region"/></td>
</tr>
36
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
trans.xml:
<?xml version="1.0"?>
<!--<?xml-stylesheet type="text/xsl" href="trans.xsl"?>-->
<language>
<name>Kannada</name>
<region>Karnataka</region>
<users>38M</users>
<family>Dravidian</family>
</language>
trans.html:
Indian Languages details
Language Family/Origin No. of speakers Region
Kannada Dravidian 38M Karnataka
2. Explain in detail about the various XML parsers with suitable examples. (Nov/Dec 2016)
(Nov/Dec 2017)
PARSING XML:
DOM BASED XML PROCESSING:
DOM:
• Include Java DOM API defined by org.w3c.dom package
• Nodes of DOM tree belong to classes such as Node, Document, Element, Text.
• Non-method properties of Node instances are accessed via methods
parentNode is accessed by calling getParentNode()
• Methods such as getElementsByTagName() (that returned an arraylike list of Node instances in
JavaScript) will in Java return an object implementing the NodeList interface.
PROGRAM:
DOM:
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import java.io.File;
public class Main {
public static void main(String[] args)
{
try
{
File fXmlFile = new File("D:/Web Tech/Staff1.XML");
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(fXmlFile);
System.out.println("RootSystem element :" + doc.getDocumentElement().getNodeName());
NodeList nodes = doc.getElementsByTagName("staff");
37
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
System.out.println("Input Elements has:" + nodes.getLength() + "nodes");
}
catch(Exception e)
{
System.out.println("XML Doc not Well formed" + e);
}
}
}
EVENT-ORIENTED PARSING: SAX-PARSER
SAX:
An alternative approach is to have the parser interact with an application as it reads an XML
document. This is the approach taken by SAX (Simple API for XML).
SAX allows an application to register event listeners with the XML parser.
SAX parser calls these listeners as events occur and passes them the information about the
events.
Main.Java:
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
public class Main
{
public static void main(String args[])
{
try
{
SAXParserFactory factory = SAXParserFactory.newInstance();
SAXParser saxParser = factory.newSAXParser();
saxParser.parse("D://Staff1.XML",new CountHelper());
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
CountHelper.JAVA:
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
public class CountHelper extends DefaultHandler
{
int no_elms;
/*CountHelper()
{
super();
}*/
@Override
public void startDocument() throws SAXException
{
no_elms=0;
//return;
}
@Override
public void startElement(String u,String ln,String qname,Attributes atts)
38
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
throws SAXException{
if(qname.equals("firstname"))
{
no_elms++;
}// return;
}
@Override
public void endDocument() throws SAXException
{
System.out.println("I/p Doc has " + no_elms + "firstname Elements");
}
}
Staff1.xml:
<?xml version="1.0"?>
<company>
<staff id="1001">
<firstname>yong</firstname>
<lastname>mook kim</lastname>
<nickname>mkyong</nickname>
<salary>100000</salary>
</staff>
<staff id="2001">
<firstname>low</firstname>
<lastname>yin fong</lastname>
<nickname>fong fong</nickname>
<salary>200000</salary>
</staff>
</company>
OUTPUT:
DOM OUTPUT:
RootSystem element :company
Input Elements has:2nodes
SAX OUTPUT:
I/p Doc has 2 firstname Elements
39
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
<rental_property>
<prop_id>1</prop_id>
<name>The Meadows</name>
<address>
<street>251 Eisenhower Blvd</street>
<city>Houston</city>
<state>TX</state>
<postal_code>77033</postal_code></address>
<square_footage>500.0</square_footage>
<bedrooms>1.0</bedrooms>
<bath>1.0</bath>
<price>600</price>
<contact>
<phone>555-555-1212</phone>
<fax>555-555-1414</fax?
</contact>
</rental_property>
In the JAXB framework, we can parse XML documents into a suitable Java object. This
technique is referred to as unmarshaling. The JAXB framework also provides the capability
to generate XML documents from Java objects, which is referred to as marshaling.
40
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
Most often the axes, e.g.: "descendant::", are followed by an "*" (element) or an element name
but comment(), processing-instruction() andtext-node() can also be used. Only root node and
elements can have children.
The construct node() only selects nodes being children of other
nodes: element(), text(), comment(), processing-instruction(). An attribute has a parent element
but attribute and namespace nodes are not children and not included in the node() construct or
type.
descendant::* All elements being children and children's children, etc, of context node.
descendant::stock All "stock" elements being children and children's children, etc, of
context node.
descendant::comment() All comment nodes being children of context node.
descendant::*|comment() All element and comment nodes being children or children's children,
etc, of context node.
descendant::node() All nodes being children or children's children, etc, of context node.
2. Axis diagrams
The diagrams are not showing attribute() and namespace() nodes and I have not made diagrams
for the attribute and namespace axes. The namespace axis is deprecated. The functions in-scope-
prefixes() and namespace-uri-for-prefix() should be used instead.
When using axes it is often important to remember that the nodes are processed in document
order (indicated below). If both a node's children and siblings are included in an axis, the node's
children are always processed before its following siblings. The order is sometimes a little tricky
especially for reverse axes until you get used to it. See the preceding axis as example.
2.1 ancestor
Ancestor axis: parent and parent's parent, etc.
41
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
2.6 following
Following axis: following siblings and their children and their children, etc.
2.7 following-sibling
Following-sibling axis: following siblings.
43
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
2.8 parent
Parent axis: The parent of context node.
India is context node, e.g.: if (parent::* eq 'Charlie') then '...' else '...'
2.9 preceding
Preceding axis: preceding siblings and their children and their children, etc.
44
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
2.10 preceding-sibling
Preceding-sibling axis: preceding siblings.
2.11 self
Self axis: context node.
45
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
Charlie is context node, e.g.: if (self::* eq 'Charlie') then '...' else '...'
47
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
/*CountHelper()
{
super();
}*/
@Override
public void startDocument() throws SAXException
{
no_elms=0;
//return;
}
@Override
public void startElement(String u,String ln,String qname,Attributes atts)
throws SAXException
{
if(qname.equals("firstname"))
{
no_elms++;
}
// return;
}
@Override
public void endDocument() throws SAXException
{
System.out.println("I/p Doc has " + no_elms + "firstname Elements");
}
}
Staff1.xml:
<?xml version="1.0"?>
<company>
<staff id="1001">
<firstname>yong</firstname>
<lastname>mook kim</lastname>
<nickname>mkyong</nickname>
<salary>100000</salary>
</staff>
<staff id="2001">
<firstname>low</firstname>
<lastname>yin fong</lastname>
<nickname>fong fong</nickname>
<salary>200000</salary>
</staff>
</company>
SAX OUTPUT:
I/p Doc has 2 firstname Elements
7. Write a XSLT program to extract XML document details and XSL formatting. (or) With
example show how XSLT can transform an XML document into HTML. (Nov/Dec 2016)
trans.xsl:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
48
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
<body>
<h1>Indian Languages details</h1>
<table border="1">
<tr>
<th>Language</th>
<th>Family/Origin</th>
<th>No. of speakers</th>
<th>Region</th>
</tr>
<xsl:for-each select="language">
<tr>
<td><xsl:value-of select="name"/></td>
<td><xsl:value-of select="family"/></td>
<td><xsl:value-of select="users"/></td>
<td><xsl:value-of select="region"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
trans.xml:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="trans.xsl"?>
<language>
<name>Kannada</name>
<region>Karnataka</region>
<users>38M</users>
<family>Dravidian</family>
</language>
trans.html:
Formatting Objects
o
To develop the XSL-FO file with the included data.
o
To dynamically create the XSL-FO file using an XSLT translation.
Once the document is created, we will use the Apache XSL-FOP formatter to convert the document to
a PDF file.
The application interaction is illustrated in Figure 1.
FIGURE 1 Apache XSL-FOP generating PDF
documents
//------------------------------------------------------------------
// Additional methods
//------------------------------------------------------------------
public void parse(JDBCInputSource source)
50
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
throws SAXException, IOException {
try {
Connection connection = source.getConnection();
if (connection == null) {
throw new SAXException("Could not establish connection with "
+ "database");
}
ResultSet rs = pstmt.executeQuery();
parse(rs, source.getTableName());
rs.close();
connection.close();
} catch (SQLException ex) {
throw new SAXException(ex);
}
}
_documentHandler.startDocument();
_documentHandler.startElement(tableMarker, _stockEmptyAttributeList);
while(rs.next()) {
_documentHandler.startElement(rowMarker,
_stockEmptyAttributeList);
for (int i = 1; i <= numCols; i++) {
generateSAXEventForColumn(rsmd, rs, i);
}
_documentHandler.endElement(rowMarker);
}
_documentHandler.endElement(tableMarker);
_documentHandler.endDocument();
}
//------------------------------------------------------------------
51
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
// Protected methods that derived classes could override to
// customize the parsing.
//------------------------------------------------------------------
protected void generateSAXEventForColumn(ResultSetMetaData rsmd,
ResultSet rs,
int columnIndex)
throws SAXException, SQLException {
String columnValue = rs.getString(columnIndex);
if (columnValue == null) {
return;
}
String columnMarker
= getColumnMarker(rsmd.getColumnLabel(columnIndex));
char[] columnValueChars = columnValue.toCharArray();
_documentHandler.startElement(columnMarker,
_stockEmptyAttributeList);
_documentHandler.characters(columnValueChars,
0, columnValueChars.length);
_documentHandler.endElement(columnMarker);
}
52
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
XSL:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited by XMLSpy® -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="cd">
<p>
<xsl:apply-templates select="title"/>
<xsl:apply-templates select="artist"/>
</p>
</xsl:template>
<xsl:template match="title">
Title: <span style="color:#ff0000">
<xsl:value-of select=".."/></span>
<br />
</xsl:template>
<xsl:template match="artist">
Artist: <span style="color:#00ff00">
<xsl:value-of select="."/></span>
<br />
</xsl:template>
</xsl:stylesheet>
Title: Empire Burlesque Bob Dylan USA Columbia 10.90 1985 (Parent)
Artist: Bob Dylan(Self)
10. Explain how XML database model is different from relational model,
S
relational database. The ideal solution is a database that can combine the flexibility of the
XML model with the performance of the relational model; that is, support for an XML data
type within a relational database. This XML data type would fully support the XML model,
both logically and physically, yet allow the data to be physically managed by a single
database.
Fundamental properties of XML that make it different from the relational model:
• XML is self-describing. A given document contains not only the data, but also the
necessary metadata. As a result, an XML document can be searched or updated without
requiring a static definition of the schema. Relational models, on the other hand, require
more static schema definitions. All the rows of a table must have the same schema.
53
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
• XML is hierarchical. A given document represents not only base information, but also
Information about the relationship of data items to each other in the form of the hierarchy.
Relational models require all relationship information to be expressed either by primary
key or foreign key relationships or by representing that information in other relations.
• XML is sequence-oriented—order is important. Relational models are set oriented—
order is unimportant.
None of these differences indicate that XML is better or worse than purely relational
models. In fact, XML and relational models are complementary solutions. Some data is
inherently hierarchical while other data is inherently tabular; some data has more rigid schema
while other data has less rigid schema; some data needs to follow a specific order while other
data does not.
11. Explain in detail about the modeling databases in XML. (Nov/Dec 2016) (April/May 2017)
Modeling Databases in XML using JAXB
When we model a database, we provide an external representation of the database contents.
We‗ll model the rental property database as an XML document. Figure 1 shows the desired output.
FIGURE 1. Desired output for rental properties
One possible solution is to use Java servlets and JDBC. Java servlets are server-side components that
reside in a Web server or application server.
Java servlets are used to handle requests from Web browsers using the HTTP protocol.
A key advantage to using servlets is the thin-client interface.
The servlets handle the request on the server side and respond by generating an HTML page
dynamically. This lowers the requirement on the client browser.
The browser has to provide support of HTML. There is zero client-side administration. Java applets
require the browser to support the correct version of the Java Virtual Machine (JVM). This has been a thorny
issue with the Java community. If the browser doesn‗t support Java, the applet will not execute. There are a
number of workarounds, such as the Java Plug-In and Java Web Start.
These technologies require an initial installation on the client machine—which can prove to be time
consuming and error prone.
We can develop a servlet that uses Java Database Connectivity (JDBC). The servlet will make the
appropriate query to the database and use JDBC API results set metadata to create the elements. We‗ll
leverage the XML data binding features of Java Architecture for XML Binding (JAXB). JAXB provides a
framework for representing XML documents as Java objects. Using the JAXB framework, we can guarantee
that the documents processed by our system are well-formed.
We have the option of validating the XML data against a schema. In the JAXB framework, we can
parse XML documents into a suitable Java object. This technique is referred to as unmarshaling. The JAXB
framework provides the capability to generate XML documents from Java objects, which is referred to as
marshaling. The process is illustrated in the Figure 2.
FIGURE 2. JAXB marshaling and unmarshaling
54
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
JAXB is easier to use and a more efficient technique for processing XML documents than the SAX
or DOM API.
Using the SAX API, you have to create a custom content handler for each XML document structure.
During the development of the content, you have to create and manage your own state machine to keep track
of your place in the document.
Using JAXB, an application can parse an XML document by unmarshaling the data from an
input stream. JAXB is similar to DOM in that we can create XML documents programmatically and
perform validation. The hindrance with DOM is the complex API.
If we have an XML tree, using the DOM API, we have to traverse through the tree to retrieve
elements. With JAXB, we retrieve the data from the XML document by calling a method on an object.
JAXB allows us to define Java objects that map to XML documents, so we can retrieve data. The JAXB
framework ensures the type safety of the data.
i.JAXB Solution
In the JAXB solution, we will model the rental property database as an XML document.
First we need to review the database schema. After reviewing the schema, we will develop our desired XML
document based on an XML schema.
After we have the XML schema developed, we can create the JAXB binding schema.
The JAXB binding schema contains instructions on how to bind the XML schema to a Java class.
We‗ll take the JAXB binding schema and generate the appropriate Java classes.
To summarize, we‗ll follow these steps:
1. Review the database schema.
2. Construct the desired XML document.
3. Define a schema for the XML document.
4. Create the JAXB binding schema.
5. Generate the JAXB classes based on the schema.
6. Develop a Data Access Object (DAO).
7. Develop a servlet for HTTP access.
We have an existing database for the rental properties. Table 1 contains the database schema.
55
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
The source code includes a sample MS Access database. The file is located at rental_property.mdb.
A rental property described with a root element of <rental_property>, as shown in the following code:
<rental_property>
<prop_id>1</prop_id>
<name>The Meadows</name>
<address>
<street>251 Eisenhower Blvd</street>
<city>Houston</city>
<state>TX</state>
<postal_code>77033</postal_code>
</address>
<square_footage>500.0</square_footage>
<bedrooms>1.0</bedrooms>
<bath>1.0</bath>
<price>600</price>
<contact>
<phone>555-555-1212</phone>
<fax>555-555-1414</fax>
</contact>
</rental_property>
The <address> element contains the subelements <street>, <city>, <state>, and <postal_code>. A similar
approach is taken for the contact information.
The <contact> element contains the <phone> and <fax> elements for the voice number and fax number,
respectively.
In our system, we‗ll normally work with a collection of rental properties. This collection is modeled using
a <rental_property_list> element, as shown here:
<rental_property_list>
<rental_property> … </rental_property>
<rental_property> … </rental_property>
……
</rental_property_list>
iv.Defining a Schema for the XML Document
Based on the desired document format, we can create a schema definition. The DTD schema format
was chosen because JAXB 1.0 supports DTDs.
In the future, JAXB is supposed to support the formal XML Schema definition. Listing contains the DTD
for our rental property list.
LISTING. rental_property.dtd
<!ELEMENT rental_property_list (rental_property)*>
56
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
<!ELEMENT rental_property (prop_id, name, address, square_footage, bedrooms, bath, price,
contact)>
<!ELEMENT prop_id (#PCDATA)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT address (street, city, state, postal_code)>
<!ELEMENT street (#PCDATA)>
<!ELEMENT city (#PCDATA)>
<!ELEMENT state (#PCDATA)>
<!ELEMENT postal_code (#PCDATA)>
<!ELEMENT square_footage (#PCDATA)>
<!ELEMENT bedrooms (#PCDATA)>
<!ELEMENT bath (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT contact (phone, fax)>
<!ELEMENT phone (#PCDATA)>
<!ELEMENT fax (#PCDATA)>
v.Creating the JAXB Binding Schema
The JAXB binding schema is an XML document that contains instructions on how to bind a DTD to
a Java class. Using the JAXB binding schema, we can define the names of the generated Java classes, map
element names to specific properties in the Java class, and provide the mapping rules for attributes.
The following code example informs the JAXB system that the element <rental_property_list> should be
mapped to a Java class and that it is the root element for the XML document:
<element name= ―rental_property_list‖ type= ―class‖ root= ―true‖/>
There‗s no requirement to define a mapping for every element in the XML document.
JAXB uses a default binding schema that will create properties in the Java class based on the XML element
name. The binding schema allows us to define a conversion rule for elements. For example, the numerical
data for the rental property, such as price, square footage, and number of rooms, is represented in the DTD
as text data (#PCDATA). This is one of the limitations of the DTD format. By using JAXB, we can specify
that a given element should be converted to a Java primitive type or class.
In the following code example, we inform JAXB to convert the values of <square_footage>,
<bedrooms>, and <bath> to the double type; <price> is converted to an instance of the java.math.
BigDecimal class:
<element name= ―square_footage‖ type= ―value‖ convert= ―double‖/>
<element name= ―bedrooms‖ type= ―value‖ convert=
―double‖/> <element name= ―bath‖ type= ―value‖ convert=
―double‖/> <element name= ―price‖ type= ―value‖ convert=
―BigDecimal‖/> <conversion name= ―BigDecimal‖ type=
―java.math.BigDecimal‖/>
We can use the binding schema to define enumerated types, constructors, and interfaces.
In the JAXB 1.0 early access version, constructors are not implemented. The binding schema includes a
section for controlling the output of the generated Java source code. For example, we can inform the system
to use a given package name.
The following code defines the package name as xmlunleashed.ch10.jaxb:
<options package= ―xmlunleashed.ch10.jaxb‖/>
Look at the JAXB binding schema file for our rental property example. The schema files use the filename
extension .xjs (for XML Java schema).
vi.Generating the JAXB Classes Based on Schemas
We are ready to generate the Java source files based on our schemas. JAXB provides a schema
compiler for generating the Java source files.
The schema compiler takes as input the DTD and the JAXB binding schema. Figure 3 illustrates the process.
FIGURE 3. Generating Java classes with the JAXB compiler
We pass our DTD (rental_property.dtd) and binding schema (rental_property.xjs) to the JAXB schema
compiler with the xjc command.
57
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
The command should be entered in the directory, e.g. <install_dir>\ch10_xmldb\. Type everything on one
line: java com.sun.tools.xjc.Main rental_property.dtd
➥rental_property.xjs -d source_code
This command generates source code in the source_code directory. The following files are generated:
• RentalPropertyList.java. This file models the <rental_property_list> element.
• RentalProperty.java. This file models the <rental_property> element.
• Address.java. This file models the <address> subelement.
• Contact.java. This file models the <contact> subelement.
Unified Modeling Language (UML) class diagram can be drawn for the generated Java classes.
Using the default schema-binding definition, the JAXB schema compiler generates a property in the Java
class for each XML element.
In the event the XML element contains subelements, the schema compiler will create a new class.
Unit-III SERVICE ORIENTED ARCHITECTURE
Characteristics of SOA, Comparing SOA with Client-Server and Distributed architectures – Benefits of SOA --
Principles of Service orientation – Service layers.
PART-A
1. Define SOA. (Nov/Dec 2017)
SOA is a form of technology architecture that adheres to the principles of service-orientation.
When realized through web services technology platform, SOA establishes the potential to support
and promote these principles throughout the business process and Automation domains of an
enterprise.
2. How does SOA address the issues that arise in client-server architecture?
a. Service oriented solutions eliminate dependencies on user environment by delegating all
processing to the server side.
b. SOA establishes an adaptable and extensible architecture mode that allows solutions to be
enhanced with minimal impact. Services can encapsulate existing legacy logic providing a
standardized API that can plug into larger integrated solution.
3. How is SOA different from distributed internet architecture?
SOA introduces processing and security requirements that differ from distributed internet
architecture and SOA administration is typically more complex due to its reliance on message-
based communication.
4. Give any 2 differences between service orientation and object orientation.
Service orientation Object Orientation
Emphasizes loose coupling between units of Emphasizes tightly bound units of
processing logic. processing logic.
Encourages coarse-grained interfaces so that Supports fine-grained interfaces so that
units of communication contain as much units of communication perform various
information as possible for completion of a sized tasks.
given task.
5. Define application architecture.
Application architecture is to an application development team what a blueprint is to a team of
construction workers. Application architecture includes high-level abstract, physical and logical
representation of the technical blueprint or common data models, communication flow diagrams,
application-wide security requirements and aspects of infrastructure.
6. Define enterprise architecture.
Enterprise architecture specification is to an organization what an urban plan is to a city. A master
specification created, providing high-level overview of all forms of heterogeneity that exist within
an enterprise. i.e. when multiple applications architecture exist within an organization they are
always accompanied by and kept in alignment with a governing enterprise architecture.
7. List any 4 characteristics of SOAs. (Nov/Dec 2016) (April/May 2017)(Nov/Dec 2017)
a. SOA supports vendor diversity.
b. SOA is fundamentally autonomous.
c. SOA promotes discovery.
d. SOA fosters intrinsic interoperability.
58
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
8. List the components SOA.
Messages- contains data for operation
Operations-holds the logic
Services- group the operation together
Processes-large units of work with business logic
9. Define service. How do services communicate?
A service represents a logically grouped set of operations capable of performing the related units
of work.Services communicate via SOAP messages.
10. What do you mean by loose coupling? or How loose coupling concept achieved in SOA?
(Nov/Dec 2016)
It is a condition wherein a service acquires knowledge of another service while still remaining
independent of that service. It is achieved through the use of service contracts that allow services.
11. What are the fundamental parts of SOA? How do they interrelate(Nov/Dec 2017)
59
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
20. What are the business service models that business service layer offers?
a) Task-centric business service
b) Entity-centric business service
21. What is the role of orchestration service layer?
It consists of one or more process services that compose business and application services
according to business rules and business logic embedded within process definition.
22. What are wrapper services?
They consist of services that encapsulate (―wrap‖) some or all parts of a legacy environment to
expose legacy functionality to service requestors. They are used for legacy purpose. Example of
wrapper service: service adapter provided by legacy vendors.
23. What are the reponsibilities of SOA? (April/May 2017)(Nov/Dec 2017)
Improved integration and intrinsic interoperability
Inherent reuse
Streamlined architectures and solutions
Leveraging of legacy investment
Establishing standardized XML data representation
Focused investment on communication infrastructure
Best of breed alternatives
Organizational agility
24. State Service component.
A service component represents a logically grouped set of operations capable of
performing the related units of work. Services communicate via SOAP messages.
Part B
1. Compare SOA with Client Server and Distributed Internet Architecture.(Nov/Dec 2016)
(April/May 2017) (Apr/May 2018)
SOA is a radical departure from client-server architecture. Current SOAs employ
technologies used to build client-server applications.
SOAs introduce complexity that sharply contrasts the simplicity of two-tier client-server
architecture.
Any environment in which one piece of software requests or receives information from
another can be referred to as "client-server".
Every variation of application architecture that ever existed (including SOA) has an element of
client-server interaction in it.
Client-server architecture: The environments, in which bulky mainframe back-ends served thin
clients, are considered an implementation of the single-tier client-server architecture (Figure 1).
60
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
o
Mainframes supported synchronous and asynchronous communication.
Client-side software performed the bulk of the processing, including all presentation-related and data
access logic Figure.2.
Asynchronous allow the server to continuously receive characters from the terminal in response to
individual key-strokes.
The reign of the mainframe as the computing platform began to decline when a two-tier
variation of the client-server design emerged in the 80s. This new approach introduced the
delegating logic and processing duties onto individual workstations, resulting in the fat client.
Figure 2. A typical Two-tier Client Server Architecture
Supported by the innovation of the GUI, two-tier client-server was considered and
dominates the IT world for years during the early 90s. The configuration of this architecture
consisted of multiple fat clients, each with its own connection to a database on a central server. One
or more servers facilitated these clients by hosting scalable RDBMSs.
61
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
62
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
SOA vs Traditional Distributed Internet Architecture
In response to the costs and limitations associated with the two-tier client server
architecture, the concept of building component-based applications hit the mainstream.
Multi-tier client-server architectures surfaced, breaking up the monolithic client executable into
components designed to varying extents of compliance with object-orientation.
Distributing application logic among multiple components (some residing on the client,
others on the server) reduced deployment headaches by centralizing a greater amount of the logic
on servers.
Server-side components located on dedicated application servers, would share and manage
pools of database connections, alleviating the burden of concurrent usage on the database server
(Figure.1). A single connection could facilitate multiple users.
Figure 1. Multi-tier Client Server Architecture
These benefits came at the cost of increased complexity and ended up shifting expense and
effort from deployment issues to development and administration processes.
Building components capable of processing multiple, concurrent requests were difficult and
problem-ridden than developing a straight-forward executable intended for a single user.
Additionally, replacing client-server database connections was the client-server Remote Procedure
Call (RPC) connection.
RPC technologies such as CORBA and DCOM allowed for remote communication between
components residing on client workstations and servers.
Issues similar to the client-server architecture problems involving resources and persistent
connections emerged.
Adding to this was an increased maintenance effort resulting from the introduction of the
middleware layer. For example, application servers and transaction monitors required significant
attention in larger environments.
Upon the arrival of the World Wide Web as a viable medium for computing technology in
the mid-to-late 90s, the multi-tiered client-server environments began incorporating Internet
technology.
Significant was the replacement of the custom software client component with the browser.
Not did this change radically alter (and limit) user-interface design, it practically shifted 100% of
application logic to the server (Figure. 2).
63
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
Figure 2. A typical distributed Internet architecture.
Distributed Internet architecture introduced a new physical tier, the Web server. This
resulted in HTTP replacing proprietary RPC protocols used to communicate between the user's
workstation and the server.
The role of RPC was limited to enabling communication between remote Web and
application servers.
Distributed Internet architectures represented the de facto computing platform for custom
developed enterprise solutions.
The commoditization of component-based programming skills and the increasing
sophistication of middleware lessened some of the overall complexity.
Although multi-tier client-server is a distinct architecture in its own right, we do not provide
a direct comparison between it and SOA.
DIA vs SOA
The following primary characteristics are used for comparison between DIA and SOA:
1) Application Logic
2) Application Processing
3) Technology
4) Security
5) Administration
64
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
65
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
2. Explain SOA vs. hybrid Web service architecture with case study.
The use of Web services within traditional architectures is completely legitimate. Due to the
development support for Web services in many established programming languages, they can be
positioned to fit in with older application designs.
A. Web services as component wrappers
The role of Web services introduces an integration layer that consists of wrapper services
that enable synchronous communication via SOAP-compliant integration channels (Figure.1).
The initial release of the SOAP specification and the first generation of SOAP servers were
specifically designed to duplicate RPC-style communication using messages.
Figure 1. Wrapper services encapsulating components
66
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
These integration channels are utilized in integration architectures to facilitate
communication with other applications or outside partners.
They are used to enable communication with other solutions and to take advantage of the
features offered by third-party utility Web services.
Regardless of their use within traditional architectures, it clarify that a distributed Internet
architecture that incorporates Web services in this manner does not qualify as a true SOA. It is a
distributed Internet architecture that uses Web services.
Instead of mirroring component interfaces and establishing point-to-point connections with
Web services, SOA provides strong support for a variety of messaging models.
Web services within SOAs are subject to specific design requirements, such as those
provided by service-orientation principles. These and other characteristics support the pursuit of
consistent loose coupling. Once achieved, a single service is never limited to point-to-point
communication; it can accommodate any number of current and future requestors.
B.Web services within SOA
While SOAs can vary in size and quality, there are tangible characteristics that distinguish
an SOA from other architectures that use Web services. SOAs are built with a set of Web services
designed to collectively automate one or business processes and that SOA promotes the
organization of these services into specialized layers that abstract specific parts of enterprise
automation logic. By standardizing on SOA across an enterprise, a natural interoperability emerges
that transcends proprietary application platforms. This allows for previously disparate environments
to be composed in support of new and evolving business automation processes.
5. Explain in detail the principles of service orientation. (Nov/Dec 2016) (Nov/Dec 2017)
Service-orientation can be viewed as a manner in which to realize a separation of concerns.
Services share a formal contract: For services to interact, they need not share anything but a
formal contract that describes each service and defines the terms of information exchange.
Figure 2. Service contracts formally define the service, operation, and message components of
a service-oriented architecture.
68
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
Services are loosely coupled: Services must be designed to interact without the need for tight,
cross-service dependencies.
Figure 3. Services limit dependencies to the service contract, allowing underlying provider
and requestor logic to remain loosely coupled.
Services abstract underlying logic: The part of a service that is visible to the outside world is
what is exposed via the service contract. Underlying logic, beyond what is expressed in the
descriptions that comprise the contract, is invisible and irrelevant to service requestors.
Figure 4. Service operations abstract the underlying details of the functionality they expose.
Services are composable Services may compose other services. This allows logic to be represented
at different levels of granularity and promotes reusability and the creation of abstraction layers.
69
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
Services are autonomous: The logic governed by a service resides within an explicit boundary.
The service has control within this boundary and is not dependent on other services for it to execute
its governance.
Figure 6. Autonomous services have control over underlying resources
Services are stateless Services should not be required to manage state information, as that can
block their ability to remain loosely coupled. Services should be designed to maximize statelessness
even if that means deferring state management elsewhere.
Figure 7. Stateless and stateful stages a service passes through while processing a message.
Services are discoverable Services should allow their descriptions to be discovered and
understood by humans and service requestors that may be able to make use of their logic.
Of these eight, autonomy, loose coupling, abstraction, and the need for a formal contract can be
considered the core principles that form the baseline foundation for SOA.
70
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
There are other qualities associated with services and service-orientation. Examples include self-
descriptive and coarse-grained interface design characteristics.
6. Explain the anatomy of SOA. Also list the benefits of SOA.
Logic components of the Web services framework
W
Each operation governs the process of a specific function the web service is capable of
performing.
Web services form an activity though which they can collectively automate a task.
SOAs offer the following advantages over traditional approaches to distributed computing:
They offer business services across the platforms
They provide location independence
Services need not be at a particular system or particular network
Completely loosely coupled approach
Authentication and authorization support at every level
The search and connectivity to other services is dynamic
Short-term benefits of implementation:
Enhances reliability
Reduces hardware acquisition costs
Leverages existing development skills
Accelerates movement to standards-based server and application consolidation
Provides a data bridge between incompatible technologies
71
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
Long-term benefits of implementation:
Provides the ability to build composite applications
Creates a self-healing infrastructure that reduces management costs
Provides truly real-time decision-making applications
Enables the compilation of a unified taxonomy of information across an enterprise and
its customer and partners
Benefits from the perspective of Business Value
Ability to more quickly meet customer demands
Lower costs associated with the acquisition and maintenance of technology
Management of business functionality closer to the business units
Leverages existing investments in technology
Reduces reliance on expensive custom development
1. Improved integration (and intrinsic interoperability)
SOA can result in the creation of solutions that consist of inherently interoperable services.
Utilizing solutions based on interoperable services is part of Service-Oriented Integration (SOI) and
results in SOI architecture.
Because of the vendor-neutral communications framework established by Web services-
driven SOAs, there are enterprises to implement highly standardized service descriptions and
message structures.
The net result is intrinsic interoperability, which turns a cross-application integration project
into less of a custom development effort, and of a modeling exercise. The cost and effort of cross-
application integration is lowered when applications being integrated are SOA-compliant.
2. Inherent reuse
Service-orientation promotes the design of services that are inherently reusable. Designing
services to support reuse from the get-go opens the door to increased opportunities for leveraging
existing automation logic.
Building service-oriented solutions in such a manner that services fulfill immediate
application-level requirements while supporting a degree of reuse by future requestors establishes
an environment wherein investments into existing systems can be leveraged and re-leveraged as
new solutions are built.
Building services to be inherently reusable results in a moderately increased development
effort and requires the use of design standards. Leveraging reuse within services lowers the cost and
effort of building service-oriented solutions.
3. Streamlined architectures and solutions
The concept of composition is another fundamental part of SOA. It is not limited to the
assembly of service collections into aggregate services. The WS-* platform is based in its entirety
on the principle of composability. This aspect of service-oriented architecture can lead to highly
optimized automation environments, where the technologies required become part of the
architecture.
Realizing this benefit requires adherence to design standards that govern allowable
extensions within each application environment. Benefits of streamlined solutions and architectures
include for reduced processing overhead and reduced skill-set requirements.
The reduced performance requirements refer that SOA extensions are composable and allow
application-level architecture to contain extensions relevant to its solution requirements.
Message-based communication in SOAs can increase performance requirements when compared to
RPC-style communication within traditional distributed architectures.
4. Leveraging the legacy investment
The industry-wide acceptance of the Web services technology set has spawned a large
adapter market, enabling many legacy environments to participate in service-oriented integration
architectures.
This allows IT departments to work toward a state of federation, where previously isolated
environments can interoperate without requiring the development of expensive and fragile point-to-
point integration channels.
72
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
Though riddled with risks relating mostly to how legacy back-ends must cope with
increased usage volumes, the ability to use what you already have with service-oriented solutions
that you are building and in the future is extremely attractive.
The cost and effort of integrating legacy and contemporary solutions is lowered. The need for
legacy systems to be replaced is lessened.
73
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
Agility is a quality inherent in just about any aspect of the enterprise. A simple algorithm, a
software component, a solution, a platform, a process all of these parts contain a measure of agility
related to how they are constructed, positioned, and leveraged.
How building blocks such as these can be realized and maintained within existing financial
and cultural constraints ultimately determines the agility of the organization as a whole.
Much of service-orientation is based on the assumption that what you build today will evolve over
time. One of the benefits of a well-designed SOA is to protect organizations from the impact of this
evolution. When accommodating change becomes the norm in distributed solution design, qualities
such as reuse and interoperability become commonplace.
The predictability of these qualities within the enterprise leads to a reliable level of
organizational agility. All of this is attainable through proper design and standardization.
Change can be disruptive, expensive, and damaging to inflexible IT environments. Building
automation solutions and supporting infrastructure with the anticipation of change seems to make a
great deal of sense.
A standardized technical environment comprised of loosely coupled, composable, and
interoperable and reusable services establishes adaptive automation environment that empowers IT
departments to adjust to change.
By abstracting business logic and technology into specialized service layers, SOA can
establish a loosely coupled relationship between these two enterprise domains.
This allows each domain to evolve independently and adapt to changes imposed by the other, as
required.
Regardless of what parts of service-oriented environments are leveraged, the increased
agility with which IT can respond to business process or technology-related changes is significant.
The cost and effort to respond and adapt to business or technology-related change is reduced.
Summary:
When assessing the return on investment for an SOA there are several concrete benefits that can be
taken into account. Many of the benefits promised by SOA do not manifest themselves until the use
of service-orientation principles becomes established within an enterprise.
7. Discuss about three service layers in detail. (Nov/Dec 2017) (Apr/May 2018)
Application service layer
The application service layer intentionally abstracts non-business-related logic into a set
of services that are referred to as application services (utility services) provides
reusable functions that address cross-cutting concerns by representing common
enterprise resources and capabilities
Common characteristics of application services:
Expose functionality within a specific processing context
Draw upon available resources within a given platform
Are solution-agnostic
Are generic and reusable
Can be used to achieve point-to-point integration with other application services
Are often inconsistent in terms of the interface granularity they expose
May consist of a mixture of custom-developed services and third-party services
that have been purchased or leased
When a separate business service layer exists there is a strong motivation to turn
all application services into generic utility services
Generic utility services are implemented in a solution-agnostic manner, provide
reusable operations are composed by business services to fulfill business-centric
processing requirements
If business logic does not reside in a separate layer, application services may be
required to implement services models more associated with business services
layer
A single application service can also be classified as a business service if it
74
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
interacts directly with application logic and contains embedded business rules
Hybrid application services (hybrid services) – services that contain both application
and business logic
Typically found within traditional distributed architectures
Not a recommended design when building service abstraction layers
An application service can compose other, smaller-grained application services into a
unit of course-grained application logic
Application integration services (integration services) – application services that exist
solely to enable integration between systems
Application services are very similar to the utility service model
Application service layer is sometimes called the utility service layer, or infrastructure
service layer (infrastructure services)
Wrapper service model –
- used for integration purposes and consist of services that encapsulate (―wrap‖) some or
all parts of a legacy environment to expose legacy functionality to service requestors
- most frequent form is a service adapter provided by legacy vendors
establishes a vendor-defined service interface that expresses an underlying API to legacy
logic
Proxy service (auto-generated WSDL) –
provides a WSDL definition that mirrors an existing component interface establishes an
endpoint on the component‘s behalf, allowing it to participate in SOAP
communication
Proxy service should not be confused with a service proxy, used by service requestors to
contact service providers
Summary
The application service layer consists of application services that represent technology-
specific logic
Typical incarnations of application services are the utility and wrapper models
Application services are ideally reusable utility services composed by business services,
but also can exist as hybrid services that contain both business and application logic
Business service layer
The business service layer represents a collection of services based on the
business service model called business services
achieves a close alignment between an organization‘s business and technology
domains
Each business service is assigned a functional context derived from one or more
existing organizational business models or specifications
Designing a business service layer leads to the creation of two common business
service models, each of which establishes its own sub-layer
Task-centric business service –
a service that encapsulates business logic specific to a task or business process that
involves two or more business entities generally have limited potential and can be
simply referred to as task services
Entity-centric business service
A service that encapsulates processing logic associated with a specific business entity are
useful for creating highly reusable and business-process agnostic services and can be
called business entity services or entity services. If a separate application service
exists, these two types of business services can be positioned to compose application
services to carry out their business logic
A hybrid service is a service that contains both business and application logic often
referred to as a type of business service and is considered a variation of an application
service and resides in the application service layer. The business service layer is
reserved for services that only abstract business logic
75
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
Summary
The business service layer is comprised of business services, a direct
implementation of the business service model
Business services are ideally also controllers that compose application services to
execute their business logic
Even though hybrid services contain business logic, they are not classified as
business services
Orchestration service layer
When orchestration is incorporated as part of a service-oriented architecture, it
assumes the role of the process. Orchestration allows a direct link to process logic to
service interaction within workflow logic combines business modeling with service-
oriented modeling and design brings the business process into the service layer
positioned as a master composition controller orchestration languages (WS-BPEL)
realize workflow management through a process service model. The orchestration layer
introduces a parent level of abstraction that alleviates the need for other services to
manage interaction details required to ensure that service operations are executed in a
specific sequence. Within the orchestration 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. All process services are
controller services by their very nature. They are required to compose other services to
execute business process logic
Process services can also be referred to as orchestrated task services parent business
process layer
The introduction of an orchestration layer typically brings with it the requirement to
introduce new middleware into the IT infrastructure
Summary
The orchestration service layer consists of one or more process services that compose
business and application services according to business rules and business logic
embedded within process definitions
Orchestration abstracts business rules and service execution sequence logic from other
services, promoting agility and reusability
8. Explain briefly about: i)Service Layer Abstraction. ii) Application Service layer.
Service layer abstraction
The service interface layer is
located between the business process and application layers
where service connectivity resides
the area of our enterprise wherein the characteristics of SOA are most prevalent
Problems solved by layering services
Need to answer the following questions:
What logic should be represented by services?
How should services relate to existing application logic?
How can services best represent business process logic?
How can services be built and positioned to promote agility?
Application service layer
The application service layer intentionally abstracts non-business-related logic into a set
of services that are referred to as application services (utility services) provides
reusable functions that address cross-cutting concerns by representing common
enterprise resources and capabilities
Common characteristics of application services:
Expose functionality within a specific processing context
Draw upon available resources within a given platform
Are solution-agnostic
Are generic and reusable
76
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
Can be used to achieve point-to-point integration with other application services
Are often inconsistent in terms of the interface granularity they expose
May consist of a mixture of custom-developed services and third-party services
that have been purchased or leased
When a separate business service layer exists there is a strong motivation to turn
all application services into generic utility services
Generic utility services are implemented in a solution-agnostic manner, provide
reusable operations are composed by business services to fulfill business-centric
processing requirements
If business logic does not reside in a separate layer, application services may be
required to implement services models more associated with business services
layer
A single application service can also be classified as a business service if it
interacts directly with application logic and contains embedded business rules
9. Discuss about Business Service layer and Orchestration Service Layer.
Business service layer
The business service layer represents a collection of services based on the business
service model called business services
achieves a close alignment between an organization‘s business and technology
domains
Each business service is assigned a functional context derived from one or more
existing organizational business models or specifications
Designing a business service layer leads to the creation of two common business
service models, each of which establishes its own sub-layer
Task-centric business service –
a service that encapsulates business logic specific to a task or business process that involves
two or more business entities generally have limited potential and can be simply referred to as
task services
Entity-centric business service
A service that encapsulates processing logic associated with a specific business entity are
useful for creating highly reusable and business-process agnostic services and can be called
business entity services or entity services. If a separate application service exists, these two
types of business services can be positioned to compose application services to carry out their
business logic
A hybrid service is a service that contains both business and application logic often referred
to as a type of business service and is considered a variation of an application service and
resides in the application service layer. The business service layer is reserved for services that
only abstract business logic
Orchestration service layer
When orchestration is incorporated as part of a service-oriented architecture, it
assumes the role of the process. Orchestration allows a direct link to process logic to service
interaction within workflow logic combines business modeling with service-oriented
modeling and design brings the business process into the service layer positioned as a master
composition controller orchestration languages (WS-BPEL) realize workflow management
through a process service model. The orchestration layer introduces a parent level of
abstraction that alleviates the need for other services to manage interaction details required to
ensure that service operations are executed in a specific sequence. Within the orchestration
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. All process services are controller services by their very nature. They are required to
compose other services to execute business process logic
Process services can also be referred to as orchestrated task services parent business
process layer
77
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
The introduction of an orchestration layer typically brings with it the requirement to
introduce new middleware into the IT infrastructure
78
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
10. How are the business services used within SOA?
As fundamental building blocks for representing business logic.
To represent corporate entity or information set
To represent business process logic.
As service composition members.
79
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
16. What are the variations of fire and forget message exchange?
a) Single destination pattern
b) Multi-cast destination pattern
c) Broadcast destination pattern
17. What are the services that a coordinator composition consists of?
a) Activation service
b) Registration service
c) Protocol-specific service
d) Co-ordinator service
18. What are the atomic transaction protocols that are available?
a. Completion Protocol
b. Durable 2PC Protocol
c. Volatile 2PC Protocol
19. Why is orchestration called ―the heart of SOA‖ ?
As it establishes a means of centralizing and controlling a great deal of inter and intra application
logic through a standardized service model.
20. Distinguish between orchestration and choreography.
Orchestration Choreography
25. What are the two types of WSDL elements? / What are the types of service description?
(April/May 2017)
A WSDL document has two parts: abstract and concrete descriptions. The abstract section defines
SOAP messages in a language- and platform-independent manner. In contrast, the concrete
descriptions define site-specific matters such as serialization.
80
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
26. Mention the three types of choreography. (Apr/May 2018)
Abstract Choreography
Portable Choreography
Concrete Choreography
Part B
1. Explain the structure of SOAP message and the importance of messaging with SOAP in detail.
(April/May 2017)
Message structure:
82
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
3. Explain in detail about atomic transactions process with suitable examples. (Nov/Dec 2016)
(Apr/May 2017)
83
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
When WS-Atomic Transaction protocols are used, the coordinator controller service can be referred
to as an atomic transaction coordinator. This particular implementation of the WS-Coordination
coordinator service represents a specific service model.
The atomic transaction coordinator (Figure 2) plays a key role in managing the participants of the
transaction process and in deciding the transaction's ultimate outcome.
Figure 3. The coordinator requesting that transaction participants prepare to vote
The atomic transaction coordinator is tasked with the responsibility of deciding the outcome
of a transaction. It bases this decision on feedback it receives from all of the transaction
participants. The collection of this feedback is separated into two phases.
During the prepare phase (Figure 3), all participants are notified by the coordinator, and each
is asked to prepare and then issue a vote.
Each participant's vote consists of either a "commit" or "abort" request (Figure 4).
Figure 4. The transaction participants voting on the outcome of the atomic transaction
After the votes are collected, the atomic transaction coordinator enters the commit phase. It
reviews all votes and decides whether to commit or rollback the transaction.
The conditions of a commit decision are simple: if all votes are received and if all participants
voted to commit, the coordinator declares the transaction successful, and the changes are
committed.
If any one vote requests an abort, or if any of the participants fail to respond, then the transaction
is aborted, and all changes are rolled back (Figure 5).
84
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
Figure 5. The coordinator aborting the transaction and notifying participants to rollback
all changes.
As more services emerge within an organization and as service compositions become more
commonplace, the need to move transaction boundaries into cross-service interaction scenarios
increases. Being able to guarantee an outcome of an activity is a key part of enterprise-level
computing, and atomic transactions therefore play an important role in ensuring quality of service.
Not only do atomic transactional capabilities lead to a robust execution environment for SOA
activities, they promote interoperability when extended into integrated environments.
This allows the scope of an activity to span different solutions built with different vendor
platforms, while still being assured a guaranteed all-or-nothing outcome. WS-Atomic Transaction
is supported by the affected applications; this option broadens the application of the two-phase
commit protocol beyond traditional application boundaries (supporting service interoperability).
Figure 6 illustrates how atomic transactions support these aspects of SOA.
85
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
86
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
Building upon orchestration logic standardizes process representation across an organization,
while addressing the goal of enterprise federation and promoting service-orientation.
Figure 1. An orchestration controls almost every facet of a complex activity
A primary industry specification that standardizes orchestration is the Web services - Business
Process Execution Language (WS-BPEL). WS-BPEL is a key second-generation extension and
uses its concepts and terminology as the basis relating to business process modeling.
Figure 3. The process service, after first being invoked by a partner service, then invokes
another partner service.
87
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
88
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
These qualities lead to increased organizational agility because:
The workflow logic encapsulated by an orchestration can be modified or extended in a central
location. Positioning an orchestration centrally can ease the merging of business processes by
abstracting the glue that ties the corresponding automation solutions together.
By establishing potentially large-scale service-oriented integration architectures, orchestration,
on a fundamental level, can support the evolution of a diversely federated enterprise. Orchestration
is an ingredient to achieving a state of federation within an organization that contains applications
based on different computing platforms.
Advancements in middleware allow orchestration engines to become fully integrated in
service-oriented environments.
The orchestration establishes comprehensive process logic that encompasses the business
activity and extends it to govern additional interaction scenarios with multiple vendor services.
For example, when one vendor cannot fulfill an order, the next vendor in line is sent the same
purchase order.
This cycle is repeated until either one vendor can complete the order in its entirety or until all
vendors have been queried. In the latter situation, the system assesses the best deal on the table by
applying a formula that takes into account the price, percentage of order to be filled, and backorder
terms. The orchestration logic manages all aspects of the process, including the involvement of
multiple vendor partner services and the business activity.
SUMMARY
An orchestration expresses a body of business process logic that is owned by a single organization.
An orchestration establishes a business protocol that defines a business process definition. The
workflow logic within an orchestration is broken down into a series of basic and structured
activities that can be organized into sequences and flows. Orchestration has been called the "heart
of SOA," as it establishes a means of centralizing and controlling a deal of inter and intra-
application logic through a standardized service model.
6. Explain in detail about choreography. (Nov/Dec 2016)
All organizations would agree on how internal processes should be structured, so that they
have to interoperate and automation solutions in perfect alignment.
The requirement for organizations to interoperate via services is becoming increasingly real
and increasingly complex.
This is true when interoperation requirements extend into the collaboration, where multiple
services from different organizations need to work to achieve a goal.
The Web Services-Choreography Description Language (WS-CDL) is specifications to
organize information exchange between multiple organizations, with a public collaboration (Figure
1).
Figure 1. Choreography enables collaboration between its participants
89
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
1. Collaboration
An important characteristic of choreographies is that they are intended for public message
exchanges.
The goal is to establish a kind of organized collaboration between services representing different
service entities, no one organization controls the collaboration logic.
Choreographies establish universal interoperability patterns for inter-organization business tasks.
While the emphasis on choreography is B2B interaction, it can be applied to enable collaboration
between applications belonging to a single organization.
2. Roles and participants
Within any given choreography, a Web service assumes one of a number of predefined roles. This
establishes what the service does and what the service can do within the context of a particular
business task.
Roles can be bound to WSDL definitions, and those related are grouped accordingly, categorized as
participants (services).
3. Relationships and channels
Every action that is mapped out within choreography can be broken down into a series of message
exchanges between two services.
Each exchange between two roles in choreography is defined individually as a relationship.
Every relationship consists of exactly two roles.
Channels define the characteristics of the message exchange between two specific roles.
To facilitate complex exchanges involving multiple participants, channel information can be passed
around in a message.
This allows one service to send another the information required for it to be communicated with by
other services.
This is a feature of the WS-CDL specification, as it fosters dynamic discovery and increases the
number of participants within large-scale collaborative tasks.
4. Interactions and work units
The logic behind a message exchange is encapsulated within an interaction.
Interactions are the building blocks of choreographies because the completion of an interaction
represents progress within choreography.
Related to interactions are work units. These impose rules and constraints that must be followed to
for an interaction to successfully complete.
5. Reusability, composability, and modularity
Figure 2. Choreography composed of two smaller choreographies
SUMMARY
Choreography is a complex activity comprised of a service composition and a series of MEPs.
Choreographies consist of multiple participants that can assume different roles and that have
different relationships.
Choreographies are reusable, composable, and can be modularized.
The concept of choreography extends the SOA vision to standardize cross-organization
collaboration.
7. Explain in detail about message exchange patterns in web services. (April/May 2017)
(Nov/Dec 2017)
Every task automated by a Web service can differ in the application logic being executed and the
role played by the service in the overall execution of the business task.
Regardless of how complex a task is, all require the transmission of multiple messages. The
challenge lies in coordinating these messages in a particular sequence so that the individual actions
performed by the message are executed properly and in alignment with the overall business task
(Figure 1).
Figure. 1 Not all message exchanges require both requests and responses.
Message Exchange Patterns (MEPs) represent a set of templates that provide a group of already
mapped out sequences for the exchange of messages.
The example is a request and response pattern where the MEP states that upon successful
delivery of a message from one service to another, the receiving service responds with a message
back to the initial requestor.
Many MEPs have been developed, each addressing a common message exchange requirement. It
is useful to have a understanding of important MEPs, as you will be applying MEPs to specific
communication requirements when designing service-oriented solutions.
i. Primitive MEPs
92
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
Before the arrival of contemporary SOA, messaging frameworks were used by various
messaging-oriented middleware products. A set of primitive MEPs has been in existence for some
time.
a.Request-response
This is the popular MEP in use among distributed application environments and the one pattern
that defines synchronous communication (this pattern can be applied asynchronously).
The request-response MEP (Figure.2) establishes a simple exchange in which a message is first
transmitted from a source (service requestor) to a destination (service provider).
Upon receiving the message, the destination (service provider) then responds with a message
back to the source (service requestor).
Figure 2. The request-response MEP
b.Fire-and-forget
This asynchronous pattern is based on the unidirectional transmission of messages from a source
to one or more destinations (Figure 3).
A number of variations of the fire-and-forget MEP exist, including:
The single-destination pattern, where a source sends a message to one destination only.
The multi-cast pattern, where a source sends messages to a predefined set of destinations.
The broadcast pattern, which is similar to the multi-cast pattern, except that the message
is sent out to a broader range of recipient destinations.
The fundamental characteristic of the fire-and-forget pattern is that a response to a transmitted
message is not expected.
Figure 3. The fire-and-forget MEP
ii.Complex MEPs
Even though a message exchange pattern can facilitate the execution of a simple task, it is a
building block intended for composition into larger patterns.
Primitive MEPs can be assembled in various configurations to create different types of messaging
models, sometimes called complex MEPs. A classic example is the publish-and-subscribe model.
The publish-and-subscribe pattern introduces new roles for the services involved with the message
exchange.
They become publishers and subscribers, and each may be involved in the transmission and
receipt of messages.
This asynchronous MEP accommodates a requirement for a publisher to make its messages
available to a number of subscribers interested in receiving them. The steps involved are similar to
the following:
Step 1. The subscriber sends a message to notify the publisher that it wants to receive
messages on a particular topic.
93
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
Step 2. Upon the availability of the requested information, the publisher broadcasts messages
on the particular topic to all of that topic's subscribers.
This pattern is an example of how to aggregate primitive MEPs, as shown in Figure 4.
Step 1 in the publish-and-subscribe MEP could be implemented by a request-response MEP,
where the subscriber's request message, indicating that it wants to subscribe to a topic, is responded
to by a message from the publisher, confirming that the subscription succeeded or failed.
Figure 4. The publish-and-subscribe messaging model is a composite of two primitive
MEPs.
Step 2 then could be supported by one of the fire-and-forget patterns, allowing the
publisher to broadcast a series of unidirectional messages to subscribers. WS-* specifications
that incorporate this messaging model include:
WS-BaseNotification
WS-BrokeredNotification
WS-Topics
WS-Eventing
WSDL support recent revisions of the MEPs specification and extended this support to
include additional variations.
Release 2.0 of the WSDL specification extends MEP support to eight patterns as follows:
The in-out pattern, comparable to the request-response MEP (and equivalent to the WSDL 1.1
request-response operation).
The out-in pattern, which is the reverse of the previous pattern where the service provider initiates
the exchange by transmitting the request. (Equivalent to the WSDL 1.1 solicit-response operation.)
The in-only pattern, which supports the standard fire-and-forget MEP. (Equivalent to the WSDL 1.1
one-way operation.)
The out-only pattern, which is the reverse of the in-only pattern. It is used in support of event
notification. (Equivalent to the WSDL 1.1 notification operation.)
The robust in-only pattern, a variation of the in-only pattern that provides the option of
launching a fault response message or processing error.
The robust out-only pattern, which, like the out-only pattern, has an outbound message
initiating the transmission. A fault message can be issued in response to the receipt of this
message.
The in-optional-out pattern, which is similar to the in-out pattern with one exception. The
delivery of a response message is optional and should not be expected by the service
requestor that originated the communication. This pattern supports the generation of a fault
message.
The out-optional-in pattern is the reverse of the in-optional-out pattern, where the incoming
message is optional. Fault message generation is supported.
Until version 2.0 of WSDL becomes commonplace, these new patterns will be of limited
importance to SOA. Version 2.0 of the WSDL specification was labeled 1.2.
The working group responsible for the new specification decided that the revised feature set
constituted a full new version number.
iv.MEPs and SOA
MEPs are highly generic and abstract in nature. They relate to an interaction between two
services.
Their relevance to SOA is equal to their relevance to the abstract Web services framework.
95
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
They are a fundamental and essential part of any Web services-based environment, including
SOA.
SUMMARY:
An MEP is a generic interaction pattern that defines the message exchange between two services.
MEPs have been around for as long as messaging-based middleware products have been used.
MEPs can be composed to support the creation of larger, more complex patterns.
The WSDL and SOAP specifications support specific variations of common MEPs.
98
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
Because a business service may have multiple binding templates, the service may specify
different implementations of the same service, each bound to a different set of protocols or a
different network address.businessEntity>.
D.tModel data structure:
The tModel is the last core data type. The tModel stands for technical model.
A tModel is a way of describing the various business, service, and template structures stored
within the UDDI registry. Any abstract concept can be registered within UDDI as a tModel.
If you define a new WSDL port type, you can define a tModel that represents that port type
within UDDI.
Then, you can specify that a given business service implements that port type by associating
the tModel with one of that business service's binding templates.
Here is an example of tModel representing the HelloWorldInterface port type:
<tModel tModelKey="uuid:xyz987..."
operator="http://www.ibm.com"
authorizedName="John Doe">
<name>HelloWorldInterface Port Type</name>
<description>
An interface for a friendly Web service
</description>
<overviewDoc>
<overviewURL>
http://localhost/helloworld.wsdl
</overviewURL>
</overviewDoc>
</tModel>
E.publisherAssertion data structure:
This is a relationship structure putting into association two or more businessEntity structures
according to a specific type of relationship, such as subsidiary or department.
The publisherAssertion structure consists of the three elements fromKey (the first
businessKey), toKey (the second businessKey) and keyedReference.
The keyedReference designates the asserted relationship type in terms of a keyName keyValue
pair within a tModel, uniquely referenced by a tModelKey.
<element name="publisherAssertion" type="uddi:publisherAssertion"
/> <complexType name="publisherAssertion">
<sequence>
<element ref="uddi:fromKey" />
<element ref="uddi:toKey" />
<element ref="uddi:keyedReference" />
</sequence>
</complexType>
9. Explain service description with WSDL in detail. (Nov/Dec 2017)
WSDL:
A WSDL document can be thought of as a contract between a client and a server. It
describes what the Web Service can do, where it can be found, and how to invoke it. Essentially,
WSDL defines an XML grammar that describes Web Services (and in general, any network
service) as collections of communications endpoints (that is, the client and the server) that are able
to exchange messages with each other.
WSDL documents use the following elements:
WSDL Ports
The <portType> element is the most important WSDL element.
It describes a web service, the operations that can be performed, and the messages that are involved.
The <portType> element can be compared to a function library (or a module, or a class) in a
traditional programming language.
WSDL Messages
The <message> element defines the data elements of an operation.
Each message can consist of one or more parts. The parts can be compared to the parameters of a
function call in a traditional programming language.
WSDL Types
The <types> element defines the data types that are used by the web service.
For maximum platform neutrality, WSDL uses XML Schema syntax to define data types.
WSDL Bindings
The <binding> element defines the data format and protocol for each port type.
Calculator.xsd_1(http://localhost:8080/Calc/Calculator?xsd=1):
<?xml version='1.0' encoding='UTF-8'?>
<xs:schema xmlns:tns="http://p1/" xmlns:xs=http://www.w3.org/2001/XMLSchema version="1.0"
targetNamespace="http://p1/">
<xs:complexType name="sub">
<xs:sequence>
<xs:element name="a" type="xs:int"/>
<xs:element name="b" type="xs:int"/>
</ xs:sequence>
</xs:complexType>
<xs:complexType name="subResponse">
<xs:sequence>
100
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
<xs:element name="return" type="xs:int"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="add">
<xs:sequence>
<xs:element name="a" type="xs:int"/>
<xs:element name="b" type="xs:int"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="addResponse">
<xs:sequence>
<xs:element name="return" type="xs:int"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
10. Briefly explain the characteristics of web service framework and web service roles.
(April/May 2017) (Nov/Dec 2017)
Service Requestor - application that is looking for and invoking an interaction with a service Service
Provider - owner of the services
Service Registry - searchable registry where service provider publishes their service descriptions and where
service find service request.
101
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
102
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
12. Write the steps in the individual design process.
The first step is an SOA composition exercise that helps identify the architectural
boundary of our planned solution. The remaining steps consist of the following individual
design processes:
• Entity-centric business service design
• Application service design
• Task-centric business service design
• Service-oriented business process design
13. What is J2EE? (April/May 2017)
The Java 2 Platform is a development and runtime environment based on the Java programming
language. It is a standardized platform that is supported by many vendors that provide
development tools, server runtimes, and middleware products for the creation and deployment of
Java solutions. The Java 2 Platform Enterprise Edition (J2EE) is built to support large-scale,
distributed solutions. The Servlets + EJBs and Web + EJB Container layers (as well as the JAX-
RPC Runtime) relate to the Web and Component Technology layers.Web technology is
incorporated is largely dependent on how a vendor chooses to implement this part of a J2EE
14. architecture.
List the components used to build J2EE web applications.
a. Java Server Pages
b. Struts
c. Java servlets
d. Enterprise Java Beans(EJB)
15. Compare "Building Blocks" versus "Service Models".
Building blocks are not an independent means of classifying service logic.
While service models are useful for classifying the nature of logic encapsulated by a
service, building blocks classify the scope of service logic.
The service model always will apply to a single service, but a building block can apply to a
range of logic.
A building block can also represent a subset of a service's logic or the collective logic of
multiple services.
16. What do you mean by the binding element in WSDL?
The binding element begins the concrete portion of the service definition, to assign a
communications protocol that can be used to access and interact with the WSDL.
The binding element appears similar in structure to the portType element. The binding
construct contains one or more operation elements.
The additional soap:binding and soap:operation elements combined within the construct
syntax. These are what establish the SOAP protocol as the manner in which this WSDL
can be communicated with.
17. What is JAX-WS?
JAX-WS stands for Java API for XML Web Services. JAX-WS is a technology for building web
services and clients that communicate using XML. JAX-WS allows developers to write
message- oriented as well as RPC-oriented web services.
18. What does the Java web service developer pack include?
Java API for XML Messaging (JAXM),Java API for XML Processing (JAXP),Java API
for XML Registries (JAXR),Java API for XML based RPC (JAX-RPC),Java API for XML
Web Services (JAX-WS),SOAP with Attachments API for Java (SAAJ),Java Server Pages
Standard Tag Library (JSTL),Java Server Faces,Java WSDP Registry Server,Web
Applications Deployment Tool,Ant Build Tool,Apache Tomcat servlet container
19. What are the types of WS-Coordination?
a. Central Coordination
b. Distributed Coordination
103
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
20. Define WS-Policy.(Apr/May 2017)
• The WS-Policy framework is comprised of the following three specifications:
– WS-Policy
– WS-PolicyAssertions WS-PolicyAttachments
• These collectively provide the following elements covered in this section,
which demonstrate how policies are formulated and attached to element or
document-level subjects:
– Policy element
– TextEncoding, Language, SpecVersion, and MessagePredicate
assertions
– ExactlyOne element
– All element
– Usage and Preference attributes
– PolicyReference element
21. List the components in WS-Policy Framework.
a. Top-level container element.
b. Policy operators that group assertions
c. Attributes that determine policy usage.
22. List the initial set of assertions in WS-Policy assertions.
a. Text encodingb.b.Language c. SpecVersion d. MessagePredicate
23. What is the purpose of WS-Security language basics?
WS-Security framework provides extensions that is used to implement message-based
security measures. These protect message contents during transport and during processing
by service intermediaries.
24. How WS-Security relates to the other WS-* specifications?
a. WS-Security can be used to sign and encrypt headers provided by WS-Addressing.
b. WS-Security can protect messages exchanged via WS-Meta-data exchange.
c. WS-Security protects SOAP messages.
d. WS-Security can be used to protect message sequences governed by WS-Reliable
messaging.
25. What do you mean by WS-Security? (April/May 2017)
WS-Security:
soap message protection through message integrity, confidentiality, and single
message authentication
extensible and flexible (multiple security tokens, trust domains, signature formats,
and encryption technologies. )
a flexible set of mechanisms that can be used to construct a range of security
protocols
26. What are the two protocols that are used with WS-Coordination?
a. WS-Business activity
b. WS-Atomic transaction
27. What is BPEL?
Business Process Execution Language is the ability to capture both the constituent
activities of a workflow and relationship between partners involved in that workflow in a
platform neutral format (XML) and supports the highest possible level of interoperability
by basing the technology on commonly adopted web service standard.
31. What are the attributes of invoke element in BPEL? (Nov/Dec 2017)
Attribute Description
partnerLink This element names the partner service via its corresponding
partnerLink.
portType The element used to identify the portType element of the partner service.
operation The partner service operation to which the process service will need to
send its request.
inputVariable The input message that will be used to communicate with the partner
service operation. Note that it is referred to as a variable because it is
referencing a WSBPEL variable element with a messageType attribute.
105
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
Part B
1. Discuss the step by step process of service modeling in detail. (Nov/Dec 2016) (Nov/Dec
2017)
A service modeling process is essentially an exercise in organizing the information we
gathered in Steps 1 and 2 of the parent service-oriented analysis process.
"Services" versus "Service Candidates"
o Candidate - The primary goal of the service-oriented analysis stage is to figure
out what it is we need to later design and build in subsequent project phases.
We are producing abstract candidates that may or may not be realized as part
of the eventual concrete design.
Service Candidates - Their behavior has significant departure from the corresponding original
candidate having subjected to the realities of the technical architecture. Then we propose service
operation candidates. Finally, service candidates and service operation candidates are
the end-result of a process called service modeling
Process description
o A series of 12 steps that comprise a proposed service modeling process
=
107
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
o Based on the results of the composition exercise in Step 6, revisit the grouping
of your business process steps and revise the organization of service operation
candidates as necessary. It is not unusual to consolidate or create new groups
(service candidates) at this point.
Step 8: Analyze application processing requirements
o By the end of Step 6, you will have created a business-centric view of your
services layer. This view could very well consist of both application and
business service candidates, but the focus so far has been on representing
business process logic.
o This next series of steps is optional and more suited for complex business
processes and larger service-oriented environments. It requires that you more
closely study the underlying processing requirements of all service candidates
to abstract any further technology-centric service candidates from this view
that will complete a preliminary application services layer.
o Specifically, what you need to determine is:
What underlying application logic needs to be executed to process the
action described by the operation candidate.
Whether the required application logic already exists or whether it
needs to be newly developed.
Whether the required application logic spans application boundaries. In
other words, is more than one system required to complete this action?
Step 9: Identify application service operation candidates
o Break down each application logic processing requirement into a series of
steps. Be explicit about how you label these steps so that they reference the
function they are performing. Ideally, you would not reference the business
process step for which this function is being identified.
Step 10: Create application service candidates
o Group these processing steps according to a predefined context. With
application service candidates, the primary context is a logical relationship
between operation candidates.
o This relationship can be based on any number of factors, including:
association with a specific legacy system
association with one or more solution components
logical grouping according to type of function
Step 11: Revise candidate service compositions
o Revisit the original scenarios you identified in Step 5 and run through them
again. Only, this time, incorporate the new application service candidates as
well. This will result in the mapping of elaborate activities that bring to life
expanded service compositions. Be sure to keep track of how business service
candidates map to underlying application service candidates during this
exercise.
Step 12: Revise application service operation grouping
o Going through the motions of mapping the activity scenarios from Step 11
usually will result in changes to the grouping and definition of application
service operation candidates. It will also likely point out any omissions in
application-level processing steps, resulting in the addition of new service
operation candidates and perhaps even new service candidates.
2. Explain in detail the application service design process.
• Service-oriented design is the process by which concrete physical service designs are
derived from logical service candidates and then assembled into abstract compositions
that implement a business process.
• Objectives of service-oriented design
– The primary questions answered by this phase are:
108
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
• How can physical service interface definitions be derived from the
service candidates modeled during the service-oriented analysis phase?
• What SOA characteristics do we want to realize and support?
• What industry standards and extensions will be required by our SOA to
implement the planned service designs and SOA characteristics?
– To address these questions, the design process actually involves further
analysis. This time our focus is on environmental factors and design standards
that will shape our services.
– The overall goals of performing a service-oriented design are as follows:
• Determine the core set of architectural extensions.
• Set the boundaries of the architecture.
• Identify required design standards.
• Define abstract service interface designs.
• Identify potential service compositions.
• Assess support for service-orientation principles.
• Explore support for characteristics of contemporary SOA.
• "Design standards" versus "Industry standards"
– Design standards represent custom standards created by an organization to
ensure that services and SOAs are built according to a set of consistent
conventions.
– Industry standards are provided by standards organizations and are published
in Web services and XML specifications
• The service-oriented design process
– We first establish a parent process that begins with some preparatory work.
This leads to a series of iterative processes that govern the creation of different
types of service designs and, ultimately, the design of the overall solution
workflow
The technical committee is in the process of finalizing the release of the next version of BPEL4WS.
The language has been renamed to the Web Services Business Process Execution Language, or
WS-BPEL.
110
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
2. The process element
The root element of a WS-BPEL is process definition. It is assigned a name value using the name
attribute and is used to establish the process definition-related namespaces.
Example. A skeleton process definition.
<process name="TimesheetSubmissionProcess"
targetNamespace="http://www.xmltc.com/tls/process/"
xmlns= "http://schemas.xmlsoap.org/ws/2003/03/business-process/"
xmlns:bpl="http://www.xmltc.com/tls/process/"
xmlns:emp="http://www.xmltc.com/tls/employee/"
xmlns:inv="http://www.xmltc.com/tls/invoice/"
xmlns:tst="http://www.xmltc.com/tls/timesheet/"
xmlns:not="http://www.xmltc.com/tls/notification/">
<partnerLinks>
...
</partnerLinks>
<variables>
...
</variables>
<sequence>
...
</sequence> ...
</process>
The process construct contains a series of common following child elements.
3. The partnerLinks and partnerLink elements
A partnerLink element establishes the port type of the service (partner) that will be participating
during the execution of the business process.
Partner services can act as a client to the process, responsible for invoking the process service.
Partner services can be invoked by the process service.
The contents of a partnerLink element represent the communication exchange between two partners
the process service being one partner and another service being the other.
Depending on the nature of the communication, the role of the process service will vary. For
instance, a process service that is invoked by an external service may act in the role of
"TimesheetSubmissionProcess" .
When this same process service invokes a different service to have an invoice verified, it acts
within a different role, "InvoiceClient."
The partnerLink element contains the myRole and partnerRole attributes that establish the service
provider role of the process service and the partner service.
The myRole attribute is used when the process service is invoked by a partner client service,
because the process service acts as the service provider.
The partnerRole attribute identifies the partner service that the process service will be invoking.
myRole and partnerRole attributes can be used by the same partnerLink element when it is expected
that the process service will act as service requestor and service provider with the same partner
service.
For example, during asynchronous communication between the process and partner services, the
myRole setting indicates the process service's role during the callback of the partner service.
Example. The partnerLinks construct containing one partnerLink element in which the process
service is invoked by an external client partner and four partnerLink elements that identify
partner services invoked by the process service.
<partnerLinks>
<partnerLink name="client"
partnerLinkType="tns:TimesheetSubmissionType"
myRole="TimesheetSubmissionServiceProvider"/>
<partnerLink name="Invoice"
111
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
partnerLinkType="inv:InvoiceType"
partnerRole="InvoiceServiceProvider"/>
<partnerLink name="Timesheet"
partnerLinkType="tst:TimesheetType"
partnerRole="TimesheetServiceProvider"/>
<partnerLink name="Employee"
partnerLinkType="emp:EmployeeType"
partnerRole="EmployeeServiceProvider"/>
<partnerLink name="Notification"
partnerLinkType="not:NotificationType"
partnerRole="NotificationServiceProvider"/>
</partnerLinks>
Each of the partnerLink elements contains a partnerLinkType attribute. This refers to the
partnerLinkType construct.
113
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
5.Explain SOA platform and describe the APIs in J2EE which is used to built SOA.
(Apr/May 2018)
• The Java 2 Platform Enterprise Edition (J2EE) is one of the two primary platforms
currently being used to develop enterprise solutions using Web services.
• Platform overview
– The Java 2 Platform is a development and runtime environment based on the
Java programming language. It is a standardized platform that is supported by
many vendors that provide development tools, server runtimes, and
middleware products for the creation and deployment of Java solutions.
– The Java 2 Platform is divided into three major development and runtime
platforms, each addressing a different type of solution.
• The Java 2 Platform Standard Edition (J2SE) is designed to support the
creation of desktop applications
• The Micro Edition (J2ME) is geared toward applications that run on
mobile devices.
• The Java 2 Platform Enterprise Edition (J2EE) is built to support large-
scale, distributed solutions. J2EE has been in existence for over five
years and has been used extensively to build traditional n-tier
applications with and without Web technologies.
114
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
• Three of the more significant specifications that pertain to SOA are listed here:
– Java 2 Platform Enterprise Edition Specification This important specification
establishes the distributed J2EE component architecture and provides
foundation standards that J2EE product vendors are required to fulfill in order
to claim J2EE compliance.
– Java API for XML-based RPC (JAX-RPC) This document defines the JAX-
RPC environment and associated core APIs. It also establishes the Service
Endpoint Model used to realize the JAX-RPC Service Endpoint, one of the
primary types of J2EE Web services (explained later).
– Web Services for J2EE The specification that defines the vanilla J2EE service
architecture and clearly lays out what parts of the service environment can be
built by the developer, implemented in a vendor-specific manner, and which
parts must be delivered according to J2EE standards.
Architecture components
• J2EE solutions inherently are distributed and therefore componentized. The following
types of components can be used to build J2EE Web applications:
– Java Server Pages (JSPs) Dynamically generated Web pages hosted by the
Web server. JSPs exist as text files comprised of code interspersed with
HTML.
– Struts An extension to J2EE that allows for the development of Web
applications with sophisticated user-interfaces and navigation.
– Java Servlets These components also reside on the Web server and are used to
process HTTP request and response exchanges. Unlike JSPs, servlets are
compiled programs.
– Enterprise JavaBeans (EJBs) The business components that perform the bulk
of the processing within enterprise solution environments. They are deployed
on dedicated application servers and can therefore leverage middleware
features, such as transaction support.
• While the first two components are of more relevance to establishing the presentation
layer of a service-oriented solution, the latter two commonly are used to realize Web
services.
Runtime environments
• The J2EE environment relies on a foundation Java runtime to process the core Java
parts of any J2EE solution. In support of Web services, J2EE provides additional
runtime layers that, in turn, supply additional Web services specific APIs (explained
later). Most notable is the JAX-RPC runtime, which establishes fundamental services,
including support for SOAP communication and WSDL processing.
• Additionally, implementations of J2EE supply two types of component containers that
provide hosting environments geared toward Web services-centric applications that
are generally EJB or servlet-based.
– EJB container This container is designed specifically to host EJB components,
and it provides a series of enterprise-level services that can be used collectively
by EJBs participating in the distributed execution of a business task.
• Examples of these services include transaction management,
concurrency management, operation-level security, and object pooling.
Web container A Web container can be considered an extension to a Web server and is
used to host Java Web applications consisting of JSP or Java servlet components. Web
containers provide runtime services geared toward the processing of JSP requests and
servlet instances.
• Programming languages
The Java 2 Platform Enterprise Edition is centered around the Java programming language.
Different vendors offer proprietary development products that provide an environment in
which the standard Java language can be used to build Web services
115
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
• Java API for XML Processing (JAXP) This API is used to process XML document
content using a number of available parsers. Both Document Object Model (DOM)
and Simple API for XML (SAX) compliant models are supported, as well as the
ability to transform and validate XML documents using XSLT stylesheets and XSD
schemas. Example packages include:
– javax.xml.parsers A
– org.w3c.dom and org.xml.sax These packages expose the industry standard
DOM and SAX document models.
– javax.xml.transform A
• Java API for XML-based RPC (JAX-RPC) The most established and popular SOAP
processing API, supporting both RPC-literal and document-literal request-response
exchanges and one-way transmissions. Example packages that support this API
include:
– javax.xml.rpc & javax.xml.rpc.server These packages contain a series of core
functions for the JAX-RPC API
– javax.xml.rpc.handler & javax.xml. rpc.handler.soap API functions for runtime
message handlers are provided by these collections of classes. (Handlers are
discussed shortly in the Service agents section.)
– javax.xml.soap & javax.xml.rpc.soap API functions for processing SOAP
message content and bindings.
• Java API for XML Registries (JAXR) An API that offers a standard interface for
accessing business and service registries. Originally developed for ebXML directories,
JAXR now includes support for UDDI.
– javax.xml.registry A series of registry access functions that support the JAXR
API.
– javax.xml.registry.infomodel Classes that represent objects within a registry.
• Java API for XML Messaging (JAXM) An asynchronous, document-style SOAP
messaging API that can be used for one-way and broadcast message transmissions
(but can still facilitate synchronous exchanges as well).
• SOAP with Attachments API for Java (SAAJ) Provides an API specifically for
managing SOAP messages requiring attachments. The SAAJ API is an
implementation of the SOAP with Attachments (SwA) specification.
• Java Architecture for XML Binding API (JAXB) This API provides a means of
generating Java classes from XSD schemas and further abstracting XML-level
development.
• Java Message Service API (JMS) A Java-centric messaging protocol used for
traditional messaging middleware solutions and providing reliable delivery features
not found in typical HTTP communication.
Service providers
• As previously mentioned, J2EE Web services are typically implemented as servlets or
EJB components. Each option is suitable to meet different requirements but also
results in different deployment configurations, as explained here:
– JAX-RPC Service Endpoint When building Web services for use within a Web
container, a JAX-RPC Service Endpoint is developed that frequently is
implemented as a servlet by the underlying Web container logic.
– EJB Service Endpoint The alternative is to expose an EJB as a Web service
through an EJB Service Endpoint. This approach is appropriate when wanting
to encapsulate existing legacy logic or when runtime features only available
within an EJB container are required. To build an EJB Service Endpoint
requires that the underlying EJB component be a specific type of EJB called a
Stateless Session Bean.
116
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
6.Give the elements of WS-Coordination specification. What are the protocols of WS
Coordination? The overall coordination mechanism consists of the activation service, the
registration service, a coordinator, and participants that implement specific protocols. It is
likely that these underlying context management services will be automatically governed
by the orchestration engine platform for which you are creating a WS-BPEL process
definition.
• In terms of the WS-Coordination language and its two protocol documents, what may
be of interest to you is the actual CoordinationContext header that is inserted into
SOAP messages. You may encounter this header if you are monitoring messages or if
you need to perform custom development associated with the coordination context.
The CoordinationContext element
– This parent construct contains a series of child elements that each house a
specific part of the context information being relayed by the header.
– The activation service returns this CoordinationContext header upon the
creation of a new activity. As described later, it is within the CoordinationType
child construct that the activity protocol (WS-BusinessActivity, WS-
AtomicTransaction) is carried. Vendor-specific implementations of WS-
Coordination can insert additional elements within the CoordinationContext
construct that represent values related to the execution environment.
– The Identifier and Expires elements
These two elements originate from a utility schema used to provide reusable elements.
WS-Coordination uses the Identifier element to associate a unique ID value with the
current activity. The Expires element sets an expiry date that establishes the extent of
the activity's possible lifespan
The CoordinationType element
• This element is described shortly in the WS-BusinessActivity and WS-
AtomicTransaction coordination types section.
The RegistrationService element
• The RegistrationService construct simply hosts the endpoint address of the registration
service. It uses the Address element also provided by the utility schema.
Designating the WS-AtomicTransaction coordination type
• In the next example, the CoordinationType element is assigned the WS-
AtomicTransaction coordination type identifier, which communicates the fact that the
header's context information is part of a short running transaction.
7.Explain in detail WS-choreography in detail.
This specification describes a formal method of defining a Choreography using a
Choreography Definition Language. Choreographies describe the sequence and conditions
in which messages are exchanged between independent processes, parties or organizations
in order to realize some useful purpose, for example placing an order.
• Choreographies need to be defined when two or more organizations or processes need
to cooperate as no single organization or process controls or manages the complete
process. For example a Buyer cannot directly control what a Seller does and vice
versa.
• Note that this differs from a Process Execution Language that can be used when there
is a single organization or process in control that can issue commands to other
processes to carry out all the actions or activities required.
• If Choreographies are not defined and agreed between the organizations or processes
involved, then those organizations and processes will not be able to successfully
interoperate to realize their shared objectives.
• By providing a formal representation of a Choreography in an XML format, this
specification allows the definition to be shared and therefore followed by all the
organizations or processes that use it.
• This specification is in two main parts:
117
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
• The first part describes how to define a Choreography in an abstract way that is
independent of:
• The format and packaging of the messages being exchanged, and
• The technology used at each end to send and receive messages
• The second part describes how to bind the messages in a Choreography to
WSDL and SOAP (Ed: required but not included in this version spec).
8. Explain in detail WS-Policy Framework.
119
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
• The WS-Security framework is comprised of numerous specifications, many in
different stages of acceptance and maturation. In this book we've concentrated on
some of the more established ones, namely:
– WS-Security
– XML-Encryption
– XML-Signature
• The Security element (WS-Security)
– This construct represents the fundamental header block provided by WS-
Security. The Security element can have a variety of child elements, ranging
from XML-Encryption and XML-Signature constructs to the token elements
provided by the WS-Security specification itself.
– Security elements can be outfitted with actor attributes that correspond to
SOAP actor roles. This allows you to add multiple Security blocks to a SOAP
message, each intended for a different recipient.
– The UsernameToken, Username,
– and Password elements (WS-
– Security)
– The UsernameToken element provides a construct that can be used to host
token information for authentication and authorization purposes. Typical
children of this construct are the Username and Password child elements, but
custom elements also can be added.
The BinarySecurityToken element
– (WS-Security)
– Tokens stored as binary data, such as certificates, can be represented in an
encoded format within the BinarySecurityToken element.
– Composing Security element
– contents (WS-Security)
– The WS-Security specification positions the Security element as a standardized
container for header blocks originating from other security extensions.
– The following example illustrates this by showing how a SAML block is
located within the Security construct.
The EncryptedData element (XML-
Encryption)
• This is the parent construct that hosts the encrypted portion of an XML document. If
located at the root of an XML document, the entire document contents are encrypted.
• The EncryptedData element's Type attribute indicates what is included in the
encrypted content. For example, a value of
http://www.w3.org/2001/04/xmlenc#Element indicates that the element and its
contents will be encrypted, whereas the value of
http://www.w3.org/2001/04/xmlenc#Content states that encryption will only be
applied to the content within the opening and closing tags.
120
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
release, the BPEL4WS specification was submitted to an OASIS technical committee
so that the specification could be developed into an official, open standard.
• The technical committee is in the process of finalizing the release of the next version
of BPEL4WS. It has been announced that the language itself has been renamed to the
Web Services Business Process Execution Language, or WS-BPEL (and assigned the
2.0 version number).
• Prerequisites
• Concepts relating to orchestration, coordination, atomic transactions, and
business activities are covered, and are therefore not repeated here.
• The process element
• The partnerLinks and partnerLink elements
• A partnerLink element establishes the port type of the service (partner) that
will be participating during the execution of the business process. Partner
services can act as a client to the process, responsible for invoking the process
service. Alternatively, partner services can be invoked by the process service
itself.
• The contents of a partnerLink element represent the communication exchange
between two partnersthe process service being one partner and another service
being the other. Depending on the nature of the communication, the role of the
process service will vary. For instance, a process service that is invoked by an
external service may act in the role of "TimesheetSubmissionProcess."
• The partnerLinkType element
• For each partner service involved in a process, partnerLinkType elements
identify the WSDL portType elements referenced by the partnerLink elements
within the process definition. Therefore, these constructs typically are
embedded directly within the WSDL documents of every partner service.
• The partnerLinkType construct contains one role element for each role the
service can play, as defined by the partnerLink myRole and partnerRole
attributes. As a result, a partnerLinkType will have either one or two child role
elements.
The variables element
• WS-BPEL process services commonly use the variables construct to store state
information related to the immediate workflow logic. Entire messages and data sets
formatted as XSD schema types can be placed into a variable and retrieved later
during the course of the process. The type of data that can be assigned to a variable
element needs to be predefined using one of the following three attributes:
messageType, element, or type.
• The messageType attribute allows for the variable to contain an entire WSDL-defined
message, whereas the element attribute simply refers to an XSD element construct.
The type attribute can be used to just represent an XSD simpleType, such as string or
integer.
The getVariableProperty and getVariableData functions
• WS-BPEL provides built-in functions that allow information stored in or associated
with variables to be processed during the execution of a business process.
– getVariableProperty(variable name, property name)
• This function allows global property values to be retrieved from
variables. It simply accepts the variable and property names as input
and returns the requested value.
– getVariableData(variable name, part name, location path)
• Because variables commonly are used to manage state information, this
function is required to provide other parts of the process logic access to
this data. The getVariableData function has a mandatory variable name
121
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
parameter and two optional arguments that can be used to specify a part
of the variable data.
The sequence element
• The sequence construct allows you to organize a series of activities so that they are
executed in a predefined, sequential order. WS-BPEL provides numerous activities that can
be used to express the workflow logic within the process definition.
11. Explain the different types of security attacks and threats and also give the web security
road map.(April/May 2017) (Apr/May 2018)
I. Types of Attacks
• Physical Access Attacks
– Wiretapping
– Server Hacking
– Vandalism
• Dialog Attacks
– Eavesdropping
– Impersonation
– Message Alteration
• Penetration Attacks
– Scanning (Probing)
– Break-in
– Denial of Service
– Malware
• Viruses
• Worms
• Social Engineering
– Opening Attachments
– Password Theft
– Information Theft
II. Types of Threats:
• Interruption
– An asset of the system is destroyed of becomes unavailable or unusable
– Attack on availability
– Destruction of hardware
– Cutting of a communication line
– Disabling the file management system
• Interception
– An unauthorized party gains access to an asset
– Attack on confidentiality
– Wiretapping to capture data in a network
– Illicit copying of files or programs
• Modification
– An unauthorized party not only gains access but tampers with an asset
– Attack on integrity
– Changing values in a data file
– Altering a program so that it performs differently
122
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
– Modifying the content of messages being transmitted in a network
• Fabrication
– An unauthorized party inserts counterfeit objects into the system
– Attack on authenticity
– Insertion of spurious messages in a network
– Addition of records to a file
WS-SecureConversation
•
Builds on the concept of trust based on security tokens
•
Defines how to establish a secured session between services for exchanging data using the rules
•
defined in WS-Policy, WS-Trust, and WS-Privacy
Defines how to create a context for a particular conversation with a Web Service and how to
•• create keys that can be used in that context
•
WS-Federation
Describes how to manage and broker trust relationships (trust of identities, attributes, and
authentication) in a heterogeneous federated environment (among Web Services) leading Single
•
Sign-On.
•
Comprise of the following:
WS-Federation: Active Requestor Profile - defines mechanisms for requesting, exchanging, and
issuing security tokens within the context of active requestors (an application capable of issuing WS
messages).
• WS-Federation (Language) - defines how federation works in the WS-Security stack.
•
WS-Federation: Passive Requestor Profile (HTTP browser) - defines a system for passive mechanisms to
work seamlessly with a single or simplified sign-on to the WS-Federation system.
123
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
•
WS-Authorization
• Describes how access policies for a Web Service are specified and managed.
•
Describes howclaims may be specified within security tokens and how these claims will be interpreted at
the endpoint.
•
WS-Policy
• Defines the policy rules on how services interact
•
Includes 4 specs
• A Policy Framework(WS-Policy) - defines a grammar for expressing WS policies
•
A Policy Attachment (WS-Policy-Attachment) - defines how to attach these policies to WS
•
A set of general policy assertions (WS-Policy-Assertions)
•
A set of security policy assertions (WS-Security Policy)
•
WS-Trust
The
trust between a service requester and a service provider is established through the exchange of
information between the two parties in an expected and understood manner
WS-Security already defines the basic mechanisms to securely exchange messages using security tokens
Builds on top of WS-Security and defines how the security tokens are issued and exchanged
Defines a set of interfaces that a secure token service may provide for the issuance, exchange, and validation
of security tokens
WS-Privacy
defines how privacy of information is maintained
WS-Security
Enhance SOAP messaging by providing quality of protection through message integrity and message
confidentiality.
Authentication with Security tokens – username and passwords, Kerberos tickets, X.509 certificate
Message integrity – XML Signature with security tokens
Message confidentiality – XML Encryption with security tokens
12. Explain the overview of SOA and the role of web services with .NET Interoperability and
J2EE Interoperability. (April/May 2017)
The .NET and J2EE frameworks are providing support for Web Services:
Microsoft .NET
Microsoft .NET is the Microsoft XML Web Services platform. It provides built-in support for
building and consuming standards-based Web Services. It enables the creation and use of XML-
based applications, processes, and Web sites as Web Services.
Through just a single line of code and/or setting a value of an attribute, it is possible to turn an
application into a Web Service in the .NET environment.
By default all inter-process communication is done using the SOAP standard.
According to the .NET framework, all components can be Web Services, and Web Services are
just a kind of component".
Differences Between J2EE and .NET Frameworks for Web Services Support
125
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
126
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
13. Explain the various standards in the development of web services. (April/May 2017)
(Apr/May 2018)
I.Basic Web Services Standards
• XML (eXtensible Markup Language) 1.1
• SOAP 1.2 (Simple Object Access Protocol)
• WSDL (Web Services Description Language) 1.1
• UDDI (Universal, Description, Discovery, and Integration) 3.0.2
a. XML 1.1
• Developed by W3C
• Fee-free open standard
• Its primary purpose is to facilitate the sharing of structured data across different information
systems, particularly via the Internet.
• A subset of SGML (Standard Generalized Markup Language)
b. SOAP 1.2
127
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology
IT6801 Service Oriented Architecture Department of IT 2018-19
OASIS Standard
SOAP version 1.2 is a lightweight protocol for exchange of information in a decentralized,
distributed environment.
• No security specification
• The SOAP Header provides a flexible mechanism for extending a SOAP message.
• Although the SOAP Header is the best place to add security features to messages, the SOAP
specification itself does not specify such header elements.
c. WSDL
It is an XML-based language for describing Web Services and how to access them.
It specifies the location of the service and the operations the services exposes.
A WSDL document is simply a set of definitions.
d. UDDI
• The Universal Description, Discovery, and Integration specs define a way to publish and
discover information about Web services.
• The UDDI business registration is an XML file that describes a business entity and its Web
services.
UDDI security
• Not specified in detail, only general policies
• Only authorized individuals can publish or change information in the registry
• Changes or deletions can only be made by the originator of the information
• Each instance of a registry can define its own user authentication mechanism
Layers and Web Services Standards
• Using these security standards, application can engage secure communication designed
to work with the general web services framework.
• Some security standards are:
– SAML 2.0 (Security Assertion Markup Language)
– SPML 2.0 (Service Provisioning Markup Language)
– XACML 2.0 (eXtensible Access Control Markup Language)
– WS-Security 1.1
V. Reliable Messaging Standards
• The objective of these standards is to allow messages to be delivered reliably between
distributed applications in the presence of system or network failure.
• Some reliable messaging standards are:
– WS-ReliableMessaging 1.1
– WS-Reliability 1.1
– WS-RM Policy Assertion 1.1
•These standards specify the potential order of operations from a collection of web services,
the data shared between them, which partners are involved and other issues involving how
multiple services and organizations participate.
• Some Business Process are:
– WS-BPEL 2.0 (Business Process Execution Language)
– WS-Choreography 1.0
129
St. Joseph’s College of Engineering/St. Joseph’s Institute of Technology