Web Sevices XML SOAP UDDI WSDL 210 772
Web. Sevices - XML SOAP - UDDI - WSDL Θ. Βαρβαρίγου Καθηγ. ΕΜΠ Τηλ 210 - 772 2484 email: dora@telecom. ntua. gr http: //ecourses. dbnet. ntua. gr
XML και XSLT <? xml version="1. 0"? > <? 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> 18/5/2010 <? xml version="1. 0"? > <xsl: stylesheet version="1. 0" xmlns: xsl="http: //www. w 3. org/1999/XSL/Transform"> <xsl: template match="/"> <html><body> <table border="1"> <tr bgcolor="#9 acd 32"> <th align="left">Title</th> <th align="left">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> Δικτυακός Προγραμματισμός 5
Δεδομένα σε ενα XML (1) • Κάρτα Πελάτη: • Name: Nikos Papadakis • Address: – – 9 Iroon Politechneiou Street Zografou, Athens Greece 157 72 • Age: 33 18/5/2010 Δικτυακός Προγραμματισμός 7
Δεδομένα στο XML (2) • Το αντίστοιχο XML: <? xml version="1. 0"? > <client> <name> <firstname>Nikos</firstname> <lastname>Papadakis</lastname> </name> <address type="home"> <street_address>9 Iroon Politechneiou St. </street_address> <city>Athens</city> <state>Greece</state> <zip>157 72</zip> </address> <age>33</age> </client> 18/5/2010 Δικτυακός Προγραμματισμός 8
XML Schema Παράδειγμα XML Schema (country. xsd) <xs: schema xmlns: xs="http: //www. w 3. org/2001/XMLSchema"> <xs: element name="country" type="Country"/> <xs: complex. Type name="Country"> <xs: sequence> <xs: element name="name" type="xs: string"/> <xs: element name="population" type="xs: decimal"/> </xs: sequence> </xs: complex. Type> </xs: schema> Και το αντίστοιχο XML: <country xmlns: xsi="http: //www. w 3. org/2001/XMLSchema-instance" xsi: no. Namespace. Schema. Location="country. xsd"> <name>France</name> <population>59. 7</population> </country> 18/5/2010 Δικτυακός Προγραμματισμός 15
XML Display • CSS - Cascading Style Sheets – – Υπέρ: εύκολος ορισμός ιδιοτήτων εμφάνισης ενός XML element Κατά: Δεν είναι πολύ «δυνατά» Μόνο για τα Web browser Παράδειγμα: p{ font-family: "Garamond", serif; } h 2 { font-size: 110%; color: red; background: white; }. note { color: red; background: yellow; font-weight: bold; } 18/5/2010 Δικτυακός Προγραμματισμός 17
XML Display • XSL – Extensible Stylesheet Language – Υπέρ: μπορεί να μετασχηματίσει ένα XML σε μια οποιαδήποτε άλλη markup γλώσσα. – Κατά: Πολυπλοκότητα – Παράδειγμα: …. <xsl: template match="doc/title"> <h 1> <xsl: apply-templates/> </h 1> </xsl: template> <xsl: template match="chapter/title"> <h 2> <xsl: apply-templates/> </h 2> </xsl: template> …. 18/5/2010 Δικτυακός Προγραμματισμός 18
XSL μετασχηματισμοί XML Plain Text XML Transformation PDF HTML WAP SGML 18/5/2010 Δικτυακός Προγραμματισμός 19
XML – XSL - Output <scene> <FX>General Road Building noises. </FX> <speech speaker="Prosser"> Come off it Mr Dent, you can't win you know. There's no point in lying down in the path of progress. </speech> <speech speaker="Arthur"> I've gone off the idea of progress. It's overrated </speech> </scene> …<xsl: template match="FX"> <fo: block font-weight="bold"> <xsl: applytemplates/> </fo: block> </xsl: template> <xsl: template match="speech[@speaker='Arthur']"> <fo: block background-color="blue"> <xsl: value-of select="@speaker"/>: <xsl: apply-templates/> </fo: block> </xsl: template>. . . 18/5/2010 Δικτυακός Προγραμματισμός 20
Η δομή ενός SOAP Message • SOAP Messages περιέχονται μέσα στα soap: Envelope elements. • Το Envelope ΜΠΟΡΕΙ να έχει: – soap: Header. • Το Envelope ΠΡΕΠΕΙ να έχει: – soap: Body. • To Envelope ΠΡΕΠΕΙ να είναι το root element! • Στο Envelope ορίζουμε πάντα το namespace soap με τιμή το URI: – http: //www. w 3. org/2001/12/soap-envelope – Πχ <soap: Envelope xmlns: soap="http: //www. w 3. org/2001/12/soap-envelope> 18/5/2010 Δικτυακός Προγραμματισμός 38
Το SOAP Encoding • Με το SOAP Encoding μπορούμε να ορίζουμε τύπους δεδομένων στο SOAP μήνυμα. • Το SOAP Encoding δηλώνεται στο Envelope με το encoding. Style και είναι προαιρετικό. • <soap: Envelope xmlns: soap="http: //www. w 3. org/2001/12/soap-envelope" soap: encoding. Style="http: //www. w 3. org/2001/12/soap-encoding"> 18/5/2010 Δικτυακός Προγραμματισμός 39
Παραπομπές • SOAP Resources: http: //www. develop. com/soap • SOAP Specification: – http: //www. w 3 c. org/2002/ws/ – http: //www. msdn. microsoft. com/xml/general/soapspecv 1. asp • “XML Manifesto, ” by Don Box, – http: //msdn. microsoft. com/workshop/xml/articles/xmlm anifesto. asp • http: //msdn. microsoft. com/vstudio/nextgen/langau ge. asp 18/5/2010 Δικτυακός Προγραμματισμός 52
Παραπομπές • “A Young Person’s Guide to the Simple Object Access Protocol, ” by Don Box • http: //msdn. microsoft. com/msdnmag/issues/0300/ soap/soap. asp • “Professional XML, ” by Mark Birbeck, et. al. , Wrox Press • Apache Axis: http: //ws. apache. org/axis 18/5/2010 Δικτυακός Προγραμματισμός 53
- Slides: 53