510 likes | 647 Views
CSG Mini-Workshop: Web Services. Justin Tilton instructional media + magic, inc. As presented at the Common Solutions Group Meeting May 9, 2002 Chicago, Illinois. Overview. Data XML Validation Schema Transport SOAP Security SAML Description WSDL Directory UDDI
E N D
CSG Mini-Workshop: Web Services Justin Tiltoninstructional media + magic, inc. As presented at theCommon Solutions Group Meeting May 9, 2002 Chicago, Illinois
Overview • Data XML • Validation Schema • Transport SOAP • Security SAML • Description WSDL • Directory UDDI • Transformation XSLT
XML is for structuring data [1] • Structured data includes things like: • spreadsheets, address books, configuration parameters, financial transactions, and technical drawings • XML is a set of rules for designing text formats that let you structure your data. • XML is not a programming language, and you don't have to be a programmer to use it or learn it
XML is for structuring data [2] • XML makes it easier for a computer to generate data, read data, and ensure that the data structure is unambiguous • XML avoids common pitfalls in language design: • it is extensible • it is platform-independent • and it supports internationalization and localization
XML is a family of technologies [1] • XML 1.0 is the specification that defines what "tags" and "attributes" are • Xlink describes a standard way to add hyperlinks to an XML file • XPointer and XFragments are syntaxes in development for pointing to parts of an XML document • XSL is the advanced language for expressing style sheets. It is based on XSLT
XML is a family of technologies [2] • XSLT is a transformation language used for rearranging, adding and deleting tags and attributes • XPath is a language for navigating in an XML document • XML Schemas help developers to precisely define the structures of their own XML-based formats. • XQuery provides flexible query facilities to extract data from real and virtual documents on the Web • XML Signatures provide integrity, message authentication, and signer authentication services for an XML document
XML is new, but not that new • Development of XML started in 1996 and has been a W3C Recommendation since February 1998 • Before XML there was SGML, developed in the early '80s, and widely used for large documentation projects • The development of HTML started in 1990. • The designers of XML simply took the best parts of SGML, guided by the experience with HTML, and produced something very powerful
HTML and XHTML • The successor to HTML is XHTML • XHTML has almost all of the same elements as HTML, but the syntax has been changed slightly to conform to the rules of XML • XHTML allows "<p>", but not "<r>" since <p> is defined in XHTML and <r> is not • XHTML says that "<p>" stands for "paragraph", and not for "price", "person", or anything else • Emerging applications such as uPortal are using XHTML to output content to browsers
XML has namespaces • To eliminate name confusion when combining documents, XML provides a namespace mechanism • XSL and RDF are good examples of XML-based formats that use namespaces • XML Schema is designed to support modularity by defining XML document structures, making it easy to combine two schemas to produce a merged document structure.
XML is license-free • XML is license-free, platform-independent and well-supported • A large and growing community of tools and engineers experienced in the technology • Since XML is license-free, you can build your own software around it without fees
An example of XML [element] <?xml version="1.0"?> <breakfast_menu> <food> <name>Belgian Waffles</name> <price> <amount>5.95</amount> <currency>US Dollars</currency> </price> <description>two of our famous Belgian Waffles with plenty of real maple syrup</description> <calories>650</calories> </food> <food> <name>Strawberry Belgian Waffles</name> <price> <amount>7.95</amount> <currency>US Dollars</currency> </price> <description>light Belgian waffles covered with strawberries and whipped cream</description> <calories>900</calories> </food> </breakfast_menu>
An example of XML [attribute] <?xml version="1.0"?> <breakfast_menu> <food> <name>Belgian Waffles</name> <price currency="US Dollars">5.95</price> <description>two of our famous Belgian Waffles with plenty of real maple syrup</description> <calories>650</calories> </food> <food> <name>Strawberry Belgian Waffles</name> <price currency="US Dollars">7.95</price> <description>light Belgian waffles covered with strawberries and whipped cream</description> <calories>900</calories> </food> </breakfast_menu>
What is an XML Schema? • XML Schema is an XML based alternative to Document Type Definition (DTD) • The purpose of an XML Schema is to define the legal building blocks of an XML document, just like a DTD.
An XML Schema defines: • Elements and attributes that can appear in a document • Simple child-parent element relationships • The sequence in which the child elements can appear • The number of child elements • Whether an element is empty or can include text • Data types for elements and attributes • Default values for elements and attributes
XML Schemas replacing DTDs • We think that very soon XML Schemas will be used in most Web applications as a replacement for DTDs. Here are some reasons: • XML Schemas are richer than DTDs • XML Schemas are written in XML • XML Schemas support data types • XML Schemas support namespaces • XML Schemas are extensible to future additions
XML Schema & Data Types • With data type support it is easier to: • Describe permissible document content • Validate the correctness of data • Work with data from a database • Define data facets (restrictions on data) • Define data patterns (data formats) • Convert data between different data types
Why Schema is important • A well-formed XML document is a document that conforms to the XML syntax rules • Even if documents are Well-Formed they can still contain errors, and those errors can have serious consequences. • With XML Schemas, most of these errors can be caught by your validating software.
The simplest element definition • A schema specifies a set of valid top-level elements. • In the simplest case, we can define an element to describe a name of the city: Schema: <xsd:element name="city" type="xsd:string"/> Document: <city>Washington</city>
Another element definition • A schema specifies a set of valid top-level elements. • Complex types can define elements with children: Schema: <xsd:element name="note"> <xsd:complexType> <xsd:sequence> <xsd:element name="to" type="xsd:string"/> <xsd:element name="from" type="xsd:string"/> <xsd:element name="heading" type="xsd:string"/> <xsd:element name="body" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:element>
Another element definition • A schema specifies a set of valid top-level elements. • Complex types can define elements with children: Document: <note> <to>Sam</to> <from>Jack</from> <heading>Your presentation</heading> <body>Please update section II</body> </note>
What is SOAP? • SOAP is an XML based protocol to let software components and applications communicate using standard Internet HTTP • SOAP stands for Simple Object Access Protocol
SOAP is: • A communication protocol • For communication between applications • A format for sending messages • Designed to communicate via internet • Platform independent • Language independent • Based on XML • Simple and extensible • Remote procedure call protocol • SOAP will be developed as a W3C standard
Why SOAP? • SOAP is Transport Protocol independent • Transport protocol chosen according to network architecture and type of exchange • Real time over the internet might use HTTP, where a batch processing application might use SMTP • SOAP provides a way to communicate between applications running on different operating systems, with different technologies and different programming languages
SOAP was Proposed • UserLand, Ariba, Commerce One, Compaq, Developmentor, HP, IBM, IONA, Lotus, Microsoft, and SAP proposed SOAP to W3C, in May 2000 • The ebXML Plenary voted on 16 February 2001 to use SOAP 1.1 and SOAP With Attachments as part of the ebXML transport specification • Anyone using the transport portion of ebXML will therefore be using SOAP
SOAP Building Blocks • A SOAP message is an ordinary XML document. • The XML document contains the following XML elements: • A SOAP envelope, that defines the content of the message • A SOAP header (optional), that contains header information such as credentials • A SOAP body, that contains request and response information
Syntax Rules • A SOAP message: • Must be encoded using XML • Must have a SOAP envelope • Can have a SOAP header • Must have a SOAP body • Must use the SOAP envelope namespaces • Must use the SOAP encoding namespace • Must NOT contain a DTD reference • Must NOT contain XML processing instructions
SOAP Request Example <soap:Envelope> <soap:Body> <GetPrice> <Item>Apples</Item> </GetPrice> </soap:Body> </soap:Envelope>
SOAP Template <soap:Envelopexmlns:soap="http://schemas.xmlsoap.org/soap/envelope/“soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> <soap:Header>…</soap:Header> <soap:Body>…</soap:Body> <soap:Fault>…</soap:Fault> </soap:Envelope>
The Envelope Element • The <Envelope> element must be the root element of a SOAP message • It defines the XML document as a SOAP message.
The Header Element • The <Header> element can contain additional, application specific information about the SOAP message • For example, the Header element can contain information about the language and currency values used in the SOAP message • Optionally, the header can carry authorization & authentication information
The Body Element • The <Body> must be present in a SOAP message • It contains the actual SOAP message or “payload”
A SOAP Example [1] • The SOAP request: <soap:Envelope> <soap:Body> <xmlns:m="http://www.stock.org/stock" /> <m:GetStockPrice> <m:StockName>IBM</m:StockName> </m:GetStockPrice> </soap:Body> </soap:Envelope>
A SOAP Example [2] • The SOAP response: <soap:Envelope> <soap:Body> <xmlns:m="http://www.stock.org/stock" /> <m:GetStockPriceResponse> <m:Price>34.5</m:Price> </m:GetStockPriceResponse> </soap:Body> </soap:Envelope>
SAML Assertion <SAML> <AssertionID> http://www.bizexchange.test/assertion/AE0221 </AssertionID> <Issuer>URN:dns-date:www.bizexchange.test:2001-01-03:19283 </Issuer> <Conditions> <Audience> http://www.bizexchange.test/rule_book.html </Audience> </Conditions> <Subject> <Account>Alice</Account> </Subject> <Resources> <string>http://www.elsevier.com/Journal_X/</string> <string>https://www.SantaMariaUniversity.edu/SIS/</string> </Resources> </SAML>
Building web services • Web services architecture overview 2 find UDDI Service Web service requestor look up web service 3 bind 4 call Call Web Service 1 publish Retrieve WSDLDefinition Register Web Service(at development time) Web service provider WSDL Document
WSDL • Web Services Description Language • Language describing what services are available and how they can be accessed • Messages being sent • End-points for message processing • WSDL makes it easy for client applications to use a web sevice
WSDL • WSDL document structure <definitions> root element <types/> data type definitions <message/> abstract message definitions <portType/> set of abstract operations <binding/> protocols for a portType <service> grouping of related ports <port/> network address for a binding </service> </definitions>
UDDI • Universal Description, Discovery and Integration • A web services registry system • White pages – general information • Yellow pages – service classifications • Green pages – operation rules
businessEntity businessKey name URL description contacts businessServices identifierBag categoryBag UDDI: Registry organization contact phone address e-mail keyedReference tModelKey keyName keyValue businessService serviceKey tModelKey name description bindingTemplates keyedReference tModelKey keyName keyValue
Registry API Find methods find_business find_service find_binding find_tModel Get methods get_businessDetail get_serviceDetail get_bindingDetail get_tModelDetail Inquiry API Save methods save_business save_service save_binding save_tModel Delete methods delete_business delete_service delete_binding delete_tModel UDDI: SOAP API
Meteor in a nutshell… Lender XML
Diagram of Meteor Concept Web Services HTML Meteor XML Student Access Provider Data Provider
As implemented ... Web Services Secure HTML Meteor Secure XML Standard Browser uPortal Meteor SOAP Meteor SOAP Database