Web Services Part 1


Published on

Published in: Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Web Services Part 1

  2. 2. INTRODUCTION <ul><li>The root of WEB-SERVICES can be traced out when the concept of component architecture began taking shape. Beauty of Component architecture is develop on one platform and run in different platform </li></ul><ul><li>Distributed Computing </li></ul><ul><ul><li>RMI </li></ul></ul><ul><ul><li>CORBA </li></ul></ul><ul><ul><li>COM </li></ul></ul><ul><li>WEB-BASED Application </li></ul><ul><ul><li>JSP </li></ul></ul><ul><ul><li>SERVLET </li></ul></ul>
  3. 3. <ul><li>WEB-SERVICES as named suggest service available on the web. This network may be LAN,WAN,MAN or Internet </li></ul><ul><li>IBM says : internet based modular application that perform a specific business task and confirm to a specific technical format </li></ul><ul><ul><li>A practical example of a web-services is one company calling services of other company to directly pass on a purchase order through internet connection </li></ul></ul>
  4. 4. Characteristics of WEB-SERVICES <ul><li>A web-services can be accessed over the WEB </li></ul><ul><li>The service interface helps the web-services to be called any other programme or services. The service interface is an XML document since XML has emerged as the global data exchange technology </li></ul><ul><li>A web-services can be registered in a service registry to be accessed by other programme </li></ul><ul><li>Web-services use the standers Web protocol to communicate </li></ul>
  5. 5. Life Cycle of Web-services <ul><li>A web-service needs to be created </li></ul><ul><li>The service interface and invocation method should be defined </li></ul><ul><li>The web-service should be published on the internet or intranet to facilitate the web user in using the service </li></ul><ul><li>The web user should be able to find the web-service </li></ul><ul><li>The web-service should be invoked </li></ul><ul><li>The web-service should be unpublished when no longer in use. </li></ul>
  6. 6. Requirement for creating a web-services <ul><li>Representing data in a standard format : XML is emerged as standers way to represent data. </li></ul><ul><li>A common extensible message format : A simple Object access protocol ( SOAP ) is a light weight protocol for exchange information. </li></ul><ul><li>A common extensible, service descripting language : A web services description language ( WSDL ) is used to document the same for Web-services. </li></ul><ul><li>A list of service providers and the services offered by them : Universal Description Discovery and integration ( UDDI ) is a industry initiated project, which satisfying the requirement of maintaining registries. </li></ul>
  7. 7. Working of the Web-services <ul><li>A web-service consist a file which contain either a class providing a functionality of web-services or reference of the external class. </li></ul><ul><li>This information is an XML file known as WSDL file. </li></ul><ul><li>Depending on the requirments, the client invokes the web method of the service and send and receive the parameter from the method. The server then returns the appropriate result to the client </li></ul>
  8. 8. <ul><li>Web-services which run over the HTTP can be accessed by following ways: </li></ul><ul><li>HTTP GET: </li></ul><ul><li>HTTP POST : </li></ul><ul><li>SOAP : Soap messaging is the proper way to call a web-services. The Get and Post method is are useful if a web-services is to be called quickly and no soap client is available. These operation will support simple inputs and outputs. SOAP is used whenever there exist a need to pass complex objects and data </li></ul>
  9. 9. <ul><li>Advantages of Web-services </li></ul><ul><ul><li>Cross buisness integration </li></ul></ul><ul><ul><li>Improved efficiency </li></ul></ul><ul><ul><li>Closer customer relationships </li></ul></ul><ul><ul><li>Facilitates just-in-time relationships </li></ul></ul><ul><ul><li>Reduce complexity </li></ul></ul><ul><li>Disadvantages: </li></ul><ul><ul><li>Network Security risk </li></ul></ul><ul><ul><li>XML support is necessary </li></ul></ul><ul><ul><li>Cost of deploying is high </li></ul></ul>
  10. 10. Introduction to XML
  11. 11. What is XML? <ul><li>XML stands for E X tensible M arkup L anguage </li></ul><ul><li>XML is a markup language much like HTML. </li></ul><ul><li>XML was designed to describe data . </li></ul><ul><li>XML tags are not predefined in XML. You must define your own tags . </li></ul><ul><li>XML is self describing . </li></ul><ul><li>XML uses a DTD ( Document Type Definition ) to formally describe the data. </li></ul>
  12. 12. Difference between XML and HTML <ul><li>XML is not a replacement for HTML. XML and HTML were designed with different goals : </li></ul><ul><li>XML was designed to describe data and to focus on what data is . HTML was designed to display data and to focus on how data looks . </li></ul><ul><li>HTML is about displaying information, XML is about describing information. </li></ul>
  13. 13. <ul><li>XML is eXtensible : The tags used to markup HTML documents and the structure of HTML documents are predefined . The author of HTML documents can only use tags that are defined in the HTML standard . </li></ul><ul><li>XML allows the author to define his own tags and his own document structure. </li></ul><ul><li>It is important to understand that XML is not a replacement for HTML . In the future development of the Web it is most likely that XML will be used to structure and describe the Web data, while HTML will be used to format and display the same data. </li></ul>
  14. 14. How can XML be used? <ul><li>XML can keep data separated from your HTML </li></ul><ul><li>XML can be used to store data inside HTML documents </li></ul><ul><li>XML can be used as a format to exchange information </li></ul><ul><li>XML can be used to store data in files or in databases </li></ul>
  15. 15. XML Syntax <ul><li><?xml version=&quot;1.0&quot;?> </li></ul><ul><li><note> </li></ul><ul><li><to>Tove</to> </li></ul><ul><li><from>Jani</from> </li></ul><ul><li><heading>Reminder</heading> </li></ul><ul><li><body>Don't forget me this weekend!</body> </li></ul><ul><li></note> </li></ul><ul><li>The first line in the document: The XML declaration should always be included. It defines the XML version of the document. </li></ul><ul><li>The next line defines the first element of the document (the root element </li></ul><ul><li>The next lines defines 4 child elements of the root (to, from, heading, and body): </li></ul>
  16. 16. <ul><li>All XML elements must have a closing tag </li></ul><ul><li>XML tags are case sensitive </li></ul><ul><li>All XML elements must be properly nested </li></ul><ul><li>All XML documents must have a root tag </li></ul><ul><li>Attribute values must always be quoted </li></ul><ul><li><?xml version=&quot;1.0&quot;?> </li></ul><ul><li><note date=&quot;12/11/99&quot;> </li></ul><ul><ul><li>…………… </li></ul></ul><ul><li></note> </li></ul>
  17. 17. XML Attributes <ul><li>XML attributes are normally used to describe XML elements, or to provide additional information about elements </li></ul><ul><li><?xml version=&quot;1.0&quot;?> </li></ul><ul><li><note date=&quot;12/11/99&quot;> </li></ul><ul><li><to>Tove</to> </li></ul><ul><li><from>Jani</from> </li></ul><ul><li><heading>Reminder</heading> </li></ul><ul><li><body>Don't forget me this weekend!</body> </li></ul><ul><li></note> </li></ul>
  18. 18. <ul><li>Using an Attribute for sex: </li></ul><ul><li><person sex=&quot;female&quot;> </li></ul><ul><li><firstname>Anna</firstname> </li></ul><ul><li><lastname>Smith</lastname> </li></ul><ul><li></person> </li></ul><ul><li>Using an Element for sex: </li></ul><ul><li><person> </li></ul><ul><li><sex>female</sex> </li></ul><ul><li><firstname>Anna</firstname> </li></ul><ul><li><lastname>Smith</lastname> </li></ul><ul><li></person> </li></ul>
  19. 19. <ul><li>There are no fixed rules about when to use attributes to describe data, and when to use elements. Attributes are handy in HTML, but in XML you should try to avoid them , as long as the same information can be expressed using elements. </li></ul><ul><li>Problems with attributes : </li></ul><ul><ul><li>attributes can not contain multiple values (elements can) </li></ul></ul><ul><ul><li>attributes are not expandable (for future changes) </li></ul></ul><ul><ul><li>attributes can not describe structures (like child elements can) </li></ul></ul><ul><ul><li>attributes are more difficult to manipulate by program code </li></ul></ul><ul><ul><li>attribute values are not easy to test against a DTD </li></ul></ul>
  20. 20. XML Validation <ul><li>A &quot;Well Formed&quot; XML document is a document that conforms to the XML syntax rules that we described earlier. </li></ul><ul><li>A &quot;Valid&quot; XML document is a &quot;Well Formed&quot; XML document which conforms to the rules of a Document Type Definition (DTD). </li></ul><ul><li>The following is the same document as above but with an added reference to a DTD: </li></ul><ul><li><?xml version=&quot;1.0&quot;?> </li></ul><ul><li><!DOCTYPE note SYSTEM &quot;InternalNote.dtd&quot;> </li></ul><ul><li><note> </li></ul><ul><li><to>Tove</to> </li></ul><ul><li>…………… </li></ul><ul><li></note> </li></ul>
  21. 21. XML DTD - An Introduction to XML Document Type Definitions <ul><li>The purpose of a DTD is to define the legal building blocks of an XML document. It defines the document structure with a list of legal elements. </li></ul><ul><ul><li>Internal DTD </li></ul></ul><ul><ul><li>External DTD </li></ul></ul><ul><li>Use of DTD : XML provides an application independent way of sharing data. With a DTD, independent groups of people can agree to use a common DTD for interchanging data. Your application can use a standard DTD to verify that data that you receive from the outside world is valid. You can also use a DTD to verify your own data. </li></ul>
  22. 22. Internal DTD <ul><li><?xml version=&quot;1.0&quot;?> </li></ul><ul><li><!DOCTYPE note [ </li></ul><ul><li><!ELEMENT note (to,from,heading,body)> </li></ul><ul><li><!ELEMENT to (#PCDATA)> </li></ul><ul><li><!ELEMENT from (#PCDATA)> </li></ul><ul><li><!ELEMENT heading (#PCDATA)> </li></ul><ul><li><!ELEMENT body (#PCDATA)> </li></ul><ul><li>]> </li></ul><ul><li><note> </li></ul><ul><li><to>Tove</to> </li></ul><ul><li><from>Jani</from> </li></ul><ul><li><heading>Reminder</heading> </li></ul><ul><li><body>Don't forget me this weekend!</body> </note> </li></ul>
  23. 23. External DTD <ul><li><?xml version=&quot;1.0&quot;?> </li></ul><ul><li><!DOCTYPE note SYSTEM &quot;note.dtd&quot;> </li></ul><ul><li><note> </li></ul><ul><li>…………… .. </li></ul><ul><li></note> </li></ul><ul><li><?xml version=&quot;1.0&quot;?> </li></ul><ul><li><!ELEMENT note (to,from,heading,body)> </li></ul><ul><li><!ELEMENT to (#PCDATA)> </li></ul><ul><li><!ELEMENT from (#PCDATA)> </li></ul><ul><li><!ELEMENT heading (#PCDATA)> </li></ul><ul><li><!ELEMENT body (#PCDATA)> </li></ul>
  24. 24. DTD - XML building blocks <ul><li>XML documents (and HTML documents) are made up by the following building blocks: </li></ul><ul><li>Elements : Elements are the main building blocks of both XML and HTML documents. </li></ul><ul><li>Tags : Tags are used to markup elements. A starting tag like <element_name> mark up the beginning of an element, and an ending tag like </element_name> mark up the end of  an element </li></ul><ul><li>Attributes : Attributes provide extra information about elements. </li></ul><ul><li>. </li></ul>
  25. 25. <ul><li>PCDATA : PCDATA means parsed character data.Think of character data as the text found between the start tag and the end tag of an XML element.PCDATA is text that will be parsed by a parser. Tags inside the text will be treated as markup and entities will be expanded.  </li></ul><ul><li>CDATA : CDATA also means character data.CDATA is text that will NOT be parsed by a parser. Tags inside the text will NOT be treated as markup and entities will not be expanded </li></ul><ul><li>Entities : Most of you will known the HTML entity reference: &quot;&nbsp;&quot;  that is used to insert an extra space in an HTML document. Entities are expanded when a document is parsed by an XML parser. </li></ul>
  26. 26. Declaring an Element <ul><li><!ELEMENT element-name (element-content)> </li></ul><ul><li>Empty Tag : <!ELEMENT img (EMPTY)> </li></ul><ul><li>Elements with data : <!ELEMENT note (#PCDATA)> </li></ul><ul><li>Elements with children (sequences) : <!ELEMENT note (to,from,heading,body)> </li></ul><ul><li>Declares that the child element message can only occur one time inside the note element : </li></ul><ul><li><!ELEMENT note (message)> </li></ul>
  27. 27. <ul><li>The + sign declares that the child element message must occur one or more times inside the note element : </li></ul><ul><li><!ELEMENT note (message+)> </li></ul><ul><li>The * sign declares that the child element message can occur zero or more times inside the note element </li></ul><ul><li><!ELEMENT note (message*)> </li></ul><ul><li>The ? sign declares that the child element message can occur zero or one times inside the note element. </li></ul><ul><li><!ELEMENT note (message?)> </li></ul><ul><li>Define This : </li></ul><ul><li><!ELEMENT note (to+,from,header,message*,#PCDATA)> </li></ul>
  28. 28. Declaring Attributes <ul><li><!ATTLIST element-name attribute-name attribute-type default-value> </li></ul><ul><li>Attribute-type : </li></ul><ul><li>CDATA :The value is character data </li></ul><ul><li>ID : The value is an unique id </li></ul><ul><li>IDREF : The value is the id of another element </li></ul><ul><li>ENTITY : The value is an entity </li></ul><ul><li>Xml : The value is predefined </li></ul>
  29. 29. <ul><li>attribute-default-value </li></ul><ul><li>#DEFAULT value : The attribute has a default value </li></ul><ul><li>#REQUIRED : The attribute value must be included in the element </li></ul><ul><li>#IMPLIED : The attribute does not have to be included </li></ul><ul><li>#FIXED value : The attribute value is fixed </li></ul><ul><li>XML example: </li></ul><ul><li><square width=&quot;100&quot;></square> </li></ul><ul><li>DTD example: </li></ul><ul><li><!ELEMENT square EMPTY> </li></ul><ul><li> <!ATTLIST square width CDATA &quot;0&quot;> </li></ul>
  30. 30. XML NAMESPACE <ul><li>XML Namespaces provide a method to avoid element name conflicts </li></ul><ul><li>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 </li></ul>
  31. 31. <ul><li>This XML carries HTML table information: </li></ul><ul><li><table> </li></ul><ul><li><tr> </li></ul><ul><li><td>Apples</td> </li></ul><ul><li><td>Bananas</td> </li></ul><ul><li></tr> </li></ul><ul><li></table> </li></ul><ul><li>This XML carries information about a table (a piece of furniture): </li></ul><ul><li><table> </li></ul><ul><li><name>African Coffee Table</name> </li></ul><ul><li><width>80</width> </li></ul><ul><li><length>120</length> </li></ul><ul><li></table> </li></ul>
  32. 32. <ul><li>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. </li></ul><ul><li>An XML parser will not know how to handle these differences </li></ul><ul><li>XML Namespaces - The xmlns Attribute </li></ul><ul><li>When using prefixes in XML, a so-called namespace for the prefix must be defined. </li></ul><ul><li>The namespace is defined by the xmlns attribute in the start tag of an element. </li></ul><ul><li>The namespace declaration has the following syntax. xmlns: prefix =&quot; URI &quot;. </li></ul>
  33. 33. <ul><li><root> </li></ul><ul><li><h:table xmlns:h=&quot;http://www.w3.org/TR/html4/&quot;> </li></ul><ul><li><h:tr> </li></ul><ul><li><h:td>Apples</h:td> </li></ul><ul><li><h:td>Bananas</h:td> </li></ul><ul><li></h:tr> </li></ul><ul><li></h:table> </li></ul><ul><li><f:table xmlns:f=&quot;http://www.w3schools.com/furniture&quot;> <f:name>African Coffee Table</f:name> <f:width>80</f:width> </li></ul><ul><li><f:length>120</f:length> </li></ul><ul><li></f:table> </li></ul><ul><li></root> </li></ul><ul><li>In the example above, the xmlns attribute in the <table> tag give the h: and f: prefixes a qualified namespace </li></ul><ul><li>When a namespace is defined for an element, all child elements with the same prefix are associated with the same namespace. </li></ul>
  34. 34. XML SCHEMA <ul><li>The purpose of an XML Schema is to define the legal building blocks of an XML document, just like a DTD. </li></ul><ul><li>An XML Schema: </li></ul><ul><li>defines elements that can appear in a document </li></ul><ul><li>defines attributes that can appear in a document </li></ul><ul><li>defines which elements are child elements </li></ul><ul><li>defines the order of child elements </li></ul><ul><li>defines the number of child elements </li></ul><ul><li>defines whether an element is empty or can include text </li></ul><ul><li>defines data types for elements and attributes </li></ul><ul><li>defines default and fixed values for elements and attributes </li></ul>
  35. 35. <ul><li>We think that very soon XML Schemas will be used in most Web applications as a replacement for DTDs. Here are some reasons: </li></ul><ul><li>XML Schemas are extensible to future additions </li></ul><ul><li>XML Schemas are richer and more powerful than DTDs </li></ul><ul><li>XML Schemas are written in XML </li></ul><ul><li>XML Schemas support data types. </li></ul><ul><li>XML Schemas support namespaces </li></ul>
  36. 36. XML Schemas Support Data Types <ul><li>One of the greatest strength of XML Schemas is the support for data types.With support for data types : </li></ul><ul><li>It is easier to describe allowable document content </li></ul><ul><li>It is easier to validate the correctness of data </li></ul><ul><li>It is easier to work with data from a database </li></ul><ul><li>It is easier to define data facets (restrictions on data) </li></ul><ul><li>It is easier to define data patterns (data formats) </li></ul><ul><li>It is easier to convert data between different data types </li></ul>
  37. 37. XML Schemas use XML Syntax <ul><li>You don't have to learn a new language </li></ul><ul><li>You can use your XML editor to edit your Schema files </li></ul><ul><li>You can use your XML parser to parse your Schema files </li></ul><ul><li>You can manipulate your Schema with the XML DOM </li></ul><ul><li>You can transform your Schema with XSLT </li></ul>
  38. 38. XML Schemas Secure Data Communication <ul><li>With XML Schemas, the sender can describe the data in a way that the receiver will understand. </li></ul><ul><li>A date like: &quot;03-11-2004&quot; will, in some countries, be interpreted as 3.November and in other countries as 11.March.However, an XML element with a data type like this: </li></ul><ul><ul><li><date type=&quot;date&quot;>2004-03-11</date> </li></ul></ul><ul><li>ensures a mutual understanding of the content, because the XML data type &quot;date&quot; requires the format &quot;YYYY-MM-DD&quot;. </li></ul>
  39. 39. A Simple XML Document (note.xml) <ul><li><?xml version=&quot;1.0&quot;?> </li></ul><ul><li><note> </li></ul><ul><li><to>Tove</to> </li></ul><ul><li><from>Jani</from> </li></ul><ul><li><heading>Reminder</heading> </li></ul><ul><li><body>Don't forget me this weekend!</body> </li></ul><ul><li></note> </li></ul>
  40. 40. A DTD File (note.dtd) <ul><li><!ELEMENT note (to, from, heading, body)> </li></ul><ul><li><!ELEMENT to (#PCDATA)> </li></ul><ul><li><!ELEMENT from (#PCDATA)> </li></ul><ul><li><!ELEMENT heading (#PCDATA)> </li></ul><ul><li><!ELEMENT body (#PCDATA)> </li></ul><ul><li>The first line defines the note element to have four child elements: &quot;to, from, heading, body&quot;. </li></ul>
  41. 41. An XML Schema (note.xsd) <ul><li><?xml version=&quot;1.0&quot;?> </li></ul><ul><li><xs:schema xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot; targetNamespace=&quot;http://www.w3schools.com&quot; xmlns=&quot;http://www.w3schools.com&quot; elementFormDefault=&quot;qualified&quot;> </li></ul><ul><li><xs:element name=&quot;note&quot;> </li></ul><ul><li><xs:complexType> </li></ul><ul><li><xs:sequence> </li></ul><ul><li><xs:element name=&quot;to&quot; type=&quot;xs:string&quot;/> </li></ul><ul><li><xs:element name=&quot;from&quot; type=&quot;xs:string&quot;/> </li></ul><ul><li><xs:element name=&quot;heading&quot; type=&quot;xs:string&quot;/> </li></ul><ul><li><xs:element name=&quot;body&quot; type=&quot;xs:string&quot;/> </li></ul><ul><li></xs:sequence> </li></ul><ul><li></xs:complexType> </li></ul><ul><li></xs:element></xs:schema> </li></ul>
  42. 42. <ul><li><?xml version=&quot;1.0&quot;?> </li></ul><ul><li>1.<xs:schema xmlns:xs=&quot;http://www.w3.org/2001/XMLSchema&quot; 2.targetNamespace=&quot;http://www.w3schools.com&quot; 3.xmlns=&quot;http://www.w3schools.com&quot; 4.elementFormDefault=&quot;qualified&quot;> </li></ul><ul><li>............................................ </li></ul><ul><li></xs:schema> </li></ul><ul><li>1.indicates that the elements and data types used in the schema come from the &quot;http://www.w3.org/2001/XMLSchema&quot; namespace </li></ul><ul><li>2.indicates that the elements defined by this schema (note, to, from, heading, body.) come from the &quot;http://www.w3schools.com&quot; namespace </li></ul><ul><li>3.indicates that the default namespace is &quot;http://www.w3schools.com&quot;. </li></ul><ul><li>4.indicates that any elements used by the XML instance document which were declared in this schema must be namespace qualified . </li></ul>
  43. 43. <ul><li>DTD reference in XML : </li></ul><ul><li><?xml version=&quot;1.0&quot;?> </li></ul><ul><li><!DOCTYPE note SYSTEM &quot;http://www.w3schools.com/dtd/note.dtd&quot;> </li></ul><ul><li><note> </li></ul><ul><li>……… .…................... </li></ul><ul><li></note> </li></ul><ul><li>Schema reference in XML : </li></ul><ul><li><?xml version=&quot;1.0&quot;?> </li></ul><ul><li><note xmlns=&quot;http://www.w3schools.com&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://www.w3schools.com note.xsd&quot;> </li></ul><ul><li>……………………………… </li></ul><ul><li></note> </li></ul>
  44. 44. <ul><li><?xml version=&quot;1.0&quot;?> </li></ul><ul><li><note xmlns=&quot;http://www.w3schools.com&quot; xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xsi:schemaLocation=&quot;http://www.w3schools.com note.xsd&quot;> </li></ul><ul><li>………………………… .. </li></ul><ul><li></note> </li></ul><ul><li>specifies the default namespace declaration </li></ul><ul><li>Once you have the XML Schema Instance namespace available : </li></ul><ul><ul><li>xmlns:xsi= http://www.w3.org/2001/XMLSchema-instance </li></ul></ul><ul><li>you can use the schemaLocation attribute. This attribute has two values. The first value is the namespace to use. The second value is the location of the XML schema to use for that namespace : </li></ul><ul><ul><li>xsi:schemaLocation=&quot;http://www.w3schools.com note.xsd&quot; </li></ul></ul>
  45. 45. Style Sheet <ul><li><?xml version=&quot;1.0&quot; encoding=&quot;ISO8859-1&quot; ?> </li></ul><ul><li><?xml:stylesheet href=&quot;cd_catalog.css&quot; type=&quot;text/css&quot;?> </li></ul><ul><li><CATALOG> </li></ul><ul><li><CD> </li></ul><ul><li><TITLE>Empire Burlesque</TITLE> </li></ul><ul><li><ARTIST>Bob Dylan</ARTIST> </li></ul><ul><li><COUNTRY>USA</COUNTRY> </li></ul><ul><li><COMPANY>Columbia</COMPANY> </li></ul><ul><li><PRICE>10.90</PRICE> </li></ul><ul><li><YEAR>1985</YEAR> </li></ul><ul><li></CD> </li></ul><ul><li><CD> </li></ul><ul><li>……… .. </li></ul><ul><li></CD> </li></ul>
  46. 46. <ul><li><HTML> </li></ul><ul><li><BODY>CATALOG </li></ul><ul><li>{ </li></ul><ul><li>width: 100%; </li></ul><ul><li>} </li></ul><ul><li>CD </li></ul><ul><li>{ </li></ul><ul><li>display: block; </li></ul><ul><li>margin-bottom: 30pt; </li></ul><ul><li>margin-left: 0; </li></ul><ul><li>} </li></ul><ul><li>TITLE </li></ul><ul><li>{ </li></ul><ul><li>color: blue; </li></ul><ul><li>font-size: 20pt; </li></ul><ul><li>} </li></ul><ul><li>ARTIST </li></ul><ul><li>{ </li></ul><ul><li>color: green; </li></ul><ul><li>font-size: 20pt; </li></ul><ul><li>} </li></ul><ul><li>COUNTRY,PRICE,YEAR,COMPANY </li></ul><ul><li>{ </li></ul><ul><li>Display: block; </li></ul><ul><li>color: red; </li></ul><ul><li>margin-left: 20pt; </li></ul><ul><li>}</BODY></HTML> </li></ul>
  47. 47. XSLT <ul><li>XSLT stands for XSL Transformations. It is use to transform XML documents into other formats, like XHTML. </li></ul><ul><li>XSL : XSL stands for EXtensible Stylesheet Language. </li></ul><ul><li>XSLT stands for XSL Transformations </li></ul><ul><li>XSLT is the most important part of XSL </li></ul><ul><li>XSLT transforms an XML document into another XML document </li></ul><ul><li>XSLT uses XPath to navigate in XML documents </li></ul><ul><li>XSLT is a W3C Recommendation </li></ul>
  48. 48. <ul><li>Catalog.xml : </li></ul><ul><li><?xml version=&quot;1.0&quot; ?> </li></ul><ul><li><?xml:stylesheet href=&quot;catalog.xsl&quot; type=&quot;text/xsl&quot;?> </li></ul><ul><li><CATALOG> </li></ul><ul><li><CD> </li></ul><ul><li><TITLE>Empire Burlesque</TITLE> </li></ul><ul><li><ARTIST>Bob Dylan</ARTIST> </li></ul><ul><li><COUNTRY>USA</COUNTRY> </li></ul><ul><li><COMPANY>Columbia</COMPANY> </li></ul><ul><li><PRICE>10.90</PRICE> </li></ul><ul><li><YEAR>1985</YEAR> </li></ul><ul><li></CD> </li></ul><ul><li><CD> </li></ul><ul><li>………… . </li></ul>
  49. 49. <ul><li>catalog.xsl : </li></ul><ul><li><?xml version='1.0'?> </li></ul><ul><li><xsl:stylesheet xmlns:xsl=&quot;http://www.w3.org/TR/WD-xsl&quot;> </li></ul><ul><li><xsl:template match=&quot;/&quot;> </li></ul><ul><li><html> </li></ul><ul><li><body> </li></ul><ul><li><table border=&quot;2&quot; bgcolor=&quot;yellow&quot;> </li></ul><ul><li><tr> </li></ul><ul><li><th>Title</th> </li></ul><ul><li><th>Artist</th> </li></ul><ul><li></tr> </li></ul><ul><li><xsl:for-each select=&quot;CATALOG/CD&quot;> </li></ul><ul><li><tr> </li></ul><ul><li><td><xsl:value-of select=&quot;TITLE&quot;/></td> </li></ul><ul><li><td><xsl:value-of select=&quot;ARTIST&quot;/></td> </li></ul><ul><li></tr> </li></ul><ul><li></xsl:for-each> </li></ul><ul><li></table> </li></ul><ul><li></body> </li></ul><ul><li></html> </li></ul><ul><li></xsl:template> </li></ul><ul><li></xsl:stylesheet> </li></ul>
  50. 50. <ul><li>The match attribute is used to associate a template with an XML element . match=&quot;/&quot; defines the whole document. </li></ul><ul><li>The <xsl:value-of> element can be used to extract the value of an XML element and add it to the output stream of the transformation </li></ul><ul><li>The XSL <xsl:for-each> element can be used to select every XML element of a specified node-set </li></ul><ul><li><xsl:for-each select=&quot;catalog/cd[artist='Bob Dylan']&quot;> </li></ul><ul><li>Legal filter operators are: </li></ul><ul><li>=  (equal) </li></ul><ul><li>!= (not equal) </li></ul><ul><li>&lt; less than </li></ul><ul><li>&gt; greater than </li></ul>
  51. 51. <ul><li>To sort the output, simply add an <xsl:sort> element inside the <xsl:for-each> element in the XSL file: </li></ul><ul><li><?xml version='1.0'?> </li></ul><ul><li>………………… . </li></ul><ul><li><xsl:for-each select=&quot;catalog/cd&quot;> </li></ul><ul><li> <xsl:sort select=&quot;artist&quot;/> </li></ul><ul><ul><li><tr> </li></ul></ul><ul><li><td><xsl:value-of select=&quot;title&quot;/></td> </li></ul><ul><li><td><xsl:value-of select=&quot;artist&quot;/></td> </li></ul><ul><li> </tr> </li></ul><ul><li></xsl:for-each> </li></ul><ul><li>…………………………………… . </li></ul><ul><li></xsl:stylesheet> </li></ul>
  52. 52. <ul><li>To add a conditional test, add the <xsl:if> element inside the <xsl:for-each> element in the XSL file: </li></ul><ul><li><?xml version='1.0'?> </li></ul><ul><li>………………… . </li></ul><ul><li><xsl:for-each select=&quot;catalog/cd&quot;> </li></ul><ul><li><xsl:if test=&quot;price &gt; 10&quot;> </li></ul><ul><li><tr> </li></ul><ul><li><td><xsl:value-of select=&quot;title&quot;/></td> <td><xsl:value-of select=&quot;artist&quot;/></td> </tr> </li></ul><ul><li></xsl:if> </li></ul><ul><li></xsl:for-each> </li></ul><ul><li>…………………………………… . </li></ul><ul><li></xsl:stylesheet </li></ul>
  53. 53. <ul><li>To insert a multiple conditional test against the XML file, add the <xsl:choose>, <xsl:when>, and <xsl:otherwise> elements to the XSL file: </li></ul><ul><li><xsl:for-each select=&quot;catalog/cd&quot;> </li></ul><ul><li><tr> </li></ul><ul><li><td><xsl:value-of select=&quot;title&quot;/></td> </li></ul><ul><li><xsl:choose> </li></ul><ul><li><xsl:when test=&quot;price &gt; 10&quot;> </li></ul><ul><li><td bgcolor=&quot;#ff00ff&quot;> </li></ul><ul><li><xsl:value-of select=&quot;artist&quot;/> </li></ul><ul><li></td> </li></ul><ul><li></xsl:when> </li></ul><ul><li><xsl:otherwise> </li></ul><ul><li><td><xsl:value-of select=&quot;artist&quot;/></td> </li></ul><ul><li></xsl:otherwise> </li></ul><ul><li></xsl:choose> </li></ul><ul><li></tr> </li></ul><ul><li></xsl:for-each> </li></ul>
  54. 54. Simple object Access protocol (SOAP 1.2)
  55. 55. Introduction <ul><li>SOAP is a lightweight protocol intended for exchanging structured information in a decentralized, distributed environment </li></ul><ul><li>SOAP uses XML technologies to define an extensible messaging framework providing a message construct that can be exchanged </li></ul><ul><li>over a variety of underlying protocols </li></ul><ul><li>The framework has been designed to be independent of any particular programming model and other implementation specific </li></ul><ul><li>semantics </li></ul><ul><li>Wire protocol similar to : </li></ul><ul><li> IIOP for CORBA </li></ul><ul><li>JRMP for RMI </li></ul><ul><li>Supports XML-based RPC (Remote Procedure Call) </li></ul>
  56. 56. What is SOAP ? <ul><li>SOAP stands for Simple Object Access Protocol </li></ul><ul><li>SOAP is a communication protocol </li></ul><ul><li>SOAP is for communication between applications </li></ul><ul><li>SOAP is a format for sending messages </li></ul><ul><li>SOAP is designed to communicate via Internet </li></ul><ul><li>SOAP is platform independent </li></ul><ul><li>SOAP is language independent </li></ul><ul><li>SOAP is based on XML </li></ul><ul><li>SOAP is simple and extensible </li></ul><ul><li>SOAP allows you to get around firewalls </li></ul><ul><li>SOAP will be developed as a W3C standard </li></ul>
  57. 57. <ul><li>WHAT SOAP IS NOT ? </li></ul><ul><li>Not a component model </li></ul><ul><ul><li>So it will not replace objects and components, i.e. EJB™, JavaBeans™ </li></ul></ul><ul><li>Not a programming language </li></ul><ul><ul><li>So it will not replace Java </li></ul></ul><ul><li>Not a solution for all </li></ul><ul><ul><li>So it will not replace other distributed computing technologies such as RMI </li></ul></ul>
  58. 58. SOAP Message structure SOAP Envelope SOAP Header Header Entry Header Entry SOAP Body Body Entry Body Entry
  59. 59. <ul><li>A SOAP message is an ordinary XML document containing the following elements: </li></ul><ul><ul><li>A required Envelope element that identifies the XML document as a SOAP message </li></ul></ul><ul><ul><li>An optional Header element that contains header information </li></ul></ul><ul><ul><li>A required Body element that contains call and response information </li></ul></ul><ul><ul><li>An optional Fault element that provides information about errors that occurred while processing the message </li></ul></ul><ul><li>A SOAP message MUST be encoded using XML </li></ul><ul><li>A SOAP message MUST use the SOAP Envelope namespace </li></ul><ul><li>A SOAP message MUST use the SOAP Encoding namespace </li></ul><ul><li>A SOAP message must NOT contain a DTD reference </li></ul><ul><li>A SOAP message must NOT contain XML Processing Instructions </li></ul>
  60. 60. <ul><li><?xml version=&quot;1.0&quot;?> </li></ul><ul><li><soap:Envelope xmlns:soap =&quot;http://www.w3.org/2001/12/soap-envelope &quot; soap:encodingStyle=&quot; http://www.w3.org/2001/12/soap-encoding &quot;> </li></ul><ul><li><soap:Header> </li></ul><ul><li>... </li></ul><ul><li>... </li></ul><ul><li></soap:Header> </li></ul><ul><li><soap:Body> </li></ul><ul><li>... </li></ul><ul><li>... </li></ul><ul><li><soap:Fault> </li></ul><ul><li>... </li></ul><ul><li>... </li></ul><ul><li></soap:Fault> </li></ul><ul><li></soap:Body> </li></ul><ul><li></soap:Envelope> </li></ul>
  61. 61. The SOAP Envelope Element <ul><li>The required SOAP Envelope element is the root element of a SOAP message. It defines the XML document as a SOAP message. </li></ul><ul><li>The SOAP encodingStyle attribute is used to define the data types used in the document. This attribute may appear on any SOAP element, and it will apply to that element's contents and all child elements. A SOAP message has no default encoding. </li></ul>
  62. 62. SOAP Header <ul><li>The optional SOAP Header element contains application specific information (like authentication, payment, etc) about the SOAP message. If the Header element is present, it must be the first child element of the Envelope element </li></ul><ul><li>SOAP defines three attributes in the default namespace (&quot;http://www.w3.org/2001/12/soap-envelope&quot;). </li></ul><ul><li>These attributes are: </li></ul><ul><ul><li>actor , mustUnderstand , and encodingStyle . </li></ul></ul><ul><li>The attributes defined in the SOAP Header defines how a recipient should process the SOAP message </li></ul>
  63. 63. <ul><li>Actor attribute : A SOAP message may travel from a sender to a receiver by passing different endpoints along the message path. </li></ul><ul><li>Syntax : soap:actor= “uri” </li></ul><ul><li><?xml version=&quot;1.0&quot;?> </li></ul><ul><li><soap:Envelope xmlns:soap=&quot;http://www.w3.org/2001/12/soap-envelope&quot; soap:encodingStyle=&quot;http://www.w3.org/2001/12/soap-encoding&quot;> </li></ul><ul><li><soap:Header> </li></ul><ul><li><m:Trans xmlns:m=&quot;http://www.w3schools.com/transaction/&quot; soap:actor=&quot;http://www.w3schools.com/appml /&quot;> 234 </m:Trans> </soap:Header> </li></ul><ul><li>... ... </li></ul><ul><li></soap:Envelope> </li></ul><ul><li>The example above contains a header with a &quot;Trans&quot; element </li></ul>
  64. 64. <ul><li>mustUnderstand Attribute : The SOAP mustUnderstand attribute can be used to indicate whether a header entry is mandatory or optional for the recipient to process. </li></ul><ul><li>If you add &quot;mustUnderstand=&quot;1&quot; to a child element of the Header element it indicates that the receiver processing the Header must recognize the element. </li></ul><ul><li>Syntax : soap:mustUnderstand=&quot;0|1&quot; </li></ul><ul><li><?xml version=&quot;1.0&quot;?> </li></ul><ul><li><soap:Envelope xmlns:soap=&quot;http://www.w3.org/2001/12/soap-envelope&quot; soap:encodingStyle=&quot;http://www.w3.org/2001/12/soap-encoding&quot;> </li></ul><ul><li><soap:Header> </li></ul><ul><li><m:Trans xmlns:m=&quot;http://www.w3schools.com/transaction/&quot; soap:mustUnderstand=&quot;1&quot;> 234 </m:Trans> </li></ul><ul><li></soap:Header> </li></ul><ul><li>... ... </li></ul><ul><li></soap:Envelope> </li></ul>
  65. 65. SOAP Body <ul><li>The required SOAP Body element contains the actual SOAP message </li></ul><ul><li>SOAP defines one element inside the Body element in the default namespace (&quot;http://www.w3.org/2001/12/soap-envelope&quot;). This is the SOAP Fault element, which is used to indicate error messages. </li></ul>
  66. 66. <ul><li><?xml version=&quot;1.0&quot;?> </li></ul><ul><li><soap:Envelope xmlns:soap=&quot;http://www.w3.org/2001/12/soap-envelope&quot; soap:encodingStyle=&quot;http://www.w3.org/2001/12/soap-encoding&quot;> </li></ul><ul><li><soap:Body> </li></ul><ul><li><m:GetPrice xmlns:m=&quot;http://www.w3schools.com/prices&quot;> <m:Item>Apples</m:Item> </li></ul><ul><li></m:GetPrice> </li></ul><ul><li></soap:Body> </li></ul><ul><li></soap:Envelope> </li></ul><ul><li>The example above requests the price of apples. Note that the m:GetPrice and the Item elements above are application-specific elements. They are not a part of the SOAP standard. </li></ul>
  67. 67. <ul><li>A SOAP response looks like this : </li></ul><ul><li><?xml version=&quot;1.0&quot;?> </li></ul><ul><li><soap:Envelope xmlns:soap=&quot;http://www.w3.org/2001/12/soap-envelope&quot; soap:encodingStyle=&quot;http://www.w3.org/2001/12/soap-encoding&quot;> </li></ul><ul><li><soap:Body> </li></ul><ul><li><m:GetPriceResponse xmlns:m=&quot;http://www.w3schools.com/prices&quot;> <m:Price>1.90</m:Price> </li></ul><ul><li></m:GetPriceResponse> </li></ul><ul><li></soap:Body> </li></ul><ul><li></soap:Envelope> </li></ul>
  68. 68. SOAP Fault Element <ul><li>An error message from a SOAP message is carried inside a Fault element. If a Fault element is present, it must appear as a child element of the Body element. A Fault element can only appear once in a SOAP message. </li></ul>Information about who caused the fault to happen <faultactor> Holds application specific error information related to the Body element <deatil> A human readable explanation of the fault <faultstring> A code for identifying the fault <faultcode> Description Sub-element
  69. 69. SOAP HTTP Binding <ul><li>HTTP communicates over TCP/IP. An HTTP client connects to an HTTP server using TCP. After establishing a connection, the client can send an HTTP request message to the server: </li></ul><ul><li>POST /item HTTP/1.1 </li></ul><ul><li>Host: 189.123.345.239 </li></ul><ul><li>Content-Type: text/plain </li></ul><ul><li>Content-Length: 200 </li></ul><ul><li>The server then processes the request and sends an HTTP response back to the client. The response contains a status code that indicates the status of the request </li></ul>
  70. 70. <ul><li>If success : </li></ul><ul><li>200 OK </li></ul><ul><li>Content-Type: text/plain </li></ul><ul><li>Content-Length: 200 </li></ul><ul><li>If failure : </li></ul><ul><li>400 Bad Request </li></ul><ul><li>Content-Length: 0 </li></ul><ul><li>SOAP HTTP Binding : A SOAP method is an HTTP request/response that complies with the SOAP encoding rules. </li></ul><ul><ul><li>HTTP + XML = SOAP </li></ul></ul><ul><li>A SOAP request could be an HTTP POST or an HTTP GET request. </li></ul><ul><li>The HTTP POST request specifies at least two HTTP headers: Content-Type and Content-Length. </li></ul>
  71. 71. <ul><li>Content-Type : The Content-Type header for a SOAP request and response defines the MIME type for the message and the character encoding (optional) used for the XML body of the request or response. </li></ul><ul><li>Example : </li></ul><ul><ul><li>POST /item HTTP/1.1 </li></ul></ul><ul><ul><li>Content-Type: application/soap+xml; charset=utf-8 </li></ul></ul><ul><li>Content-Length : The Content-Length header for a SOAP request and response specifies the number of bytes in the body of the request or response. </li></ul><ul><li>Example : </li></ul><ul><ul><li>POST /item HTTP/1.1 </li></ul></ul><ul><ul><li>Content-Type: application/soap+xml; charset=utf-8 </li></ul></ul><ul><ul><li>Content-Length: 250 </li></ul></ul>
  72. 72. Problem <ul><li>In the example a GetStockPrice request is sent to a server. The request has a StockName parameter, and a Price parameter will be returned in the response. The namespace for the function is defined in &quot;http://www.example.org/stock&quot; address. </li></ul>
  73. 73. <ul><li>SOAP Request : </li></ul><ul><li>POST /InStock HTTP/1.1 </li></ul><ul><li>Host: www.example.org </li></ul><ul><li>Content-Type: application/soap+xml; charset=utf-8 </li></ul><ul><li>Content-Length: nnn </li></ul><ul><li><?xml version=&quot;1.0&quot;?> </li></ul><ul><li><soap:Envelope xmlns:soap=&quot;http://www.w3.org/2001/12/soap-envelope&quot; soap:encodingStyle=&quot;http://www.w3.org/2001/12/soap-encoding&quot;> </li></ul><ul><li><soap:Body xmlns:m=&quot;http://www.example.org/stock&quot;>   </li></ul><ul><li>  <m:GetStockPrice> </li></ul><ul><li><m:StockName>IBM</m:StockName> </li></ul><ul><li>     </m:GetStockPrice> </li></ul><ul><li></soap:Body> </li></ul><ul><li></soap:Envelope> </li></ul>
  74. 74. <ul><li>SOAP Response: </li></ul><ul><li>HTTP/1.1 200 OK </li></ul><ul><li>Content-Type: application/soap+xml; charset=utf-8 </li></ul><ul><li>Content-Length: nnn </li></ul><ul><li><?xml version=&quot;1.0&quot;?> </li></ul><ul><li><soap:Envelope xmlns:soap=&quot;http://www.w3.org/2001/12/soap-envelope&quot; soap:encodingStyle=&quot;http://www.w3.org/2001/12/soap-encoding&quot;> </li></ul><ul><li><soap:Body xmlns:m=&quot;http://www.example.org/stock&quot;> <m:GetStockPriceResponse> </li></ul><ul><li><m:Price>34.5</m:Price> </li></ul><ul><li></m:GetStockPriceResponse> </li></ul><ul><li></soap:Body> </li></ul><ul><li></soap:Envelope> </li></ul>
  75. 75. Example
  76. 76. <ul><li><?xml version=&quot;1.0&quot;?> </li></ul><ul><li><soap:Envelope xmlns:soap=&quot;http://www.w3.org/2001/12/soap-envelope&quot; soap:encodingStyle=&quot;http://www.w3.org/2001/12/soap-encoding&quot;> </li></ul><ul><li><soap:Header> </li></ul><ul><li><m:reservation xmlns:m=&quot;http://travelcompany.example.org/reservation&quot; </li></ul><ul><li>soap:role=&quot;http://www.w3.org/2003/05/soap-envelope/role/next&quot; </li></ul><ul><li>soap:mustUnderstand=“1&quot;> </li></ul><ul><li><m:reference>uuid:093a2da1-q345-739r-ba5d-pqff98fe8j7d</m:reference> </li></ul><ul><li><m:dateAndTime>2001-11-29T13:20:00.000-05:00</m:dateAndTime> </li></ul><ul><li></m:reservation> </li></ul><ul><li><n:passenger xmlns:n=&quot;http://mycompany.example.com/employees&quot; </li></ul><ul><li>soap:role=&quot;http://www.w3.org/2003/05/soap-envelope/role/next&quot; </li></ul><ul><li>soap:mustUnderstand=“1&quot;> </li></ul><ul><li><n:name>Niyaz ahmad rao</n:name> </li></ul><ul><li></n:passenger> </li></ul><ul><li></soap:Header> </li></ul><ul><li>... ... </li></ul><ul><li></soap:Envelope> </li></ul>
  77. 77. <ul><li><soap:body> </li></ul><ul><li><p:itinerary </li></ul><ul><li>xmlns:p=&quot;http://travelcompany.example.org/reservation/travel&quot;> </li></ul><ul><li><p:departure> </li></ul><ul><li><p:departing>New York</p:departing> </li></ul><ul><li><p:arriving>Los Angeles</p:arriving> </li></ul><ul><li><p:departureDate>2001-12-14</p:departureDate> </li></ul><ul><li><p:departureTime>late afternoon</p:departureTime> </li></ul><ul><li><p:seatPreference>aisle</p:seatPreference> </li></ul><ul><li></p:departure> </li></ul><ul><li><p:return> </li></ul><ul><li><p:departing>Los Angeles</p:departing> </li></ul><ul><li><p:arriving>New York</p:arriving> </li></ul><ul><li><p:departureDate>2001-12-20</p:departureDate> </li></ul><ul><li><p:departureTime>mid-morning</p:departureTime> </li></ul><ul><li><p:seatPreference/> </li></ul><ul><li></p:return> </li></ul><ul><li></p:itinerary> </li></ul><ul><li><q:lodging </li></ul><ul><li>xmlns:q=&quot;http://travelcompany.example.org/reservation/hotels&quot;> </li></ul><ul><li><q:preference>none</q:preference> </li></ul><ul><li></q:lodging </li></ul><ul><li></soap:body> </li></ul>