xml presentation

23
7/29/2019 XML Presentation http://slidepdf.com/reader/full/xml-presentation 1/23 WEB SERVICES AND XML BASICS  Author: Sonali Patil

Upload: magic1717

Post on 14-Apr-2018

226 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: XML Presentation

7/29/2019 XML Presentation

http://slidepdf.com/reader/full/xml-presentation 1/23

WEB SERVICES ANDXML BASICS

 Author: Sonali Patil

Page 2: XML Presentation

7/29/2019 XML Presentation

http://slidepdf.com/reader/full/xml-presentation 2/23

 Agenda

Web Services Web Services Architecture

SOAP

UDDI

WSDL WSDL UDDI Relationship

XML XML Tree

XML Syntax Rules

XML DTD

Namespaces

CSS

XSL

XSLT

Page 3: XML Presentation

7/29/2019 XML Presentation

http://slidepdf.com/reader/full/xml-presentation 3/23

What are Web Services?

Web services is a piece of software that allow your 

application to publish its function or message to the rest

of the world

The basic Web services platform is XML + HTTP.

Is available over the Internet or private (intranet)

networks

Uses a standardized XML messaging system Is not tied to any one operating system or programming

language

Is self-describing via a common XML grammar 

Is discoverable via a simple find mechanism

Page 4: XML Presentation

7/29/2019 XML Presentation

http://slidepdf.com/reader/full/xml-presentation 4/23

Web Services Architecture

Web Service Roles

Service provider 

Service requestor  Service registry

Web Service Protocol Stack

Service transport (HTTP) XML messaging (SOAP)

Service description (WSDL)

Service discovery (UDDI)

Page 5: XML Presentation

7/29/2019 XML Presentation

http://slidepdf.com/reader/full/xml-presentation 5/23

What is SOAP? 

SOAP stands for Simple Object Access Protocol

SOAP is an XML-based protocol to let

applications exchange information over HTTP.

SOAP is a format for sending messages

Show the env,header,body format

SOAP is platform independent

SOAP is based on XML

SOAP allows you to get around firewalls

Page 6: XML Presentation

7/29/2019 XML Presentation

http://slidepdf.com/reader/full/xml-presentation 6/23

What is WSDL? 

WSDL is used to describe the Web services.

WSDL stands for Web Services Description Language

WSDL is based on XML. It is a simple XML document  A WSDL document describes a web service using these

major elements

<types> The data types used by the web service

<message> The messages used by the web service

<portType> The operations performed by the web service

<binding> The message format and protocol details for eachport used by the web service

<service> The address location of the Web Service

Page 7: XML Presentation

7/29/2019 XML Presentation

http://slidepdf.com/reader/full/xml-presentation 7/23

WSDL

<type>

 <messages>

<xsd:simpleType name="CreditRating">

<xsd:restriction base="xsd:string">

<xsd:enumeration value="GOOD" />

<xsd:enumeration value="AVERAGE" />

<xsd:enumeration value="BAD" />

<xsd:enumeration value="UNKNOWN" />

</xsd:restriction>

</xsd:simpleType>

<s1:message name="addCustomer ">

<s1:part element="s2:addCustomer " name="addCustomer " />

</s1:message>

<s1:message name="addCustomerResponse">

<s1:part element="s2:addCustomerResponse"

name="addCustomerResponse" /></s1:message>

Page 8: XML Presentation

7/29/2019 XML Presentation

http://slidepdf.com/reader/full/xml-presentation 8/23

WSDL

<porttype>

<s1:portType name="CustomerServicePort">

<s1:operation name="addCustomer ">

<s1:input message="s2:addCustomer " />

<s1:output message="s2:addCustomerResponse" /><s1:fault message="s2:customerServiceFault" name="customerServiceFault"

/>

</s1:operation>

</ s1:portType>

Page 9: XML Presentation

7/29/2019 XML Presentation

http://slidepdf.com/reader/full/xml-presentation 9/23

WSDL <binding>

<s1:binding name="CustomerServiceSoapBinding"type="s2:CustomerServicePort">

<s4:binding style="document"

transport="http://schemas.xmlsoap.org/soap/http" />

<s1:operation name="addCustomer ">

<s4:operation soapAction="addCustomer " style="document" />

<s1:input>

<wsp:Policy><wsp:PolicyReference URI="#Auth.xml" />

</wsp:Policy>

<s4:header message="s2:customerServiceRequestHeader "

part="request_header " use="literal" />

<s4:body use="literal" />

</s1:input>

<s1:output>

<s4:header message="s2:customerServiceResponseHeader "

part="response_header " use="literal" />

<s4:body use="literal" />

</s1:output>

<s1:fault name="customerServiceFault">

<s4:fault name="customerServiceFault" use="literal" /></s1:fault>

Page 10: XML Presentation

7/29/2019 XML Presentation

http://slidepdf.com/reader/full/xml-presentation 10/23

WSDL

<service>

<s1:service name="CustomerService">

<s1:port binding="s2:CustomerServiceSoapBinding"

name="CustomerServicePort">

<s4:address location= "https://esp-

int.cable.comcast.com:443/CustomerService/10.03" /></s1:port>

</s1:service>

Page 11: XML Presentation

7/29/2019 XML Presentation

http://slidepdf.com/reader/full/xml-presentation 11/23

What is UDDI? 

UDDI is a directory service where companies can

register and search for Web services.

UDDI stands for Universal Description, Discovery andIntegration

UDDI is a directory of web service interfaces described

by WSDL

UDDI communicates via SOAP

Page 12: XML Presentation

7/29/2019 XML Presentation

http://slidepdf.com/reader/full/xml-presentation 12/23

