Copyright 2001, ActiveState
XML Protocols
Copyright 2001, ActiveState
Protocol Definition
• “A set of formal rules describing how to transmit data, especially across a network.”
• “High level protocols deal with– data formatting,– Including syntax of messages,– character sets,– sequencing of messages etc.”
http://foldoc.doc.ic.ac.uk/
Copyright 2001, ActiveState
Protocol Background
• Protocols build on each other (e.g.):– XML-RPC (remote procedures) builds on– HTTP (web) which builds on– TCP (reliability, connections) which builds
on – IP (routing, packets) which builds on– Ethernet (sends bits over wires)
Copyright 2001, ActiveState
Why XML Protocols?
• An XML-based protocol automatically “inherits”:– A large code-base of XML parsers and
other tools– A mechanism for representing structured
information– Unicode support
Copyright 2001, ActiveState
Why So Many XML Protocols?
• Different tradeoffs.
• Often independently invented.
• Some will merge.
• Some will fall into disuse.
• Welcome to the cutting edge!
Copyright 2001, ActiveState
Web Services Vision
• In the future, we want computers to talk to each other more and more…
• about more and more complicated stuff!
• Automated purchases, auctions, research etc.
Copyright 2001, ActiveState
Web Services and Protocols
• We are going to have to be able to create new protocols more quickly than ever before!
• XML allows us to create a new data representation vocabulary quickly
• “Protocol frameworks” build on XML to do the same thing for protocols.
Copyright 2001, ActiveState
Protocol Frameworks
• XML is a markup language
• …but a specific vocabulary like XHTML or VoxML is also called a markup language
• Similarly, SOAP and other protocol frameworks are generic protocols that can be used to build more specific protocols
Copyright 2001, ActiveState
Comparison Criteria
• Good criteria come from this W3C web page:
http://www.w3.org/2000/03/29-XML-protocol-matrix
Copyright 2001, ActiveState
Comparing Sync/Async
• Synchronous: sender and receiver are alternately in the “listening” or “sending” mode – like a traffic light.
• Asynchronous: information can arrive any time – like a corner with no stop sign
Copyright 2001, ActiveState
Examples
• Synchronous: “Web site contacted…waiting for reply.”
• Asynchronous: telephone call.
• Synchronous: “That will be $5.00. Here’s your food.”
• Asynchronous: “Alert: Your stock just tanked!”
Copyright 2001, ActiveState
Comparing Extensibility
• Some protocols are problem-domain specific.
• Others are meant to be the generalized basis of other protocols.
• All of them are designed with some “primary domain” in mind: that often explains why they are different.
Copyright 2001, ActiveState
Comparing Data Typing• If the protocol is intended to be a basis for
others:– Are data-types inline or out-of-line?– Can you directly represent arbitrary data
structures?
• Type definitions are not strictly necessary but they ease the integration of protocols with programming languages and databases
Copyright 2001, ActiveState
Comparing Associated Schemas
• Is there a schema for the protocol interactions themselves?
• Can you refer to a data typing schema?
Copyright 2001, ActiveState
Comparing Packaging
• Explicit support for packaging non-XML information?
• You can always embed Base-64 information in XML but that is inefficient.
• Some protocols describe how to handle multiple parts and refer between parts using links.
Copyright 2001, ActiveState
Jabber
• Jabber is designed for XML-Based “Instant Messaging”
• It’s creators promote it as a basis for all sorts of XML-based messaging.
• Any XML namespaces can be used within it! • e.g. BizTalk messages embedded in Jabber streams.
Copyright 2001, ActiveState
Jabber
Copyright 2001, ActiveState
Jabber & Instant Messaging
• Jabber is in-use today but is not (yet?) as popular as proprietary messaging systems.
• Jabber’s primary distinguishing characteristic is its open architecture.
Copyright 2001, ActiveState
Jabber Specs
• Namespace-based extensibility
• Defines long-lived XML streams
• Primarily Async
• Doesn’t define any type system
• Can be used for Remote Procedure Calls (with a little extra code)
Copyright 2001, ActiveState
Jabber Streams
• single, persistent XML stream• running on a single socket
<stream:stream to="jabber.com" xmlns:stream="http://etherx.jabber.com/streams">
(entire long-lived session is conducted)</stream:stream>
Copyright 2001, ActiveState
Jabber “Identity”
• Things in Jabber with identities are known as “entities”:– Users– Chatrooms– “Proprietary” message systems (ICQ)– …
Copyright 2001, ActiveState
Jabber “Messages”<message to="[email protected]"><subject>Testing</subject><body>This is just a test message</body></message> • <subject> – subject line• <body> – text of the message (arbitrary
XML)• <x> – register a Jabber extension• <error> – error message• <thread> – some identifying string
Copyright 2001, ActiveState
Jabber “Info/Query”
• Info/query is a way of doing RPC-like things in Jabber
• You send out an info/query “request” with an “iq” element.
• The “iq” element is sent out
• If there is a result, it comes back through another “iq” element
Copyright 2001, ActiveState
Info/Query types
• Outgoing:– “get” – get some information– “set” – set a value
• Returning:– “result” – a return value– “error” – the query failed
Copyright 2001, ActiveState
Jabber Extension
• Jabber is somewhat informally specified.
• If you define a protocol “based on” Jabber, it isn’t clear how you would specify – types, – expected responses,– etc.
Copyright 2001, ActiveState
Jabber Info
• http://www.jabber.org
• http://www.jabber.com
• http://protocol.jabber.org
Copyright 2001, ActiveState
XML-RPC
• Request/response-type (sync) protocol
• Deployed and in use!
• The original XML-based RPC protocol
• Still the easiest way to do cross-language, cross-platform RPC!
Copyright 2001, ActiveState
XML-RPC Specs
• Based on HTTP
• Supports a fixed set of hard-coded types and data structures.
• Does not directly support more structured types.
Copyright 2001, ActiveState
XML-RPC HTTP Header
POST /RPC2 HTTP/1.0 User-Agent: Some Client SoftwareHost: betty.userland.com Content-Type: text/xml Content-length: 181
Copyright 2001, ActiveState
Example Message
<?xml version="1.0"?> <methodCall><methodName>getStateName</
methodName><params><param><value><i4>41</i4></
value></param> </params> </methodCall>
Copyright 2001, ActiveState
methodCall
• There is always one methodCall element.
• It always contains methodName element.
• There is typically a params sub-element.
• The params element always contains one or more param elements.
• Each param has a value.
• Parameters are not named.
Copyright 2001, ActiveState
Basic Value Types
• <i4> or <int>– four-byte signed integer (e.g. –12)
• <boolean>– 0 (false) or 1 (true)
• <string>– ASCII string (e.g. hello world)
• <double>– double-precision signed floating point number
(e.g.-12.214)
Copyright 2001, ActiveState
More Basic Types
• <dateTime.iso8601>– date/time– (e.g. 19980717T14:08:55)
• <base64>– base64-encoded binary– (e.g. eW91IGNhbid0IHJlYWQgdGhpcyE=)
Copyright 2001, ActiveState
Structures
• Structures<struct><member> <name>lowerBound</name>
<value><i4>18</i4></value></member><member> <name>upperBound</name>
<value><i4>139</i4></value></member></struct>
Copyright 2001, ActiveState
Arrays
<array><data><value><i4>12</i4></value><value><string>Egypt</string></value><value><boolean>0</boolean></value><value><i4>-31</i4></value></data></array>
Copyright 2001, ActiveState
Extensibility
• XML-RPC is extensible in that you can define different method names and they can have different parameters
• New data types and data structures are not supported.
• Namespaces are not supported.
Copyright 2001, ActiveState
SOAP
• In use (e.g. at ActiveState!)
• Can be used synchronously or async
• Type names can be inline or out-of-line
• Namespace-based extensibility
• Higher level protocols definable in Web Services Description Language
• Types come from W3C Schemas
Copyright 2001, ActiveState
What Does SOAP Define?
• Standard expression for – message envelopes– headers– bodies
• Standard encoding rules for structured data
• RPC mechanism
Copyright 2001, ActiveState
SOAP Generality
• You may – use any XML content as payload.– use SOAP in a sync RPC model or any
other model.– Use SOAP object encoding with or without
envelopes and RPC.
Copyright 2001, ActiveState
Scope
• SOAP leaves various issues to other specs:– datatypes (XML schemas)– discovery (UDDI)– service description (WSDL)– security (SSL, https, …)
Copyright 2001, ActiveState
SOAP HTTP Header
POST /StockQuote HTTP/1.1Host: www.stockquoteserver.comContent-Type: text/xml; charset="utf-8"Content-Length: nnnnSOAPAction: "Some-URI"
Copyright 2001, ActiveState
SOAP XML Header
<SOAP-ENV:Header>
<myns:From>MarkH</myns:From>
<myns:To>DickH</myns:To>
<myns2:Subject>Beer</myns2:Subject>
</SOAP-ENV:Header>
Copyright 2001, ActiveState
SOAP Body
The SOAP body is syntactically just like the header.
<SOAP-ENV:Body>
<myns:Date>Wed, 20 Sep 2000</myns: Date>
<myns:From>[email protected]
</myns:From> …
</SOAP-ENV:Body>
Copyright 2001, ActiveState
SOAP Information Encoding
• Header and body entries are arbitrary XML.
• XML has no data types or data structures other than “string” and “tree”.
• SOAP defines some conventions that allow a few more data structures.
Copyright 2001, ActiveState
SOAP Types & Structures
• “Simple value” – a primitive type
• “Compound value” – structured type
• “Arrays” – compound values indexed by position
• “Structs” – compound values indexed by “role name”
• … a little more complicated than it seems…
Copyright 2001, ActiveState
SOAP Types
• SOAP does not define primitive types.
• You may use XML Schema or other.
• Elements can be type-declared– “out of line” in a schema or – “inline” using xsi:type attributes
Copyright 2001, ActiveState
Service Description
• Web Service Description Language (WSDL) describes Web Services
• With WSDL, web service providers can formally describe what services they provide.
• WSDL is a sort of “schema for protocols.”
• Somewhat similar to IDL for COM/CORBA
Copyright 2001, ActiveState
WSDL Deployment
• WSDL is not widely deployed yet
• In particular, hampered dependence on W3C XML Schema Definition Language (XSDL or “XML Schemas”)
• WSDL may not be widely deployed until schemas are.
Copyright 2001, ActiveState
UDDI
• UDDI defines – vocabulary for registering organizations
according to the services they provide.
– SOAP messages for publishing this information.
– SOAP messages for querying repositories.
Copyright 2001, ActiveState
XP: XML Protocol Activity
• “The goal of XML Protocol is to develop technologies which allow two or more peers to communicate in a distributed environment, using XML as its encapsulation language”
• Formally standardizing SOAP
Copyright 2001, ActiveState
ebXML Message Service
• An extension to SOAP for electronic business– Security– reliability
Copyright 2001, ActiveState
WebDAV
• Not a general-purpose “generic” protocol
• Designed specifically for web-based content management
• With WebDAV, it would be possible to directly “edit” pages on the web (with appropriate permissions)
Copyright 2001, ActiveState
BizTalk
• Built on SOAP
• BizTalk is basically a higher-level protocol specific to business commerce
• BizTalk is controlled by Microsoft.
• Many see it as a competitor to ebXML.
Copyright 2001, ActiveState
Summary
• Most new protocols will be based upon XML.• Some, like WebDAV, use XML “directly”
• Others build on generic XML Protocol “frameworks” like SOAP and the ebXML Messaging Service
• Either way: XML Protocols are here to stay!
Copyright 2001, ActiveState
Resources
[email protected] (that’s me!)
http://www.activestate.com/Initiatives/WebServices/index.html
http://www.w3.org/2000/xp/
Top Related