Service Oriented Architecture
Service Oriented Architecture
A Course Material
On
Service Oriented Architecture
By
L.Sankaran
Assistant Professor
Computer Science and Engineering Department
Quality Certificate
Year/Sem:IV/VII
Name: L.Sankaran
This is to certify that the course material being prepared by Mr. L.Sankaran is of the
adequate quality. He has referred more than five books and one among them is from
abroad author.
Seal: Seal:
OBJECTIVES:
The student should be made to:
Learn XML fundamentals.
Be exposed to build applications based on XML.
Understand the key principles behind SOA.
Be familiar with the web services technology elements for realizing SOA.
Learn the various web service standards.
TEXTBOOKS:
1. Ron Schmelzer et al. ―XML and Web Services‖, Pearson Education, 2002.
2. Thomas Erl, ―Service Oriented Architecture: Concepts, Technology, and Design‖,
Pearson Education, 2005.
REFERENCES:
1. Frank P.Coyle, ―XML, Web Services and the Data Revolution‖, Pearson Education,
2002
2. Eric Newcomer, Greg Lomow, ―Understanding SOA with Web Services‖, Pearson
Education,2005
3. Sandeep Chatterjee and James Webber, ―Developing Enterprise Web Services: An
Architect's Guide‖, Prentice Hall, 2004.
4. James McGovern, Sameer Tyagi, Michael Stevens, Sunil Mathew, ―Java Web
Services Architecture‖, Morgan Kaufmann Publishers, 2003
CONTENTS
1 Unit – I 7
2 Unit – II 38
3 Unit – III 62
4 Unit – IV 85
5 Unit – V 113
Prerequisite
Unit – I
Introduction To Xml
Part – A
2. What are the major portions of an XML document structure?.[ CO1 - L1]
The XML declaration
The Document Type Declaration
The element data
The attribute data
The character data or XML content
Example1: our shirt element begins with <shirt> and ends with </shirt>.
11. What is meant by Well formed XML documents?.[ CO1 - L1 - Nov/Dec 2016]
An XML document is well formed if it follows all the preceding syntax rules of XML.
On the other hand, if it includes inappropriate markup or characters that cannot be
processed by XML parsers, the document cannot be considered well formed.
It goes without saying that an XML document can‗t be partially well formed. And, by
definition, if a document is not well formed, it is not XML. This means that there is no
such thing as an XML document that is not well formed, and XML processors are not
required to process these documents.
20. What are the XML rules for distinguishing between the content of a document
and the XML markup element? .[ CO1 - L1]
The start of XML markup elements is identified by either the less than symbol (<) or the
ampersand (&) character Three other characters, the greater than symbol (>), the
apostrophe or single quote (‗) and the double quotation marks (―) are used by XML for
markup. To use these special characters as content within your document, you must
use the corresponding general XML entity.
XPATH - xpath gets its name from its use of a payh notation to navigate through the
hierarchical tree structure of an XML document XQUERY - it is w3c initiative to define a
standard set of constructs for querying & searching XML document.
36. What are all the priorities available for evaluating XPath expressions?.[ CO1 -
L1]
Grouping
Filters
Path operations
Example :
<empname>This is a character data.</empname>
Start and end tags must be paired and must be properly nested with other pairs of start
and end tags.
Example:
<b><i>This text is bold and italic</i></b>
Attribute specifications may appear within start tags or empty-element tags.
Every attribute specification consists of an attribute name followed by an equals sign
(=) followed by a quoted attribute value.
Example:
<img src=‖flower.jpg‖ alt=‖flower‖ />
An attribute value may not contain the character <; if the character & appears, it must be
the first character in a character or entity reference. A pair of either single quotes or
double quotes may be used to quote an attribute value.
Attribute specifications are white-space-separated from one another.
The XML declaration is a processing instruction of the form <?xml ...?>. 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.The XML
declaration indicates the presence of external markup declarations and character
encoding. Because a number of documents formats use markup similar to XML, the
declaration is useful in establishing the document as being compliant with a specific
version of XML without any doubt or ambiguity.
don‗t require the inclusion of the DOCTYPE, valid XML documents do.Valid XML
documents must declare the document type to which they comply, whereas well-formed
XML documents can include the DOCTYPE to simplify the task of the various tools that
will be manipulating the XML document.
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.
Example2:
<on_sale/>. In this case, there would be no other matching element of the same name
used in a different manner. These ―unmatched‖ elements are known as empty
elements.
The trailing ―/>in the modified syntax indicates to a program processing the XML
document that the element is empty and no matching end tag should be sought.
The XML is a hierarchical tree. This means that XML elements exist within other
elements and can branch off with various children nodes. The nature of XML is to allow
for the growth of these elements in a manner that‗s as ―wide‖ or ―deep‖ as possible.
This means that a single XML element can contain any number of child elements, and
the depth of the XML tree can consist of any number of nodes.
XML elements can contain letters, numbers, and other characters, but names cannot
start with a number or any punctuation character. XML names cannot contain spaces
because white spaces, is used within an element to separate the various attribute
sections. Also, XML elements cannot contain the greater-than or less-than characters
for obvious reasons.
XML elements cannot start with the letters ―xml‖ because they are reserved for future
use.
XML elements cannot contain the colon character because it is reserved for use in XML
namespaces.
Although punctuation marks (other than the colon) can be used within an XML element
name, you should avoid the hyphen (-) and period (.)
Element names can be as long as you like, with almost no real size limitation. This
means that the element <wow_this_really_is_one_heck_of_a_long_element_name> is
actually valid, but what programmer would want to type that element repeatedly or
encode a software application to key on that particular element name. Also, some
devices with constrained memory capabilities may not work well with overly long XML
tag names.
XML also allows for the use of non-English letters, such as á, é, and ò, in a document.
In fact, XML allows all Unicode 2.3 characters.
Attributes
Attributes are name/value pairs contained within the start element that can specify text
strings that modify the context of the element.
Example: <price currency= ―USD‖>_</price>
2.Entity References
There are times to introduce special characters or make use of content that is
constantly repeated without having to enter it multiple times. This is the role of the XML
entity
3.Comments
Comments are quite simple to include in a document. The character sequence <!--
begins a comment and --> ends the comment.
Between these two delimiters, any text at all can be written, including valid XML
markup. The only restriction is that the comment delimiters cannot be used; neither can
the literal string Comments can be placed anywhere in a document and are not
considered to be part of the textual content of an XML document.
Example: <!..The below element talks about an Elephant I once owned…..>
4. Processing Instructions
Processing instructions (PIs) perform a similar function as comments in that they are not
a textual part of an XML document but provide information to applications as to how the
content should be processed.
Processing instructions have the following form: <?instruction options?>
The instruction name, called the PI target, is a special identifier that the processing
application is intended to understand.
Example: <?send-message ―process complete‖?>
In the content section, any characters can be included, with the necessary exception of
the character string ]]>.
<object_code>
<![CDATA[
Function master(poltice integer){ If poltice<=3 then {
IntMaster=poltice+IntToString(FindElement(―<chicken>‖));
}
}
]]></object_code>
Well-Formed Documents
An XML document is well formed if it follows all the preceding syntax rules of XML.
On the other hand, if it includes inappropriate markup or characters that cannot be
processed by XML parsers, the document cannot be considered well formed.
It goes without saying that an XML document can‗t be partially well formed. And, by
definition, if a document is not well formed, it is not XML. This means that there is no
such thing as an XML document that is not well formed, and XML processors are not
required to process these documents.
Valid Documents
A well-formed XML document is considered valid only if it contains a proper Document
Type Declaration and if the document obeys the constraints of that declaration. In most
cases, the constraints of the declaration will be expressed as a DTD or an XML
Schema.
The possible elements and the ordering of those elements in a document, valid XML
documents can take advantage of certain advanced features of XML that are not
available to merely well-formed documents due to their lack of a DTD or XML Schema.
The creation of well-formed XML is a simple process; the use of valid XML documents
can greatly improve the quality of document processes.
Valid XML documents allow users to take advantage of content management, business-
to-business transactions, enterprise integration, and other processes that require the
exchange of constrained XML documents.
5. Explain the role of XML name spaces with example.[ CO1 – L2]
XML namespaces - XML Namespace is used to avoid element name conflict in XML
document.The XML Namespace recommendation provides a mechanism for identifying
each element and attribute name within a document with a specific XML vocabulary.
An XML namespace is a collection of element and attribute names associated with a
particular XML vocabulary (such as XHTML) through an absolute URI known as the
namespace name
Default namespace :
<html xmlns="http://www.w3.org/1999/xhtml">
XML Namespace Declaration - An XML namespace is declared using the reserved XML
attribute. This attribute name must be started with "xmlns".
Example
<?xmlversion="1.0" encoding="UTF-8"?>
<cont:contact xmlns:cont="http://sssit.org/contact-us">
<cont:name>VimalJaiswal</cont:name>
<cont:company>SSSIT.org</cont:company>
<cont:phone>(0120) 425-6464</cont:phone>
</cont:contact>
Namespace Prefix: cont
Namespace Identifier: http://sssit.org/contact-us
It specifies that the element name and attribute names with cont prefix belongs to
http://sssit.org/contact-us name space.
In XML, elements name are defined by the developer so there is a chance to conflict in
name of the elements. To avoid these types of confliction we use XML Namespaces.
The XML Namespaces provide a method to avoid element name conflict. Generally
these conflicts occur when we try to mix XML documents from different XML application.
Table 1:
<table>
<tr>
<td>Aries</td>
<td>Bingo</td>
</tr>
</table>
Table 2:
This table carries information about a computer table.
<table>
<name>Computer table</name>
<width>80</width
><length>120</length>
</table>
If you add these both XML fragments together, there would be a name conflict because
both have <table>element. Although they have different name and meaning
How to get rid of name conflict?
1) By Using a Prefix
Table 1:<h:table>
<h:tr><h:td>Aries</h:td>
<h:td>Bingo</h:td></h:tr>
</h:table>
Table 2:<f:table>
<f:name>Computer
table</f:name><f:width>80</f:width><f:length>120</f:length></f:table>
Note: In this example, you will get no conflict because both the tables have specific
names.
2) By Using xmlns Attribute
<root>
<h:table xmlns:h="http://www.abc.com/TR/html4/"><h:tr>
<h:td>Aries</h:td>
<h:td>Bingo</h:td>
</h:tr>
</h:table>
<f:table:xmlns:f="http://www.xyz.com/furniture"><f:name>Computer
table</f:name><f:width>80</f:width><f:length>120</f:length>
</f:table>
</root>
In the above example, the <table> element defines a namespace and when a
namespace is defined for an element, the child elements with the same prefixes are
associated with the same namespace.
<rootxmlns:h="http://www.abc.com/TR/html4/"
xmlns:f="http://www.xyz.com/furniture"><h:table>
<h:tr>
<h:td>Aries</h:td>
<h:td>Bingo</h:td>
</h:tr>
</h:table>
<f:table>
<f:name>Computer table</f:name><f:width>80</f:width><f:length>120</f:length>
</f:table>
</root>
Note: The Namespace URI used in the above example is not necessary at all. It is not
used by parser to look upinformation. It is only used to provide a unique name to the
Namespace identifier.
an internet domain address. There is also an URI name URN (Universal Resource
Name) but it is not so common.
6.Briefly discuss about XML and DTD. Write a DTD for employee including
employee name (firstname and lastname) Employee Date of birth (month, Date
and Year) and address (city and state) .[ CO1 – L2]
XML and DTD
A DTD (Document Type Definition) describes the structure of one or more XML
documents. Specifically, a DTD describes:
Elements
Attributes, and
Entities
An XML document is well-structured if it follows certain simple syntactic rules
An XML document is valid if it also specifies and conforms to a DTD
Why DTD?
A DTD allows the XML document to be verified (shown to be legal)
A DTD that is shared across groups and allows the groups to produce consistent XML
documents Parsers An XML parser is an API that reads the content of an XML
document,Currently popular APIs are DOM (Document Object Model) and SAX
(Simple API for XML) A validating parser is an XML parser that compares the XML
document to a DTD and reports any errors.Most browsers don‗t use validating parser
An XML example
<novel>
<foreword>
<paragraph>This is the great American novel.</ paragraph></foreword>
<chapter number="1">
<paragraph>It was a dark and stormy night.</paragraph><paragraph>Suddenly, a shot
rang out!</paragraph>
</chapter>
</novel>
An XML document contains (and the DTD describes):
Elements, such as novel and paragraph, consisting of tags and content
Attributes, such as number="1", consisting of a name and a value
Entities (not used in this example)
A DTD example
<!DOCTYP E novel [
<!ELEMENT novel (foreword, chapter+)><!ELEMENT foreword(paragraph+)>
<!ELEMENT chapter (paragraph+)>
<!ELEMENT paragraph(#PCDATA)>
<!ATTLIST chapter number CDATA #REQUIRED>
]>
A novel consists of a foreword and one or more chapters, in that order
Each chapter must have a number attribute
A foreword consists of one or more paragraphs
A chapter also consists of one or more paragraphs
A paragraph consists of parsed character data (text that cannot contain any other
elements)
ELEMENT descriptions
Suffixes:
? optional foreword?
+ one or more chapter+
* zero or more appendix*
Separators:
both, in order foreword?, chapter+
| or section chapter
Grouping:
() grouping (section |chapter)+
Element Syntax
7. Explain in detail and give example of XML Schema?.[ CO1 – L2 - Nov/Dec 2016]
What is an XML Schema?
An XML Schema describes the structure of an XML document. The purpose of an XML
Schema is to define the legal building blocks of an XML document, just like a DTD.
An XML Schema:
Elements that can appear in a document
Attributes that can appear in a document
Which elements are child elements
The order of child elements
The number of child elements
Whether an element is empty or can include text
Data types for elements and attributes
Default and fixed values for elements and attributes
XML Schema
Valid XML Document for XML Schema (employee.xml)
<?xml version="1.0"?>
<Employee_Info xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="employee.xs">
<Employee Employee_Number="105">
<Name>Masashi Okamura</Name>
<Department>Design Department</Department>
<Telephone>03-1452-4567</Telephone>
<Email>[email protected]</Email>
</Employee>
<Employee Employee_Number="109">
<Name>Aiko Tanaka</Name>
<Department>Sales Department</Department>
<Telephone>03-6459-98764</Telephone>
<Email>[email protected]</Email>
</Employee>
</Employee_Info>
</xs:complexType>
<xs:element name="Employee" type="EmployeeType" />
<xs:complexType name="EmployeeType">
<xs:sequence >
<xs:element ref="Name" />
<xs:element ref="Department" /><xs:element ref="Telephone" />
<xs:element ref="Email" />
</xs:sequence
<xs:attribute name="Employee_Number" type="xs:int" use="required"/>
</xs:complexType>
<xs:element name="Name" type="xs:string" />
<xs:element name="Department" type="xs:string" />
<xs:element name="Telephone" type="xs:string" />
<xs:element name="Email" type="xs:string" />
</xs:schema>
XLink allows an XML document to specify a link from the current document to another
document in another location.
XPointer expands on the functionality of XLink by building on the XPath specification
and identifying a node or node set to link to in the target document. This provides much
the same functionality as a foreign key within a table of a database.XPointers provide
the same functionality within a group of XML documents.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 (for which XPath provides the core functionality) and XPointer to locate a set
of nodes.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 also return any of the following:
1. A node set
2. A Boolean value
3. A string value
4. A numeric value
Axis
The axis portion of the location step identifies the hierarchical relationship for the
desired nodes from the current context.
Every axis has a principal node type:
If an axis is an element, the principal node type is element; otherwise, it is the type of
node the axis can contain.
If the axis is attribute, the principal node type is attribute.
A node test may also contain a node name, or QName. In this case, a node with the
specified name is sought, and if found, it‗s returned in the node set. However, the nodes
selected in this manner must be the principal node type sought and have an expanded
name equal to the QName specified.
This means that if the node belongs to a namespace, the namespace must also be
included in the node test for the node to be selected.
For instance, ancestor::div and ancestor::test:div will produce two entirely different node
sets. In this first case, only nodes that have no namespace specified and have a name
of div will be selected. In the second case, only those div nodes belonging to the test
namespace will be selected.
In addition to specifying an actual node name, other node tests are available to select
the desired nodes. Here‗s a list of these node tests:
comment()
node()
processing-instruction()
text()
The comment() node test selects comment nodes from an XML document.
The node() node test selects a node of any type, whereas the text() node test selects
those nodes that are text nodes.
The processing-instruction() node test, because this node test will accept a literal string
parameter to specify the name of a desired processing instruction.
Predicates
The predicate portion of a location step filters a node set on the specified axis to create
a new node set. Each node in the preliminary node set is evaluated against the
predicate to see whether it matches the filter criteria.
If it does, the node ends up in the filtered node set. Otherwise, it doesn‗t.
A predicate may consist of a filter condition that is applied to an axis that either directs
the condition in a forward or reverse direction.
A forward axis predicate contains the current context node and nodes that follow the
context node.
A reverse axis predicate contains the current context node and nodes that precede the
context node.
XPath Functions
XPath functions are used to evaluate XPath expressions and can be divided into one of
four main groups:
Boolean
Node set
Number
String
XPointer
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 node tests already listed for XPath expressions
The next two functions, here() and origin(), are interesting functions in their own right.
The here() function, as indicated, refers to the current element.
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:
1. Node points
2. 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.
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 sub trees 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.
Within the XPointer Language, a range can be specified by using the keyword to within
the XPointer expression in conjunction with the start-point() and end-point() functions.
1. xlink:type:
The xlink:type attribute must contain one of the following values:
Simple - A value of simple creates a simple link between resources.
Extended - A value of extended creates an extended link.
Locator - A value of locator creates a link that points to another resource.
Arc - A value of arc creates an arc with multiple resources and various traversal paths.
Resource - A resource value creates a link to indicate a specific resource.
Title - A value of title creates a title link
none - a value of none for the xlink:type attribute, the parent element has no XLink
meaning, and no other XLink-related content or attributes have any relationship to the
element.
2.xlink:href:
The xlink:href attribute supplies the location of the resource to link to. This attribute is a
URI reference that can be used to find the desired resource.
3.xlink:role:
The xlink:role attribute specifies the function of the link. This attribute may only be used
for the following XLink types:
• Extended
• Simple
• Locator
• Resource
4.xlink:arcrole
The xlink:arcrole attribute may only be used with two types of XLinks:
• Arc
• Simple
5.xlink:title
The xlink:title attribute is completely optional and is provided for us to make some
sense of and document, in a way, what a particular link is. If the xlink:title attribute is
specified, it should contain a string describing the resource.
6.xlink:show
The xlink:show attribute is an optionally specified attribute for a link for the simple and
arc XLink types and will accept the following values:
New- A value of new is specified, the resource will be loaded into a new window.
Replace - A value of replace indicates that the resource should be loaded into the
current window
Embed - A value of embed will load the resource into the specified location and wrap
the originating resource around it, as appropriate.
Other - A value of other allows each application using XLinks to look for other
indications within the XML document to determine what needs to be done.
None - A value of none has essentially the same effect as specifying a value of other,
with the exception that the application is not expected to look for other indications as to
what to do to display the link.
7. xlink:actuate
The xlink:actuate attribute is used to indicate when the linked resource should be
loaded. This attribute will accept the following values:
Onload - A value of onLoad indicates that when the current resource is loading, the
linked resource should be loaded as well.
onRequest - A value of onRequest means the linked document should only be loaded
when some post-loading event triggers a message for traversal.
other - A value of other indicates, again, that the application should look for other
indications as to what the desired behavior is.
none - A value of none specifies that the application is free to handle the loading of the
linked resource in whatever manner seems appropriate.
Unit - II
Building Xml- Based Applications
Part – A
1. What are the different XSLT elements?.[ CO1 - L1]
Style sheet
Value-of
For-each
Sort
Text
XSL (XML Style sheet) Programming is the Next Generation of the CSS (Cascading
Style Sheet Programming).In CSS, users can use certain style tags which the browsers
can understand and are predefined by W3 consortium.
XSL takes to one step ahead and users can define any tags in the XML file.
XML sheets can help in showing the same data in different formats.
<?xml-stylesheet href="doc.xsl" type="text/xsl"?>
PART B
1. Explain how XML is processed with the help of SAX.[ CO1 – L2]
When such an event occurs, the handler automatically calls back to a particular method
overridden by the client, and feeds as arguments the method what it sees
SAX parser is event-based; it works like an event handler in Java.
If the parser is namespace-aware,namespaceURI will hold the prefix (before the colon)
localName will hold the element name (without a prefix) qualifiedName will be the empty
stringIf the parser is not using namespaces,namespaceURI and localName will be
empty strings qualifiedName will hold the element name (possibly with prefix) When
SAX calls startElement, it passes in a parameter of type Attributes .Attributes is an
interface that defines a number of useful methods; o getLength() returns the number of
attributes getLocalName(index) returns the attribute‗s local name o getQName(index)
returns the attribute‗s qualified name o getValue(index) returns the attribute‗s value As
with elements, if the local name is the empty string, then the attribute‗s name is in the
qualified name public void end Element()throws SAX Exception Receive notification of
the end of an element
Program1- SAXCountEmployees.java
Import javax.xml.parsers.SAXParserFactory;
import org.xml.sax.XMLReader;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
class SAXCountEmployees {
static public void main(String args[]) { try {
String FEED_URL = "employee.xml";
SAXParserFactory saxFactory = SAXParserFactory.newInstance(); XMLReader parser
= saxFactory.newSAXParser().getXMLReader();
parser.setContentHandler(new CountElementsHelper()); parser.parse(FEED_URL);
}
catch (Exception e)
{
e.printStackTrace();
}
return;
}
private static class CountElementsHelper extends DefaultHandler { int numElements;
CountElementsHelper() {
super();
}
public void startDocument() throws
SAXException { numElements = 0;
return; }
public void startElement(String namespaceURI, String localName, String qName,
Attributes atts) throws SAXException
{
if (qName.equals("Employee")) { numElements++;
}
return;
}
public void endDocument() throws SAXException
{
System.out.println("Input document has " + numElements + " 'Employee' elements.");
return;
}}}
Program 2 -- employee.xml
<?xml version = "1.0" ?>
<Employee-Detail>
<Employee>
<Emp_Id> 11032 </Emp_Id>
<Emp_Name> Geetha </Emp_Name>
<Emp_E-mail>[email protected] </Emp_E-mail>
</Employee>
<Employee>
<Emp_Id> 11022 </Emp_Id>
<Emp_Name> sumalatha</Emp_Name>
<Emp_E-mail> [email protected] </Emp_E-mail>
</Employee>
<Employee>
<Emp_Id> 11011 </Emp_Id>
<Emp_Name> Lakshmanan </Emp_Name>
<Emp_E-mail> [email protected] </Emp_E-mail>
</Employee></Employee-Detail>
Input document has 3 Employee elements
Advantage:
It is simple. SAX supported in almost all programming languages
Quantity of memory usage is low. (3) It works well in stream application
Only for reading xml-documents
Disadvantage:
The data is broken into pieces and clients never have all the information as a whole
unless they
create their own data structure
Properties of DOM
Programmers can build documents, navigate their structure, and add, modify, or delete
elements and content.
Provides a standard programming interface that can be used in a wide variety of
environments and applications.
XML Parser
The XML DOM contains methods (functions) to traverse XML trees, access, insert, and
delete nodes. However, before an XML document can be accessed and manipulated, it
must be loaded into an XML DOM object.
An XML parser reads XML, and converts it into an XML DOM object that can be
accessed with JavaScript. Most browsers have a built-in XML parser.
Program1- DOMCountEmployees.java
// JAXP classes
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
// DOM classes
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
// JDK classes
import java.io.File;
class DOMCountEmployees
{
static public void main(String args[])
{
try {
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder parser = docBuilderFactory.newDocumentBuilder();
Document document = parser.parse(new File("employee.xml"));
NodeList emplist = document.getElementsByTagName("Employee");
System.out.println("Input document has"+emplist.getLength() + " 'Employee'
elements.");
}
catch (Exception e)
{
e.printStackTrace();
} return;
}
}
Program employee.xml
<?xml version = "1.0" ?>
<Employee-Detail>
<Employee>
<Emp_Id> 11032 </Emp_Id>
<Emp_Name> Geetha </Emp_Name>
<Emp_E-mail>[email protected] </Emp_E-mail>
</Employee>
<Employee>
<Emp_Id> 11022 </Emp_Id>
<Emp_Name> sumalatha</Emp_Name>
<Emp_E-mail> [email protected] </Emp_E-mail>
</Employee>
<Employee>
<Emp_Id> 11011 </Emp_Id>
<Emp_Name> Lakshmanan </Emp_Name>
<Emp_E-mail> [email protected] </Emp_E-mail>
</Employee>
</Employee-Detail>
3. Explain detail about Parsing XML Using Document Object Model.[ CO1 – L2 -
Nov/Dec 2016]
The Document Object Model (DOM)
provides a way of representing an XML document in memory so that it can be
manipulated by your software.
DOM is a standard application programming interface (API) that makes it easy for
programmers to access elements and delete, add, or edit content and attributes.
DOM Levels
The DOM working group works on phases (or levels) of the specification.
Level 1:
Allows traversal of an XML document as well as the manipulation of the content in that
document.
Level 2 :
Extends Level 1 with additional features such as namespace support, events, ranges,
and so on.
Level 3:
it is currently a working draft. This means that it is under active development and
subject to change.
DOM Core
The DOM core is available in DOM Level 1 and beyond. It permits to create and
manipulate XML documents in memory. DOM is a tree structure that represents
elements, attributes, and content.
<purchase-order>
<customer>James Bond</customer>
<merchant>Spic</merhant>
<items>
<item>Night vision camera</item>
<item>Vibrating massager</item>
</items>
</purchase-order>
Tree structure
Parents, Children, and Siblings
The DOM specification uses the words parents, children, and siblings to represent
nodes and their relationships to one another.
Parent nodes may have zero or more child nodes.
Parent nodes themselves may be the child nodes of another parent node. The ultimate
parent of all nodes is, of course, the root node.
Siblings represent the child nodes of the same parent. These abstract descriptions of
nodes are mapped to elements, attributes, text, and other information in an XML
document.
DOM interfaces contain methods for obtaining the parent, children, and siblings of any
node
The root node has no parent, and there will be nodes that have no children or siblings.
DOM Interfaces
The DOM interfaces are defined in IDL so that they are language neutral.
SimpleWalker.java
package com.madhu.xml;
import java.io.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;
public class SimpleWalker {
protected DocumentBuilder docBuilder;
protected Element root;
public SimpleWalker() throws Exception {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
docBuilder = dbf.newDocumentBuilder();
DOMImplementation domImp = docBuilder.getDOMImplementation(); if
(domImp.hasFeature(―XML‖, ―2.0‖))
{
System.out.println(―Parser supports extended interfaces‖);
}
}
public void parse(String fileName) throws Exception {
Document doc = docBuilder.parse(new FileInputStream(fileName));
root = doc.getDocumentElement();
System.out.println(―Root element is ― + root.getNodeName());
}
public void printAllElements() throws Exception { printElement(―‖, root);
}
public void printElement(String indent, Node aNode)
{
System.out.println(indent + ―<‖ + aNode.getNodeName() + ―>‖);
Node child = aNode.getFirstChild(); while (child != null) {
printElement(indent + ―\t‖, child); child = child.getNextSibling();
}
System.out.println(indent + ―</‖ + aNode.getNodeName() + ―>‖);
}
public static void main(String args[]) throws Exception
{
SimpleWalker sw = new SimpleWalker(); sw.parse(args[0]);
sw.printAllElements();
}
}
<#text>
</#text>
<book>
<#text>
</#text>
</book>
<#text>
</#text>
</fiction>
<#text>
</#text>
<biography>
<#text>
</#text>
<book>
<#text>
</#text>
</book>
<#text>
</#text>
</biography>
<#text>
</#text>
</library>
4. Explain in detail about Parsing XML Using SAX.[ CO1 – L2 - Nov/Dec 2016]
SAX is an API that can be used to parse XML documents.
A parser is a program that reads data a character at a time and returns manageable
pieces of data.
SAX provides a framework for defining event listeners, or handlers. These handlers are
written by developers interested in parsing documents with a known structure.
The handlers are registered with the SAX framework in order to receive events. Events
can include start of document, start of element, end of element, and so on. The
handlers contain a number of methods that will be called in response to these events.
Disadvantages
SAX parsing is ―single pass,‖ so can‗t back up to an earlier part of the document any
more than you can back up from a serial data stream. No random access at all.
Handling Parent/child relationships can be more challenging as well.
The current SAX implementations are read-only parsers.
They do not provide the ability to manipulate a document or its structure.
There is no way to validate a SAX parser or to determine whether it works correctly.
Advantages:
lightweight
simple
Easy to use.
SAX Versions
The first version, SAX 1.0, was released in May 1998. It provided the basic functionality
needed to read elements, attributes, text, and to manage errors.
The current version, SAX 2.0, was released two years later in May 2000. Many of the
SAX 2.0 interfaces are departures from SAX 1.0. Older interfaces are included, but
deprecated, for backward compatibility.
SAX Basics
<?xml version=‖1.0‖ encoding=‖UTF-8‖?>
<fiction>
<book author=‖Herman Melville‖>Moby Dick</book>
</fiction>
Parse this document using SAX, you would build a content handler by creating a Java
class that implements the Content Handler interface in the org.xml.sax package.
SAX Packages
The SAX 2.0 API is comprised of two standard packages and one extension package.
The two standard packages are,
org.xml.sax - It contains the basic classes, interfaces, and exceptions needed for
parsing documents.
org.xml.helpers - It contains additional classes that can simplify some of coding and
make it more portable.
The one extension package is,
org.xml.sax.ext- It is an extension that is not shipped with all implementations. It
contains two handler interfaces for capturing declaration and lexical events.
5 Explain how XSLT transforms the document from one word type to other.[ CO1
– L2 – Nov/Dec 2016]
XSL
XSL is a language that allows one to describe a browser how to process an XML file.
XSL can convert an XML file into another XML with different format.
XSL can convert an XML file into a non-XML file.
XSL consists of three languages:
XSLT (XSL Transformations) is a language used to transform XML documents into
other kinds of documents (most commonly HTML, so they can be displayed)XPath is a
language to select parts of an XML document to transform with XSLT
XSL-FO (XSL Formatting Objects) is a replacement for CSS
There are no current implementations of XSL-FO.
A style sheet stores formatting options for a document, usually separately from
document o E.g. an HTML style sheet may specify font colors and sizes for headings,
etc.
The XML Style sheet Language (XSL) was originally designed for generating HTML
from XML
XSLT is a general-purpose transformation language
Can translate XML to XML, and XML to HTML
XSLT templates
<xsl:template match=―/bank-2/customer‖>
<xsl:value-of select=―customer_name‖/>
</xsl:template>
<xsl:template match=―*‖/>
The match attribute of xsl:template specifies a pattern in XPath Elements in the XML
document matching the pattern are processed by the actions within the xsl:template
element xsl:value-of selects (outputs) specified values (here, customer_name) For
elements that do not match any template
Attributes and text contents are output as is Templates are recursively applied on sub
elements
The <xsl:template match=―*‖/> template matches all elements that do not match any
other template Used to ensure that their contents do not get output.
If an element matches several templates, only one is used based on a complex priority
scheme/user-defined priorities
6.Write XSLT code to display employee details in a table form which is stored is
XML. [ CO1 – L2]
Program1- empdetail.xsl
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html" indent="yes"/>
<xsl:template match="Employee-Detail">
<html>
<head>
<title>XSLT Style Sheet</title>
</head>
<body>
<h1>
<p align="center">Employee Details</p>
</h1>
<table border="2" width="50%" align="center">
<tr>bgcolor="LIGHTBLUE">
<th>Emp_Id</th>
<th>Emp_Name</th>
<th>Emp_E-mail</th>
</tr>
<xsl:for-each select="Employee"><tr>
<td>
<i>
<xsl:value-of select="Emp_Id"/>
</i>
</td><td>
<xsl:value-of select="Emp_Name"/>
</td>
<td><xsl:value-of select="Emp_E-mail"/></td>
</tr></xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Program 2 - employee.xml
<?xml version = "1.0" ?>
<?xml-stylesheet href="empdetail.xsl" type="text/xsl"?>
<Employee-Detail>
<Employee>
<Emp_Id> 11032 </Emp_Id>
<Emp_Name> Geetha </Emp_Name>
<Emp_E-mail>[email protected] </Emp_E-mail>
</Employee>
<Employee>
<Emp_Id> 11022 </Emp_Id>
<Emp_Name> sumalatha</Emp_Name>
<Emp_E-mail> [email protected] </Emp_E-mail>
</Employee>
<Employee>
<Emp_Id> 11011 </Emp_Id>
<Emp_Name> Lakshmanan </Emp_Name>
<Emp_E-mail> [email protected] </Emp_E-mail>
</Employee>
</Employee-Deta>
The <fo:flow> element contains a collection of text blocks. The <fo:flow> element is
similar to a collection of paragraphs. A body of text is defined using the <fo:block>
element.
The <fo:block> element is a child element of <fo:flow>
<!-- page sequences and content --><fo:page-sequence master-name=‖simple‖>
<fo:flow flow-name=‖xsl-region-body‖>
<!-- this defines a level 1 heading with orange background --><fo:block font-size=‖18pt‖
font-family=‖sans-serif‖ line-height=‖24pt‖ space-after.optimum=‖15pt‖ background-
color=‖orange‖ color=‖white‖ text-align=‖center‖ padding-top=‖3pt‖>
Ez Books Online </fo:block>
<!-- Paragraph that contains info about the company --><fo:block font-size=‖12pt‖
font-family=‖sans-serif‖ line-height=‖15pt‖ space-after.optimum=‖14pt‖ text-
align=‖justify‖>
</fo:block>
</fo:flow></fo:page-sequence>
Generating a PDF Document
Follow these steps to generate a PDF document from simple.fo:
Open an MS-DOS window.
Move to the directory <install_dir>\ch9_xsl\xsl_fo\.
Set up the Java classpath by typing setpaths.
Execute Apache-FOP by typing fop simple.fo simple.pdf.
The Apache-FOP formatter now reads the input file simple.fo and generates the output
file simple.pdf.
View the simple.pdf file in Adobe Acrobat Reader.
Page Headers and Footers
The <fo:static-content> element defines content that should appear on every page.The
<fo:static-content> element is commonly used to set up page headers and footers. The
<fo:static-content> element is a component of <fo:page-sequence>. The header is
defined using the following code fragment: <fo:static-content flow-name=‖xsl-region-
before‖> <fo:block text-align=‖end‖ font-size=‖10pt‖ font-family=‖serif‖ line-
height=‖14pt‖ >
Ez Books Catalog - page <fo:page-number/></fo:block>
</fo:static-content>
The footer is defined using the following code fragment:
<!-- footer -->
<fo:static-content flow-name=‖xsl-region-after‖>
<fo:block text-align=‖center‖ font-size=‖10pt‖ font-family=‖serif‖ line-height=‖14pt‖ >
Visit our website http://www.ezbooks.web </fo:block>
</fo:static-content>
Graphics
XSL-FO also allows for the insertion of external graphic images. The graphic formats
supported are dependent on the XSL-FO formatting engine. The Apache-FOP
formatting engine supports the
popular graphics formats: GIF, JPEG, and BMP.
The following code fragment inserts the image smiley.jpg:
<fo:block text-align=‖center‖>
<fo:external-graphic src=‖smiley.jpg‖ width=‖200px‖ height=‖200px‖/>
</fo:block>
Unit – III
Service Oriented Architecture
Part – A
Inherent reuse
Streamlined architectures and solutions
Leveraging the legacy investment
Establishing standardized XML data representation.
Focused investment on communications infrastructure
"Best-of-breed" alternatives
Organizational agility(Flexibility)
7. What are the requirements is needed to fill QoS gaps between contemporary
and primitive SOA?.[ CO3 - L1]
In a secure manner
Reliably
With appropriate performance
Protecting business integrity
Executing exception logic in case of failure
11.List out some of the characteristics of the reusable services in SOA? [ CO3 -
L1]
Reusable services have the following characteristics:
Define by an unbelievable functional context
Logic is highly generic
Has a generic and extensible contract
Can be accessed concurrently
17.List out the primary characteristics of the two tier client server architecture?.[
CO3 - L1]
Application logic
Application processingTechnology
Security and Administration
28. What’s the difference between services and components? .[ CO3 - L1]
Services are logical grouping of components to achieve business functionality.
Components are implementation approaches to make a service.
PART-B
Scalability
Behavioral predictability
Reliability
G. Contemporary SOA promotes discovery:
Universal description discovers and integration(UDDI) provided for service
registries.Some SOA systems used UDDI service registry or directory to manage
service descriptions.
Services are supplemented with communication meta data by which they can be
effectively discovered and interpreted.
Store Meta data in a service registry or profile documents
H. Contemporary SOA promotes federation:
Establishing and standardizing the ability to encapsulate legacy and non-legacy
application logic and by exposing it via an open, common standard communications
framework. Communication channels are all uniform and standardized. Services enable
standardized federation of disparate legacy systems.
I. Contemporary SOA promotes architectural composability:
Supports the automation of flexible, adaptable business process by composing loosely
coupled services. Flexible service contracts to allow different types of data exchange
requirements for similar functions
Services are effective composition participants, regardless of the size and complexity of
the composition. Ensures services are able to participate in multiple compositions to
solve multiple larger problems-related to reusability principle
Advantages
• Composite applications faster than writing a program from scratch. Building new
services and application becomes quicker and cheaper
J. Contemporary SOA fosters inherent reusability
Service-oriented design principles encourage reuse of software
Services can be composed into larger services which in turn can be reused
Services contain and express logic and can be positioned as reusable enterprise
resources
Reusable services have the following characteristics:
Defined by an agnostic functional context
Logic is highly generic
Has a generic and extensible contract
Can be accessed concurrently
K. Contemporary SOA emphasizes extensibility:
When encapsulating functionality through a service description, you are encouraged to
think beyond a point-to-point solution. Extensibility can be achieved less significantly
due to loosely coupled relationship fostered among all services.
The software on the client implements the application logic and the
interactions with the system user.
Operation of Two-tier client-server architecture:
The client accepts user requests and performs the bulk of application logic
that produces database requests and transmits them to the server.
The server accepts the requests, performs the data access logic, and
transmits the results to the client.
The client accepts the results and presents them to the end user.
Further processing is made easier by reducing the need for runtime caching of state
information
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.
The bottom line: Building services to be inherently reusable results in a moderately
increased development effort and requires the use of design standards. Subsequently
leveraging reuse within services lowers the cost and effort of building service-oriented
solutions.
Organizational agility
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.
The bottom line: The cost and effort to respond and adapt to business or
technology-related change isreduced.
Separation of concerns:
―Separation of concerns‖ is an established software engineering theory based on the
idea of breaking down a large problem into a series of individual concerns.
Allows the logic required to solve the problem to be decomposed into a collection of
smaller, related pieces. Each piece of logic addresses a specific concern.
Implemented in different ways with different development platforms
compos ability by allowing a given SOA to only implement extensions is actual requires.
Vendor diversity This is really more of a benefit of SOA than an actual characteristic.
Regardless, it is primarily realized through the use of the open standards provided by
the Webservices platform. Intrinsic interoperability.
Promotes federation Federation is a state achieved by extending SOA into the realm of
service-oriented integration. A number of key WS- extensions provide features sets that
supports the attainment of federation. Most notable among these are the specifications
that implement the concepts of orchestration and choreography.Inherent
reusabilityReusability is one of the primary principles of service orientation and one that
can be applied across service oriented solution environments.
SOA promotes the creation of inherently reusable service logic within individual services
and across service design compositions benefit attainable through quality service
design extensibility Given that Web services are composable and based on open
standards,extensibility is a natural benefit of this platform. Several WS extensions
introduce architectural mechanisms that build extensibility into a solution. However, for
the most part, this is a characteristic that must be intentionally designed into services
individually and into SOA as a whole.
organizational agility
layers of abstraction
The service layer is between the application layer and the business process layer
6. AGNOSTIC SERVICES:
A key aspect of delivering reusable services is that they introduce service layers that
are not limited to a single process or solution environment.
Entity-centric business services are designed to provide a set of features that provide
data management related only to their corresponding entities. They are therefore
business process-agnostic. The same entity-centric business services can (and should)
be reused by different process or task-centric business services.
Application services ideally are built according to the utility service model. This makes
them highly generic, reusable, and very much solution-agnostic. Different service-
oriented solutions can (and should) reuse the same application services.
In this scenario, a parent process service composes available hybrid and application
services to automate a business process. This is a common configuration when adding
an orchestration layer over the top of an older distributed computing architecture that
uses Web services.
(vi) Scenario #6: Process services, task-centric business services, and utility application
services
Even though task-centric services also contain business process logic, a parent process
service can still be positioned to compose both task-centric and utility application
services. Though only partial abstraction is achieved via task-centric services, when
combined with the centralized business process logic represented by the process
services, business logic as a whole is still abstracted.
(vii) Scenario #7: Process services, task-centric business services, entity-centric
business services, and utility application services This variation also introduces entity-
centric business services, which can result in a configuration that actually consists of
four service layers. Sub-processes can be composed by strategically positioned task-
centric services, whereas the parent process is managed by the process service, which
composes both task-centric and entity-centric services.
(viii) Scenario #8: Process services, entity-centric business services, and utility
application services
The process service contains all business process-specific logic and executes this logic
through the involvement of available entity-centric business services, which, in turn,
compose utility application logic to carry out the required tasks.
Unit – IV
Web Services
Part – A
1.What is a web service? .[ CO2 - L1 - May/June 2015]
Definition 1:
A web service is used to implement architecture according to service-oriented
architecture (SOA)concepts. The basic unit of communication is a message.
Definition 2:
Web services are application components.
Web services communicate using open protocols.
Web services are self-contained and self-describing.
Web services can be discovered using UDDI .
Web services can be used by other applications XML is the basis for Web services.
2.What are the parts comprised in the web services framework? .[ CO2 - L1 ]
One or more architectures
Technologies
Concepts
Models
Sub-frameworks.
4.Define service and List the fundamental roles of service? .[ CO2 - L1]
A service is a unit of software capable of altering its role, depending on its processing
responsibility in a given scenario.
• Service provider
• Service requestor
• Intermediaries
• Initial sender and ultimate receiver
• Service composition
7.What are referred to as intermediaries and list its types? .[ CO2 - L1]
Web services and service agent‘s route and process a message after it is initially sent
and before it arrives at its ultimate destination are referred to as intermediaries or
intermediary services
Passive intermediary
Active intermediary
<soap:Body>
<soap:fault>
</soap:fault>
</soap:Body>
</soap:Envelope>
21.What are the basic sets of common service models? .[ CO2 - L1]
Utility service model
Controller service model
23.List out some of the usage of business service model? .[ CO2 - L1]
Business services are used within SOAs as follows:
As fundamental building blocks for the representation of business logic
To represent a corporate entity or information set
To represent business process logic
As service composition members
Utility service is generic and non-application specific web service or service agent that is
designed for potential reuse.
Example:
Utility services are used within SOAs as follows:
As services that enable the characteristics of reuse within SOA
As solution-agnostic intermediary services
As services that promote the intrinsic interoperability characteristics of SOA
As the services with the highest degree of autonomy.
26. What are service descriptions and list its categories? .[ CO2 - L1]
A WSDL endpoint description explains how the service description document itself is
organized. It is also known as WSDL service definition or just WSDL definition.
Categories:
Service descriptions is divided into two categories
Abstract description
Concrete description
27.What does abstract description establish and list its parts? .[ CO2 - L1]
An abstract description establishes the interface characteristics of the web service
without any reference to the technology used to host or enable a web service to transmit
messages.
Parts:
The three mail parts that comprise an abstract description are
Port type
Operation
Message
29. Define concrete description and What are the parts that comprise concrete
description?.[ CO2 - L1]
The concrete description portion of the WSDL file defines the connection needed from
the abstract web service interface to a physical transport protocol.
The three main parts that comprise concrete description are
Binding
Port
Service
Refers to an executable business process that may interact with both internal and
external Web services. Orchestration describes how Web services can interact at the
message level, including the business logic and execution order of the interactions.
These interactions may span applications and/or organizations, and result in a long-
lived, transactional process. With orchestration, the process is always controlled from
the perspective of one of the business parties.
40. What are all the steps to follow to create the appropriate tModel? .[ CO2 - L1]
Set the name field of the tModel to the target Namespace attribute of the definitions
element in the interface document. This field is used to locate the appropriate tModel.
The description field of the tModel corresponds to the documentation element of the
interface document. This field can have a maximum of 256 characters. Set the
overviewURL field of the tModel to the URL and binding specification in the interface
document. Set the category Bag field of the tModel so that its keyed reference is
uddiorg: types and its key Value is wsdlSpec. This defines the UDDI entry as a WSDL
service interface definition
PART-B
A temporary classification based on the roles it assumes during the runtime processing
of a message .A permanent classification based on the application logic it provides and
the roles it assumes within a solution environment
Design classifications of Web Services
Service roles (temporary classifications)
Service models (permanent classifications)
Service roles
A Web service is capable of assuming different roles, depending on the context within
which it is used. For example, a service can act as the initiator, re layer, or the recipient
of a message. A service is therefore not
labeled exclusively as a client or server, but instead as a unit of software capable of
altering its role, depending on its processing responsibility in a given scenario.
Provided here are descriptions of the fundamental service roles.
• Service Provider
• Service Requestor
• Intermediaries
• Initial Sender and Ultimate Receiver
• Service Composition
Service provider:
The service provider role is assumed by a Web service under the following conditions:
• The Web service is invoked via an external source, such as a service requestor.
• As the recipient of a request message, the Web service is classified as a service
provider.
• The Web service provides a published service description offering information
about its features and behavior.
As the recipient of a request message, the Web service is classified as a service
provider.
The term "service provider" also is used to identify the organization (or individual)
responsible for actually providing te Web service.To help distinguish the service role
from the service's actual provider, the following, more qualified terms are sometimes
used:
• Service provider entity (the organization or individual providing the Web service)
• Service provider agent (the Web service itself, acting as an agent on behalf of its
owner)
• Any unit of processing logic capable of issuing a request message that can be
understood by the service provider is classified as a service requestor.
The sender of the request message is classified as a service requestor
• The Web service searches for and assesses the most suitable service provider
by studying available service descriptions.
Intermediaries:
Though less flexible and less scalable, point-to-point communication was a great deal
easier to design. Web services communication is based on the use of messaging paths,
which can best be described as point-to-* paths.
This is because once a service provider submits a message; it can be processed by
multiple intermediate routing and processing agents before it arrives at its ultimate
destination.
Intermediary Services:
Web services and service agents that route and process a message after it is initially
sent and before it arrives at its ultimate destination are referred to as intermediaries or
intermediary services. Because an intermediary receives and submits messages, it
always transitions through service provider and service
The intermediary service transitions through service provider and service requestor
roles while processing a message. There are two types of intermediaries.
Passive Intermediaries
Active Intermediaries
Passive Intermediary, is typically responsible for routing messages to a subsequent
location It may use information in the SOAP message header to determine the routing
path, or it may employ native routing logic to achieve some level of load balancing. The
intermediary passive is that it does not modify the message.
A passive intermediary service processing a message without altering its contents.
Active intermediaries also route messages to a forwarding destination. Prior to
transmitting a message, however, these services actively process and alter the
message contents
Typically, active intermediaries will look for particular SOAP header blocks and perform
some action in response to the information they find there. They almost always alter
data in header blocks and may insert or even delete header blocks entire
Service compositions:
It does not apply to a single Web service, but to a composite relationship between a
collections of services. Any service can enlist one or more additional services to
complete a given task. Any of the enlisted services can call other services to complete a
given sub-task.
Therefore, each service that participates in a composition assumes an individual role of
service composition member
service composition
Web services need to be designed with service composition in mind to be effective
composition members. Service-orientation principles place an emphasis on compos
ability, allowing some Web services to be designed in such a manner that they can be
pulled into future service compositions without a foreknowledge of how they will be
utilized.
Abstract description:
An abstract description establishes the interface characteristics of the Web service
without any reference to the technology used to host or enable a Web service to
transmit messages.By separating this information, the integrity of the service description
can be preserved regardless of what changes might occur to the underlying technology
platform.port Type, operation, and message:The parent port Type section of an abstract
description provides a high-level view of the service interface by sorting the messages a
service can process into groups of functions known as operations.
Note: The term "port Type" is being renamed to "interface" in version 2.0 of the WSDL
specification.Binding represents one possible transport technology the service can use
to communicate. SOAP is the most common form of binding, but others also are
supported. A binding can apply to an entire interface or just a specific operation. The
port, which represents the physical address at which a service can be accessed with a
specific protocol. This piece of physical implementation data exists separately to allow
location information to be maintained independently from other aspects of the concrete
description. WSDL definitions frequently rely on XSD schemas to formalize the structure
of incoming and outgoing messages. Another common supplemental service description
document is a policy.
Policies can provide rules, preferences, and processing details above and beyond what
is expressed through the WSDL and XSD schema documents.
So now we have up to three separate documents that each describes an aspect of a
service:
• WSDL definition
• XSD schema
• policy
Service description documents can be collectively viewed as establishing a service
contract a set of conditions that must be met and accepted by a potential service
requestor to enable successful communication. A service contract can refer to additional
documents or agreements not expressed by service descriptions. For example, a
Service Level Agreement (SLA) agreed upon by the respective owners of a service
provider and its requestor can be considered part of an overall service contractMost of
the time service semantics are assessed by humans, either verbally by discussing the
qualities of a service with its owner, or by reading supplementary documentation
published alongside service descriptions.The ultimate goal is to provide sufficient
For example:
a binding template may simply point to the address of a Web site. However, if a Web
service isbeing represented, then the binding template references a tModel. The tModel
section of a UDDI record provides pointers to actual service descriptions .
3. Write in detail about XML Schemas and WSDL with examples. .[ CO2 – L2 -
Nov/Dec 2012]
The WSDL Document Structure
A WSDL document describes a web service using the major elements:
Element Defines
<types> The data types used by the web service
<message> The message used by the web service
<portType> The operations performed by the web service
<binding> The communication protocols used by the web service
<service> The Service location used by the web service
Abstract Definition
The abstract definition contains a series of parts that include
Types
Message
Port type (or interface),
Concrete Definition
The concrete definition is comprised of
Binding parts
Service parts
Description
xmlns –specifies default name space
xmlns:tns –means this name space i.e. namespace used for particular WSDL.
xmlns:xsd –specifies all the elements within WSDL belong to the XML Scheme
Definition Language
xmlns:soap –establish the soap: qualifier used by elements defined in bindings.
name –name of the service
targetNamespace–it lets the WSDL document make references to itself as an
XML schemanamespace.
The types construct is where XSD schema content is placed. It consist of the following
elements Actual XSD schema markup (an entire schema construct containing
type definitions)
Import elements that reference external schema definitions o Contain both embedded
and imported XSD types.
Examples
A types construct containing an XSD schema construct in which a complex Type is
defined <types>
<schemaxmlns=http://www.w3.org/2001/XMLSchema
targetNamespace=‖http:www.xmltc.com/railco/transform/schema/‖>
<complexType name=‖ReturnCodeType‖>
<sequence>
<element name=‖code‖type=‖xsd:integer‖/>
<element name=‖Message‖type=‖xsd:string‖/>
</sequence></complexType></schema></types>
The WSDL types construct populated by XSD schema types used by the message
construct to represent the SOAP message body.
Examples
Two message constructs likely representing the input (request) and output (response)
messages for an operation are given below
<message name=‖getEmployeeWeeklyHoursRequestMessage‖><part
name=‖RequestParameter‖ element=‖act:EmployeeHoursRequest Type‖/>
</message>
<message name-
―getEmployeeWeeklyHoursResponseMessage‖><partname=‖ResponseParamat
er‖ element=‖act:EmployeeHoursResponseType‖/>
</message>
The part element is simply assigned a native XSD schema data type using the type
attributes.
<message name=‖getID‖><part type=‖xsd:integer‖/>
</message>
The portType, interface, and operation elements
The WSDL portType element, also known as interface, defines a group of service
operations which is defined using the operation element.
Example
The portType construct hosting two operation constructs.
<portType name=‖EmployeeInterface‖><operation name=‖GetWeeklyHoursLimit‖>
</operation>
<operation name=‖UpdateHistory‖>
</operation>
</portType>
The input and output elements (when used with operation)
The input and output elements, child element of operation, represent the request and
response messages the operation is capable of processing.
Example
Each operation has one input and one output message. The respective input and output
elements are assigned messages defined in the message constructs via their message
attributes.
<operation name=‖GetWeeklyHoursLimit‖>\
<input message=‖tns:getWeeklyHoursRequestMessage‖/><output
message=‖tns:getWeeklyHoursResponseMessage‖/>
</operation>
<operation name=‖UpdateHistory‖>
<input message=‖tns:updateHistoryRequestMessage‖/><output
message=‖tns:updateHistoryResponseMessage‖/>
</operation>
One-way MEP
Placing a single input element within the operation construct expresses the one-way
MEP.
<operation name =‖Submit‖>
<input message=‖tns:receiveSubmitMessage‖/>
</operation>
The binding element
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 construct contains one or more operation elements.
<binding name=‖EmployeeBinding‖type=‖tns:EmployeeInterface‖><soap:binding
style=‖document‖ transport=‖http://schemas.xmlsoap.org/soap/http/‖>
<operation name=‖GetWeeklyHoursLimit‖><soap:operation soapAction=‖…‖/>
</operation>
<operation name=‖UpdateHistory‖><soap:operataion soapAction=‖…‖/>
</operation></binding>
The style attribute of the soap:binding element defines whether the SOAP messages
used to support an operation are to be formatted as
The service element simply provides a physical address at which the service can be
accessed. It hosts the port element that contains this location information.
The port element contains a child soap: address element with the physical address
information. Note :The port element is replaced with a end point element in version 2.0
of the WSDL specification.
Example
<service name=‖EmployeeService‖>
<port binding=‖tns:EmployeeBinding‖ name=‖EmployeePort‖>
<soap:address location=‖http://www.xmltc.com/tls/employee/‖/></port></service>
The attributes on the header blocks indicate how the header blocks are to be processed
by the SOAP nodes.
SOAP messages are allowed to pass through many intermediaries before reaching their
destination.Intermediary=some unspecified routing application The final destination
processes the body of the message
Headers are allowed to be processed independently of the body Processed by
intermediaries. Message styles
The SOAP offers two messaging styles:
RPC(Remote Procedure Call)-style
Creating tightly coupled, inter-object style interfaces for web services components It is
also known as section 5 encoding Attachments
SOAP attachments are used to send large quantities binary data with the SOAP
message which may not fit well into a XML SOAP element.
Faults
The SOAP fault element holds errors and status information for a SOAP message. It
appear as an immediate child of the body element.<fault code> and <fault string> are
required.
Anatomy of a SOAP message
<? Xml version=‖1.0‖?>
<soap:Envelope xmlns:soap=http://www.w3.org/2001/12/soap-envelope soap:encoding
style=http://www.w3.org/2001/12/soap-encoding><soap:header>
</soap:header>
<soap:body>
<soap:fault>
</soap:fault></soap:body></soap:envelope>
5. Explain in detail about Web Service building block UDDI.[ CO2 – L2 - Nov/Dec
2014]
Universal Description, Discovery, and Integration (UDDI) is a platform-independent,
open framework for describing services, discovering businesses, and integrating
business services using the Internet as well as public registries of Web Services
designed to store information about businesses and the services they offer.UDDI is also
a specification for building such registries as well as an application programming
interface (API) that exposes the functionality of the registries.UDDI Basics Public UDDI
registries are hosted by operator nodes, which are companies such as Microsoft and
IBM that have committed to running public UDDI nodes.The public registry system is
loosely modeled after the Domain Name Service (DNS) system, in that there are
multiple registries responsible for synchronizing their data with each other
The DNS system provides for unique domain names, UDDI relies on globally unique
identifiers (GUIDs), which are URNs that uniquely identify the resources in each
registry.There are three levels of information available in each UDDI registry, which
correspond roughly to the features of a phone book: White pages. These pages provide
listings of companies that can be queried by name, text description, contact information,
and known identifiers (like Dun and Bradstreet‘s DUNS numbers).Yellow pages. These
pages allow for the looking up of companies by the kind of services they offer,
organized into established business categories (industry codes, location, and products
and services). These categories are organized into taxonomies. Green pages.
These pages provide information about how to interact with companies‘ Web Services
by exposing service descriptions and binding information
Example
Request - response pattern.
i)Request-response
In a request-response message exchange the SOAP client sends a SOAP request
message to the service. The service responds with a SOAP response message.
ii)Fire-and-forgot
Fire-and-forgot is a simple asynchronous message exchange pattern is based on the
unidirectional transmission of messages from a source to one or more destinations.
Response to a transmitted message is not permitted.
The fire-and-forget MEP.
Types
Single-destination pattern- A source sends a message to one destination only
Multi-cast pattern A source sends message to a predefined set of destination
Broadcast pattern -Similar to the multi-cast pattern, except that the message is sent out
to a broader range of messaging models.
Complex MEPs
Complex MEPs is a message pattern in which primitive MEPs are assembled to create
different types of messaging models
Example
Publish-and-subscribe pattern:
Publish-and-subscribe pattern is a asynchronous MEP in which publishers sends
messages to all interested subscribers.
Step 1:
The subscriber sends a message to notify the publisher that it wants to receive
messages on a particular topic.
Step 2:
Upon the availability of the requested information, the publisher broadcast messages on
the particular topic to all of the topics subscribers.
WSDL specification
Request-response operation: upon receiving a message, the service must respond with
a standard message or a fault message. Solicit-response operation: upon submitting a
message to a service requestor, the service expects a standard response message or a
fault message. One-way operation: the service expects a single message and is not
obligated to respond.
Patterns supported by WSDL 2.0
The in-out pattern, comparable to the request-response MEP
The out-in pattern, which is the reverse of the previous pattern where the
service provider initiate the exchange by transmitting the request
The in-only pattern, which essentially supports the standard fire-and-forgot
MEP
The out-only pattern, which is the reverse of the in-only pattern. it is used
primarily in support of event notification
The robust in-only pattern, a variation of the in-only pattern that provides the
option of launching a fault response message as a result of a transmission or
processing error
The robust out-only pattern, which is similar to the in-out pattern with one
exception. This variation introduces a rule stating that the delivery of a
response message is optional and should therefore not be expected by the
service requestor that originated the communication. This pattern also
supports the generation of a fault message.
The in-optional-out pattern, which is similar to the in-out pattern with one
exception. This variation introduces a rule stating that the delivery of a
response message is optional and should therefore not be expected by the
service requestor that originated the communication. This pattern also
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 again
supported.
1.Business protocols
Defines how participants can interoperate to achieve the completion of a business task.
2.Process definition
Encapsulates and expresses the details of the workflow logic.
Process services and partner services:
3.Process services
A process service is the process itself represented as a service. It coordinates and
exposes functionality from the partner services.
Partner services :Partner services or partner links is the services allowed to interact with
the process service. The process service, after first being invoked by a partner service,
then invokes another partner service.
A single orchestration scope can be classified as a complex, and most likely, long-
running activity.
Roles
Roles establish what the service does and what the service can do within the context of
a particular business task.
Participants
Participants are the roles that bounded to WSDL definitions, and those related are
grouped.
Interaction
Interaction encapsulates the actual logic behind a message exchange.
Work units
Work units are the rules and constrains that must be adhered to for an interaction to
successfully completed
Designed choreography can be applied to different business tasks comprised of the
same fundamental actions.
Modularity
Choreography can be assembled from independent modules that can represent distinct
sub-task.
Compos ability
Choreography composes a set of non-specific services to accomplish a task.
Orchestrations and choreographies:
Although orchestrations and choreographies look very similar to each other there are
significant differences among them.
• An orchestration expresses organization specific business workflow
• An organization controls the logic behind an orchestration even if it involves
external businesses
• Choreography is not owned by a single entity, it acts as a community interchange
pattern used for collaborative purpose by services from different provider entities.
Unit – V
Building Soa-Based Applications
Part – A
2.What are the goals needed for performing a service-oriented analysis? .[ CO3 -
L1 - Nov/Dec 2011]
The overall goals of performing a service-oriented analysis are as follows:
Define a preliminary set of service operation candidates.
Group service operation candidates into logical contexts. These contexts represent
service candidates.
Define preliminary service boundaries so that they do not overlap with any existing or
planned services.
Identify encapsulated logic with reuse potential.
Ensure that the context of encapsulated logic is appropriate for its intended use.
Define any known preliminary composition models.
5.List out the types of logic suitable for orchestration layer.[ CO3 - L1]
Business rules
Conditional logic
Exception logic
Sequence logic
10. Give the overall goals for performing a service-oriented design.[ CO3 - L1]
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
PART-B
Goals
The overall goals of performing a service oriented analysis are as follows:
Define a preliminary set of service operation candidates. Group service operation
candidates into logical contexts. These contexts represent service candidates. Service
Operation CandidatesService Candidates (Logical context)
Define preliminary service boundaries so that they do not overlap with any existing or
planned services.
• Identify encapsulated logic with reuse potential.
• Ensure that the context of encapsulated logic is appropriate for its
intended use.
• Define any known preliminary composition models.
The service-oriented analysis process
The service-oriented analysis process is a sub-process of the overall SOA delivery
lifecycle.
The original scenarios that are identified in step 5 are revisited and the new application
service candidates are incorporated by expanding the service compositions.
Process services
(i)Design standards
It is important to note that a firm set of design standards is critical to achieving a
successful SOA. Because the design we are defining as part of this phase is concrete
and permanent, every service produced needs to be as consistent as possible.
Otherwise, many key SOA benefits, such as reusability, compos ability, and
especially agility, will be jeopardized. It is therefore assumed that prior to starting this
phase, design standards are already in place.
• Entity-centric business service design (a step-by-step process)
Entity-centric business services represent the one service layer that is the least
influenced by others. Its purpose is to accurately represent corresponding data entities
defined within an organization's business models
Process description
Step 1: Review existing services
Step 2: Define the message schema types
Step 3: Derive an abstract service interface
Step 4: Apply principles of service-orientation
Step 5: Standardize and refine the service interface
Step 6: Extend the service design
Step 7: Identify required processing
SERVICE DESIGN GUIDELINES
• Apply naming standards
• Apply a suitable level of interface granularity
• Design service operations to be inherently extensible
• Identify known and potential service requestors
• Consider using modular WSDL documents
• Use namespaces carefully
• Use the SOAP document and literal attribute values
<wsc:registrationservice>
</ wsc:registrationservice>
</ wsc:coordinationcontext></header><body>...</body></Envelope>
The identifier and expires elements
Identifier- The identifier elements is used to associate a unique ID value with the
current activity
Expires - The expires element sets an expiry date that establishes the extent of the
activity‘s possible lifespan.
The coordination type element
The specific protocols that establish the rules and constraints of the activity are
identified within the coordination type element.The coordination type element is used to
represent the WS-business activity and WS-atomic transaction coordination types
section.
1. WS-policy
2. WS-policy assertions
1.The policy element
The policy element establishes the root construct used to contain the various policy
assertions that comprise the policy.
2.Policy assertions
A policy assertion represents an individual preference, requirement, capability, or other
characteristics It is basic building block of a policy expression
An XML element with a well-known name and meaning.
Standard policy assertions
WS-policy assertions define four general policy assertions for any subject.
Policy assertions description
Wsp:textencoding Specifies a character encoding
Wsp:language Specifies a natural language
Wsp:specversion Specifies a version of a particular specification
Wsp:messagepredicate It can be tested against the message
• <signedinfo>
• <canonicalizationmethod/>
• <signaturemethod/>
• <reference>
• <transforms>
• <digestmethod>
• <digestValue>
• </reference>
• <reference/>
• </signedinfo>
• <signaturevalue/>
• <keyinfo/>
• <object/>
• </signature>
************************