WSDL UDDI Relationship

Page 13: XML Presentation

7/29/2019 XML Presentation

http://slidepdf.com/reader/full/xml-presentation 13/23

What is XML

XML stands for EXtensible Markup Language

XML is a markup language much like HTML

XML was designed to carry data, not to display data XML tags are not predefined. You must define your own

tags

XML is designed to be self-descriptive

Page 14: XML Presentation

7/29/2019 XML Presentation

http://slidepdf.com/reader/full/xml-presentation 14/23

XML Tree

XML documents form a tree structure that starts at "the root" and

branches to "the leaves".

XML documents use a self-describing and simple syntax:

<?xml version="1.0" encoding="ISO-8859-1"?>

<note>

<to>abc</to>

<from>xyz</from>

<heading>Reminder</heading>

<body>Don't forget me this weekend!

 ABCD

</body>

</note>

XML

Declaration

Root element

Child

Elements

Element

Tag

Page 15: XML Presentation

7/29/2019 XML Presentation

http://slidepdf.com/reader/full/xml-presentation 15/23

XML Syntax Rules 

 All XML Elements Must Have a Closing Tag

<message>This is correct</message>

XML Elements Must be Properly Nested

<b><i>This is incorrect</b></i><b><i>This is correct</i></b>

XML Tags are Case Sensitive

<Message>This is incorrect</message>

XML Documents Must Have a Root Element

Page 16: XML Presentation

7/29/2019 XML Presentation

http://slidepdf.com/reader/full/xml-presentation 16/23

XML DTD

The purpose of a DTD is to define the structure of an XML

document.

The DTD consists of the following elements:

Elements

 Attributes Entities

PCDATA

CDATA

<!DOCTYPE note

[<!ELEMENT note (to,from,heading,body)>

<!ELEMENT to (#PCDATA)>

<!ELEMENT from (#PCDATA)>

<!ELEMENT heading (#PCDATA)>

<!ELEMENT body (#PCDATA)>

]>

Page 17: XML Presentation

7/29/2019 XML Presentation

http://slidepdf.com/reader/full/xml-presentation 17/23

XML Namespaces 

XML Namespaces provide a method to avoid element name conflicts.

The xmlns Attribute

When using prefixes in XML, a namespace for the prefix must be defined.

The namespace is defined by the xmlns attribute in the start tag of anelement.

The namespace declaration has the following syntax. xmlns: prefix ="URI ". When a namespace is defined for an element, all child elements with the

same prefix are associated with the same namespace.

<root><h:table xmlns:h="http://www.w3.org/TR/html4/">

<h:tr><h:td>Apples</h:td><h:td>Bananas</h:td>

</h:tr></h:table><f:table xmlns:f="http://www.w3schools.com/furniture">

<f:name>African Coffee Table</f:name><f:width>80</f:width><f:length>120</f:length>

</f:table></root>

Page 18: XML Presentation

7/29/2019 XML Presentation

http://slidepdf.com/reader/full/xml-presentation 18/23

XML CSS

With CSS (Cascading Style Sheets) you can add display

information to an XML document.

So CSS is used to format an XML document

In order to link a XML to the CSS file, the following tag should

be included in the XML:

<?xml-stylesheet type="text/css"

href =“note_format.css"?> 

Body note_format.css{

background-color: #ffffff;

width: 100%;

}

Page 19: XML Presentation

7/29/2019 XML Presentation

http://slidepdf.com/reader/full/xml-presentation 19/23

XSL

XSL stands for EXtensible Stylesheet Language 

CSS = Style Sheets for HTML

XSL = Style Sheets for XML XSL consists of three parts:

XSLT - a language for transforming XML documents

XPath - a language for navigating in XML documents

XSL-FO - a language for formatting XML documents

Page 20: XML Presentation

7/29/2019 XML Presentation

http://slidepdf.com/reader/full/xml-presentation 20/23

XSLT

XSLT stands for XSL Transformations

XSLT is the most important part of XSL

XSLT transforms an XML document into another XMLdocument another type of document that is recognized

by a browser, like HTML and XHTML

XSLT uses XPath to navigate in XML documents

Page 21: XML Presentation

7/29/2019 XML Presentation

http://slidepdf.com/reader/full/xml-presentation 21/23

XSLT - Transformation

Following is an example of a XML document that has to transformed to a

XHTML document:

<?xml version="1.0" encoding="ISO-8859-1"?>

<?xml-stylesheet type="text/xsl" href="cdcatalog.xsl"?>

<catalog><cd>

<title>Empire Burlesque</title>

<artist>Bob Dylan</artist>

<country>USA</country>

<company>Columbia</company>

<price>10.90</price><year>1985</year>

</cd>

.

.

</catalog>

Page 22: XML Presentation

7/29/2019 XML Presentation

http://slidepdf.com/reader/full/xml-presentation 22/23

Create an XSL Style Sheet

<?xml version="1.0" encoding="ISO-8859-1"?>

<xsl:stylesheet version="1.0”

xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><xsl:template match="/">

<html>

<body>

<h2>My CD Collection</h2>

<table border="1">

<tr bgcolor="#9acd32">

<th>Title</th>

<th>Artist</th>

</tr>

<xsl:for-each select="catalog/cd">

<tr>

<td><xsl:value-of select="title"/></td>

<td><xsl:value-of select="artist"/></td></tr>

</xsl:for-each>

</table>

</body>

</html>

</xsl:template></xsl:stylesheet>

X Path expression

Page 23: XML Presentation

7/29/2019 XML Presentation

http://slidepdf.com/reader/full/xml-presentation 23/23

  The XML when viewed in the browser will look as shown

below: