Configure player

Close

WWDC Index does not host video files

If you have access to video files, you can configure a URL pattern to be used in a video player.

URL pattern

preview

Use any of these variables in your URL pattern, the pattern is stored in your browsers' local storage.

$id
ID of session: wwdc2002-704
$eventId
ID of event: wwdc2002
$eventContentId
ID of session without event part: 704
$eventShortId
Shortened ID of event: wwdc02
$year
Year of session: 2002
$extension
Extension of original filename: mov
$filenameAlmostEvery
Filename from "(Almost) Every..." gist: ...

WWDC02 • Session 704

XML in WebObjects

WebObjects • 57:28

Learn about XML integration with WebObjects, such as object serialization, archiving, parsing, as well as other practical uses of XML. This session demonstrates the use of the upcoming XML serialization feature and XSLT to create XML documents.

Speakers: Bob Frank, Mike Brumbelow, Han-Ming Ong

Unlisted on Apple Developer site

Transcript

This transcript was generated using Whisper, it may have transcription errors.

Our next session this afternoon is XML and Web Objects. I'd like to introduce Bob Frank, who's going to give the presentation for this session. Bob? Thank you, Tony. Okay. Hold on. There's the clicker. Good afternoon. Welcome to XML and WebObjects. Today, we're going to cover a wide variety of materials so that you can get familiar with what is XML, how to use it in WebObjects, and why you should be using it. Han Ming is going to cover the basics of what XML is, what are the key concepts, and basically give you an overview if you're not familiar with it. Also, he'll discuss serialization of... using XML to read and write simple configuration files, which is a very common use of XML. Also, we will be discussing serialization of EOs. Slightly more sophisticated, but using the same approach as you use for reading and writing files is serializing EOs into XML and also using XSLT, which is XML-style transformations, which allow you to transform one XML document into another XML document.

Lastly, we'll be discussing a very popular way of using XML to communicate between servers, XMLRPC. We'll discuss what it is, how to use it, and compare and contrast it with SOAP. You'll see the letter X so many times in this session that you'll probably be sick of it. And without further ado, Hanming?

there you go, this button. Good afternoon. My name is Han Ming-Ong. I'm in the engineering team. And I'm going to give you a quick refresher on XML. I have 10 to 15 minutes, so I'm going to assume that you have done some XML work before. So I'm going to give you some definition, basic definitions of XML, followed by constraints, so that it can make sense out of XML data. There are two main specifications. Sorry about that. Right here?

Okay. So there are two main specifications for doing constraints. One is document types definition, DTD, and schema. So as Bob mentioned, with XML technology, there's a proliferation of acronyms. So my advice is don't worry too much about the letters, but try to understand the meaning behind them. Then I'll talk about processing of XML data, which means the producing and the consumption and the consuming of XML data using low-level APIs like DOM, DOM, SAX, and JXP.

then i'm going to be a list of populous that one would use to our parts and consume xml data Yeah. So what is XML? Essentially, XML is structured data that always has the same fixed synthetic formation. It is always hierarchical and tree-like form, which means for developers like us, we worry a lot less about the how of extracting information out of it.

and because it is organized so it is for me up a date layman to read as well that's one of the goals of xml the other goals of the other great goal of xml is that it should be portable and the reason why it is portable is because it encodes the data as text a piece of text string is the same across different development platforms and languages and not only is it in text that it accept unique characters that means all the languages in the world can be can be written in XML and it puts the encoding right at the top in the declaration so that most of the time you don't have to apply heuristics to try to understand it The next slide I'm going to show you is a simple XML document so that you have a feel of it.

so the first line they see is that what we call the actual declaration the version is one point zero the w_ three cc organization did a good job so i put two two years or so is to one point zero they may wrap it up soon one point one the deco the encoding that we see here is unique you t_f_ eight which is a good default encoding for your you know if you have just have english uh... you can you can and don't put it down i can put as u_s_ esky they'll be the passing a lot faster Thank you.

here in this action of document we see a root element copper chase order the starting tag is a line three the ending tax is a line ten This root element has two char, comment and item. And here it has an attribute called order date. Attributes may or may not be required. When it's present, it usually means metadata.

and to illustrate the fact that you can have you could character i put in some chinese character which i'm sure all of you understand OK. This thing right here. I figured it out. Linking at me. Constraints. The above XML document that we just saw adheres to a concept called well-formedness that is defined by the basic XML 1.0 specifications it says, the basic rules say stuff like you must have one and only one root element in an XML document and every element must have an opening tag and an ending tag there are many exceptions to it validity as a contract of structure between the producer and the consumer of the actual data producer of the actual out there i would say stop something like expect to see the root elements purchase order having a child in man to child in man's comments and i can the contract of structure varies across domains and industry so when one say that an XML document is valid it is always always with respect to a contract and the structural contract is defined in two ways more than two ways but the two most common ways is using DTD document depth definition and schemas so document type definition that's rude way that in s_g_m_ l wall and so for some of us we've worked with x just works out what the tax amount you may find this a the syntax a bit weird to some of the old timers out there now is very natural so you still have to publish your contract in d_t_d_ The two main deficiencies with DTD, unfortunately, is that it doesn't have a typing facility. Bye. and that it doesn't work naturally with namespace. Now, words in English, common words in English, are very important to some domains, and they are common. So you have to have namespace to avoid the name conflict, just like packages or namespace in C++.

so in the next flight i'm going to show you an example simple example of a d_t_d_ the constraints the x_ and i'll be out of the saw you on i don't need to focus too much into it but just now you you find it with So what it says here is you might find an element called purchase order, and it must have two child elements in sequence, comment, and item. And it must have an attribute called order date, and it must be a parsed data. So on and so forth.

schema the same grand goals as d_t_d_ except that now it is that's remain differences the first one is is written in xml which means for most of us are familiar with xml easy you can you can use a favorite xml editor create your schema file and have it validated across uh... not the schema schema schema and soft to me problems of course the at typing you can have the basic system types like string integer and so on and so forth and even customize types which means in schema files you can put in stricter permissible the content which can be validated and it was very naturally with namespace so in the next slide i'm going to show you an example of a schema file constraints the same XML data despite slightly more verbose you will find it as intuitive i highlighted using colors to show you the sections i want to talk about red collar is the prefix of a name space you can call the critics anything so in this case the prefix is linked wouldn't do a name space namespace has a one-to-one relationship with the URI. In this case, our URI is an URL, www.apple.com/publications. So the prefix which I chose to use is Apple. If you focus on the gold color now, these are just the elements. We've seen that before. Purchase order must have two child in sequence, two children in sequence. The first child is comment. The second child is item.

and the green colors are the data types i've mentioned before string in this case is a basic data type is great that you know that the b_ three c_ actually study quite a lot of languages to find some common system type integer boolean is very similar to split similar to java so it's very easy for us to use and can customize the type as well of course so at this point i'll take a little pause, a little breather for me and for for some of you out there to remind ourselves what XML is not really So a contract of structure is just what it is. There's no semantics in it.

It doesn't explain what purchase order is. What that means is the producer of the XML data has to talk to the consumer of the XML data to explain to her what the XML elements are. What the producer of the XML data usually does is put the semantic explanation in the DTD or in the schema file. so you still have to talk to achieve interoperability the second thing is that and a piece of xml data structured tax data you still have to find domains for end users for it some of the users that we've seen out there is storing xml configuration information and to uh... do content publishing you store xml your data as xml then you apply transformation to get wml html or even binary formats like PDF and of course a lot of companies including Apple uh... WebObjects uh... is leveraging XML to build web services whatever that means so we move on to processing of xml data this set of low-level api's is called document object model document object model has been used again in the sgml world and way back to model any documents not only xml those of you in the audience who have worked with html browsers must have seen DOM models of html before so it is a very general tree structure for me at least and for some of you most of you out there you probably use it for producing xml data serialize it out It is less useful parsing because it is pretty memory intensive. It builds the entire object tree and let you manipulate from then. There's another low level API that allows you to do parsing. And most people like this simple API for XML.

It is faster than DOM because it is very sequential. It starts at the very top, look at the first element, and it generates standard callbacks that you're supposed to implement and handle. it maintains a very little state information and hence extremely lightweight which is good for parsing Thank you.

Jack's P. This is neither sex nor dom, but it is an abstract layer that Sun provides for you to instantiate parsers and transformers so that you can easily plug in transformers and parsers from different vendors. I would advise you to start using it if you have not. This will make your code more portable, and you can choose parsers depending on their performance and functionality and speed.

so next slide will show you a list of parcels that you can you know choose and if you have Jack's P you can plug and play the Xerces parser very popular sans crimson parser is going to be included in 1.4 was already included and i get it down posture and just to illustrate that it'll be a lot of your approaches as well jim clock has a pretty reputable posture which i think is fast Okay, I'm going to switch gear now and talk about the integration of XML technology with WebObjects. I'm finished with the refresher so the XML expert can wake up.

so we're gonna ship uh... deserts is to pass her and silent to transformer in the job action now before we used to we plan have to say this we plan to ship versus two and that into in the current web objects we only have the services one pastor but we have noticed that all developers that using a battle to transform anyway so we want to put the ticket and synchronization of versions as you so you up Out there my node is very important, so we keep them synchronized.

that support at the lower eighty i level at the slightly higher the p_i_ level we have to serialization schemes for web objects the first one is some of you may have used it works in the cold and the quarter and we plan to support a new one call and that's xml input and output stream so let's talk about them what's a local and the quarter we like to deprecate them feel following the philosophy of deprecating aligning our civilization a_p_i_'s with java e_p_i_'s now the analogy here is uh... and escorting versus the rise of all we used to have an escorting which is a not more objective see way of doing so binary civilization made the transition in what objects five to civilizable so we'd like to follow that and deprecate all xml code in decoder following that deprecation we'll be saying goodbye to our mapping file the non-standard mapping file that we use for transforming xml data and say hello to XSLT My colleague, Mike Brumbelow, he will talk more about XSLT transformation later on.

now access out he is industry standard that is not became a recommendation by the b_-three c about a year ago i think and it is good because knowledge is very portable once you learn let excel p you can use a knowledge in objective c and and c_-plus-plus or even microsoft and i a different platforms not if you already accept excel t expert you can apply the knowledge immediately So the new XML serialization scheme, for the most part, is going to be as easy as the binary serialization, because it follows the basic binary serialization rules. What that means is classes, they already implement serializable. You get-- they become XML serializable for free.

this is because the classes that does this realization xml in the stream and i'll be streamed the up built on top of the respective i'll classes instead of instantiating object output stream you instantiate object nsxml output stream you write out the object and vice versa for nsxml input stream so the web objects that's the heavy lifting of figuring out what should be sterilized and as i say they follow the basic sterilization rules what that means is non-transitive non-static data members becomes realizable and if you want to be in fancier you overwrite the two methods the write and read object customize them they'll be called and by lining our eight p_i_'s with the job i must be standard the serializable interface we make our eight p_i_ small billable to job developers well-earning web objects and job about this or more familiar with the uh... survival interface So here is the default XML output of a serialized object. I want you to focus in the middle part, because the rest are just namespace and stuff.

we have a sterilized object this first trial is a class structure most of us were focusing on a content part of it can not those of you guys who wants to know the class structure it is there for you I'm gonna skip to the content. It just says that this object has a field called first name. And it is of data type string. And the content is just Mike. Now, this, this is, this is, this is This XML content is actually deserializable to become a person object in memory if you use an XML input stream. Thank you. So here is an example of how to write out that particular object.

You must have seen this before if you have used serialization, binary serialization, the last two lines at least. You instantiate an object, an NSXML output stream. You write out the object, and you close it. That's it. Now I want you to focus hard on the next slide because it's going to be really complicated for reading it in.

That didn't go well. It went well during rehearsal. It's supposed to be a joke. So again, you instantiate an NSXML input stream. You read the object in, the XML data in. You pass it to your class, and then you close it. That's it. Good, I'm doing pretty well on time. So I'm going to give you a demo now, demo two.

on using uh... the new serialization scheme to do configuration now one word about storing xml is configuration now as i said earlier on because the basic structure of xml is always the same so storing xml data is storing configuration data into xml is becoming more popular you see it in ant and almost everywhere in tomcat this is because people worry a lot less about the extracting of it they worry more about what you're going to do with the data compare this with make files where you know it attack is actually a very important delimiter mister tap you make phone compile or in the apache configuration where the new line is important delimiter as well So here, I'm going to make use of an example that was shipped with WebObjects 5, so that you're familiar with it. It's create plot. Create plot is a very simple example that shows you how to make use of the plotting APIs to create graphs. And there are three kind of graphs. One is based on floating point number. The other one is based on string. And the last one is based on date. We hard coded the example when we shipped it, so that it always started with the floating point example. I've already run it. And let me bring up YE.

So this is the example that started up when you first run it. And it just plots a graph of floating point. And you can illustrate there are three kind of graphs-- floating point, date, and string. So when the application started up, it writes out a configuration file, which I'm going to show you.

this is the x_m_l_ configuration file it is similar to that some of the other we saw early on i added a comment i'll show you how to do it on this changes value to configure the starting plot and i think i'm gonna change it to object creating session so you shouldn't come soon and there you go it is a new law c_c_ object it is not that based on string and let me change it again to that to date have a new application so if a new plot based on so i mean imagine i mean is fair who just concerned about changing the configuration file and doesn't have a web of x application she can go in and change the x_m_l_ file and the next on the session comes in you have a new plot so now i'm going to go to the and walk you through it briefly I created a class called start config, and I made it serializable. And I'm following the rules of serialization, binary serialization. I created a variable, instance, a member variable called starting plot.

make sure it's not sensitive and non-static and because i had a i wanted to customize it by adding a comment if you don't let a comment you'd you don't have to customize over either read the right object method I have a couple of utility methods to help me create it. Those are, this are the stuff you saw earlier on. Write an object and close it.

And this is the creation of the class. And here, what I did was, I customize it so that the session itself gets out gets up but as of on a per session basis you can put this method in application and becomes application white and last in the main so instead of her coding it in main and I'll get it from the session That's it. So with that, I'm going to bring up Mike. He's going to talk about serialization of EOs using the new XML serialization scheme. And he's going to talk about transformation as well, XSLT, one of my favorite topics. Mike, please. Thank you. Thank you. Hopefully this isn't the daemon clicker. Hi, my name is Mike Brumbelow, and today I'll be talking about EOX mal-serialization and XSLT.

The good news about EO XML serialization is that it's easy as pie. You give us a collection of EOs, and we go through, and using NSXML output stream, we serialize it out for you. And using NSXML input stream, we read that back in for you. Now, concerning managing your object graph, the good thing is that as a part of the serialization process, we don't fire off any faults. So the objects you give us are the objects you serialize out. We don't fault any objects in.

Let me demo this for you here. I wrote an application. And on demo one, please. I wrote an application that takes an RSS document. And RSS stands for RDF Site Summary. And RDF stands for Resource Description Framework. It's a way of describing content information for a site. And a lot of news sites vend this kind of document out to the public, and you can use it to read news and information. And I wrote an application that goes out pulls out this document, and we'll display it on the screen here. Where are you at? There you go. Now I'm going to launch it.

Okay. I'm going to select a site to look at. I'm going out and fetching the RSS document, and it's an XML document. Going through and displaying all the links, information associated with that site, the different news today. Let's see, is there anything here for us? Okay. Let's go to Wired. Is there anything here concerning us? Any news? The last one, where's that at? Hmm, let's look at that.

Interesting. So, you know, we can navigate and look at the different news articles and everything underneath there. So let's go back to CNETnews.com. Now, when I press this button at the bottom here, save articles, that's going to go out. It's going to fetch that XML RSS document. It's then going to save it out to the database. And then from there, it'll convert it into EOs and save it out to the database. And then from there, we're going to then serialize those EOs out to the file system. magically it happens. So let's go look at the document that gets generated here.

And as you can see-- wow, there's a lot of stuff there. Really, no data is serialized out. Basically, references to our data. And you can see in here, for instance, we've actually serialized out-- let me highlight that for you-- the editing context and some of the other EOs as well. It's a nice little long document.

close that out. Now the next thing I'm going to do is navigate to the next page and from here we're going to deserialize and bring all of those EOs back into the application and display the links again. It's just that fast. And we'll click on an item. Voila. - And let's look a little bit of code here to see how simple it was. For serializing out, you pass us your objects, and then from there we go through and we get ahold of an NSXML output stream. We format it, and then from there we write out.

And then from there, flush and close the buffer, and we're all set to go. Of course, you know, there's some error handling there. That's a positive thing. Then to deserialize and bring back the EO, you just go out and, you know, get a hold of your stream, and then from there, create an NSXML input stream, read it back in, and you're all set to go. So it's easy as pie, very simple, straightforward to the point. Back to slides.

Next, I want to talk to you about XSL. XSL stands for Extensible Style Sheet Language. It has two rule-based vocabularies, that being XSLT, or Extensible Style Sheet Language Transformation, and the other one, XSLFO. That stands for Formatting Objects. Both of these vocabularies transform source XML documents, and both specify the formatting of XML documents. Now, formatting objects is an XML vocabulary that defines page layout, pagination, the placement of images, text, that kind of thing, on a document. And then from there, it's converted to a binary format like PDF and Word. And you can also maybe generate an SGV file or any kind of binary output that you want based on these objects. And a really good place to go to get information concerning XSL-FO is the Apache site. They have a formatting objects parser out there that you can download and use as a part of your application. It's very simple, straightforward, and to the point.

But what we really want to focus on is XSLT, which is the rules document of XSL. It enables us to extract data from a source XML document and then transform it into whatever format, XML, text, HTML that we want to. Now, the XSLT vocabulary has many constructs, and the main one is the template matching functionality, and that enables you to look in your XML document, identify an element, tag, and then from there, work on that tag, the data that's inside of it as well, the content. It also has copying control structures, such as if-then-else, if-then-else-choose.

It also has iteration, the ability to loop through. And it also gives you the ability to maintain state by defining variables. Using XPath, which is an expression matching functionality as a part of XSLT, you're able to find data and then from there work upon that data. And we'll kind of touch upon that in a small example coming up here in a few moments. Thanks.

Now, the components that make up XSLT are the source valid XSL transformation document, the XALAN XSL transformation parser or processor, and a valid source XML document. And those three components work together to generate an output XML document. So you're basically going and you're converting an XML document to another XML document, or maybe converting an XML document to an HTML document, XHTML document, or even a text-formatted document.

Now, here are some examples of the components that make up the transformation process. At the top, we have foo.xml, and this is a basic input document, very simple, straightforward. It's kind of like a Hello World kind of document. In the middle, there's our XSLT style sheet, and you can see there that there's a template element, and that's used to find the tag or the element and work upon it. you see that one of the attributes is the name match, and that tells you what the name of the element is. And as a part of that, there's also the value of element, and that enables you to find the content inside of there. And at the bottom, there's the output that gets generated based on that.

Now, some of the uses of XSLT are transforming XML to HTML, XHTML, WML. And you can also take a FO document, put it through your XSLT processor, and then from there generate a PDF document. And there's any number of different text transformations that you can do as well. Thank you.

Now, some of the two key processors in XSLT are Apache Zalan and SACSON, which is located at SourceForge. And here are some of the URLs that you can go to to get more information. and Give you a moment to jot those down. Now let's look at the demo.

And as a part of this demo, what I'm going to do is I'm going to take an XML document-- Demo 1--take an XML document and convert it into an HTML document to show you how simple and easy it is to do transformations in WebObjects using our parser. Okay, so we bring up the application here, and let's fire it up.

So the first thing I'm gonna do is I'm gonna load in an XML document called inventory. And then I'm going to take an XSLT style sheet, load that in. And I'm going to enter the name of our destination document. And by pressing this button, I'm going to do the transformation.

and magically there it appears. Let's look at this real quickly, the document that we just generated. It's just straight HTML, very simple, straightforward, and to the point. And if we look at the style sheet, a very basic style sheet that enables you to go through and transform the source XML document. And you can see the template here. And it's looking for the tag product. And based on that, it's gonna pull out the data where you see the description in. I'm sorry? We're not as close to your Okay. Now here's the XML document. And how's that? Excellent. one. So there's the XML document that we transformed. And let's go back again, give you a better look at the other document.

How's that? Thank you. So there we're doing transformations from an XML document to XSLT. Now, the next thing we're going to do, and this is kind of a little bit unplanned here, is we're going to go ahead and we're going to take... an NSDictionary, fill it full of information, and using NS XML output stream, we're gonna convert it to an XML representation of a plist. So what I'm gonna do is I'm gonna enter someone's name. and his favorite cartoon. What's that? Bob? Oh, The Simpsons, okay.

Okay. What's your favorite card game? Solitaire. Solitaire. Excellent. I prefer magic, but... Okay, let's hope that works. Okay. So now by pressing this button, I'm going to go through and do the transformation. And I'm going to write it out here to the console. So let me just clear the console there. So keep me honest. Press the submit button. and magically there you are. We've taken an XML document-- I'm sorry, we've taken a NSDictionary and we've converted it into an XML representation of a plist. So let's look at some code real quick.

This is the serialization portion for taking an NSDictionary and converting it to an XML representation of a plist. Pretty straightforward to the point. And we want to kind of focus on this line of code here. Let me get to it right now. He's the guy that does the quote unquote "heavy lifting."

And to do the XSLT transformations that we saw previously, there's a code there. Pretty straightforward to the point. and that's it. So pretty much it's very simple, very little code that enables you to do transformations inside of WebObjects using XSLT. And with that, I'm going to call up Bob Frank so that he can demo XMLRPC and WoXMLCoder. Bob?

Thank you, Mike. Very good. WoXML node and XMLRPC. Okay. What is WoW XML Node? WoW XML Node, if you're not familiar with it, is a graphical way that you can use WoW Builder to create XML documents. It allows you to use all of the dynamic elements that you're familiar with for building WebObjects HTML documents. You can use WoW Conditional, you can use WoW Switch, you can use repetitions, et cetera, and so on. And instead of producing a pure HTML document, it will produce an XML document.

It has a very tight integration with WebObjects Builder. You can drag and drop. You can drag relationships from EOs, from objects that are in the bottom part of WebObjects Builder, and use them to populate your values for your walks and melnodes. And the document format is under your precise control. From a verboseness perspective, compared to some of the automatic tools that you get to do the heavy lifting, like NSXML, Object Input Stream, and Output Stream, it's probably going to give you a more compact representation when you build it yourself and you specifically specify what you want the document to look like. On the other hand, when you use the automatic tools that you get with Object Input Stream and Output Stream, they have a bunch of other automated facilities that allow you to serialize, for example, an EO and serialize it back in in another application easily. When you do use WoXML node, though, one thing that you need to do in your component that's generating your XML document, your page, is you need to set the header, the response.setHeader, to text XML as your content type.

What this does, and I'll show it to you in the demo, it tells the browser to realize, or whoever's receiving it, that this is an XML document. IE happens to be very intelligent when it comes to receiving XML documents, and they have a little XML browser built in.

You're all familiar with the typical WoW HTTP application. Well, okay, so maybe this isn't quite a typical application. This is a fairly complex application. You have the browsers communicating via HTTP, going through the firewall, hitting the web servers, sending all sorts of messages all over the place to a variety of application instances. Well, it's a very nice application. What WoW, I mean, what XMLRPC does, it is a method that allows servers to communicate directly to each other over HTTP typically and it allows you to execute remote procedure calls.

What you'll see is a simple communication between servers to allow them to generate requests on another machine, perhaps running WebObjects, perhaps not, and send a request and get back a response or a fault. A fault is like an exception or an error. What is XMLRPC and SOAP? They're both technologies that are used in the coming popular buzzword of web services. We have an entire session, session 705, devoted exclusively to web services, focusing primarily on the SOAP aspect. So I'm not going to touch very much on SOAP. XML RPC is an earlier and a much more simple approach to web services. It's a parameter marshalling mechanism that focuses very much on the metaphor of a remote procedure call. SOAP stands for Simple Object Access Protocol. It's much more robust, and it has a lot more buzzword momentum going for it with a lot of large players in the web services industry. It has much more typing specifications, as Han Ming pointed out earlier, regarding namespacing for schema documents, and therefore it is typically more compact for certain types of representations. And, once again, C705, for more than you ever wanted to know about web services, and the SOAP aspect of it.

One other comment about SOAP, it's a W3C note. XMLRPC is not. But both are focusing on remote communication between servers so that you don't need to do something, for example, like screen scraping. If you wanted to get data from a remote server, typically many people have implemented a variety of screen scraping mechanisms in order to get data, weather data, stock data, et cetera, et cetera. Now, with web services becoming more and more popular, None of that's necessary. And when neither of these protocols focus on remote object activation or garbage collection, those are implementation details of the implementation on either side of the communications channel.

XML RPC. What do I mean when I say strict RPC concept? It means that you have a method or a function name on the remote server that you wish to execute, and you're going to send an XML-based request. Your document is going to be a request, please execute this method for me, and give me back a response. Very much just like traditional functional programming. Responses, all requests in the XML document are falling under a method call XML tag.

I'll show you the document structure in a second. All responses are wrapped in a method response document tag. XMLRPC uses faults to represent error conditions. And in Java, it is handled very similar to an exception, but in most XMLRPC representations and what most error codes mean, they are typically less severe than an exception in Java.

To build up a method call, you specify the method name that you want to execute on the remote server. And as you build that up, you add the parameters that you want to pass along to it. And those are passed to the document, depending on the library that you're using. In my demo, you'll see an implementation wrapping, the Apache XMLRPC jar files. And they take a vector of your arguments. I've written a simple wrapper that maintains the array for you. And you don't need to necessarily build an independent vector or an array and pad all of it with the parameters that you want.

XMLRPC supports a very simple set of base primitive types, Boolean, double, datetime, integers, strings. They are typically getting more and more support from underlying XMLRPC parsers to support Unicode. Originally, the XMLRPC specification, I believe, specified only ASCII, but due to the fact that more and more XML parsers support Unicode, You get that for free nowadays.

Additional types for encoding binary data, it specifies a base64 encoding, which transforms binary data into a character representation. Additionally, it has data structures to contain complex data, arrays-- I think everyone understands the concept of arrays-- and structs, which is their representation of a dictionary. Names are strings used for keys, and values may be of any type. Obviously, it's unordered.

The values in the XML document are exactly as I specified them on the previous slide. An int is an int tag, and the content goes inside the tag. Boolean is a Boolean specified by 0 or 1. String is a string, any content. Double is a double, and datetime follows this ISO format. and in the XMLRPC jar file from the Apache jar file, it has a convenience formatter that takes a Java date and formats it in this format. All values--oh, and base64.

All values are wrapped with a value tag. For example, if you have a string, "Hello, world," everybody's first program string, it's wrapped with the value tag. An array looks like this. You have an array, and it contains its data, and the data contains an ordered set of values. So this value is serialized into the XML document and un-serialized in this order from the client to the server.

And the dictionary, each member of the dictionary is a member tag. That specifies a name-value pair. Your key are your names, and your values are your ints. And you see in a name, it doesn't specify a string. In XMLRPC, if you do not specify any data type, all data types are implicitly assumed to be string. But it's best, just like in Java, to specify your types.

It's always best to specify exactly what type you have. This is the whole tamale of what an XMLRPC request looks like. You have a standard HTTP header specifying where it's going and what the path to the method on the server is. All XMLRPC requests are done via POST.

And the content type is text, XML. Content length must be accurate, must be specified. And you have your XML header. The method call tag begins the body of the XML document where it specifies your method name. In this case, examples.getStateName. On the server side, you will be looking for this method. And the value is an int specifying 32.

The response comes back, what is the 30-second state? You can see here the answer is Minnesota. The response is a standard HTTP packet with an HTTP response code, connection, content length, which, again, is mandatory, must be specified and accurate, content type, date, and server. You have your XML header, and then your method response makes up the body of your document. Method response has a single params tag, which includes a single parameter. The parameter can include a compound type, an array, or a dictionary, a struct, an XMLRPC vocabulary. And what this does is this gives you the ability to return any value you want from your function. Okay?

A fault is a method response, includes a fault and a value, and unlike the method response, it includes a dictionary with two values, a fault code, which is a numeric value, and a fault string, which is a descriptive term for what the error is. There are several common extensions in XMLRPC that many servers implement.

System.multicall is commonly implemented, and it allows you to include an array of dictionaries in the body of your payload that allows you to execute multiple methods in a single request-response loop. And a few introspection methods are also commonly implemented by many servers. List methods, method signature, and method help.

Other key features, because it, by default, goes over HTTP, it's very easy to go over HTTPS if your web server supports it, and also it has built-in support for HTTP user password authentication. Likewise, since it's not encrypted, by default, standard HTTP user password authentication is more secure if you run it over HTTPS. At this point, I'd like to go to demo three to give you an example of XMLRPC and blogging. Let me quick fire up the server here. I'm going to show you a quick screen of what the application looks like, and then we'll dive in and take a quick look at the code.

Blogging, by the way, is a very popular thing, popular use of XMLRPC. And in addition to other popular technologies like Jabber, it's also based on XMLRPC. So let me quick log in. First, if you want to take a look, using Woe XML node, I created a Woe component that demonstrates what the request is going to look like. And since I set the header content to type text XML, Internet Explorer receives this as an XML document and realizes, hey, this is in fact an XML document.

I have a little handling built in to show how this works. Here is the structure. Here is the method that we're using. Get user blogs is a login function. It returns empty if there's no blogs for this user. And a temp app key is another parameter that I'm requiring. So let's go ahead and log in.

And you can see it's a very standard woe app. This is a client application. Boy, am I happy to be here. - Yeah. and we've successfully submitted it to the server process, which is running on this same box. They're communicating over TCP/IP using XMLRPC. The request that went out looked like this. Boy, am I happy to be here. And the method was new post.

So just so that you can see it works, let's take a look at what the blog looks like. Rather than actually publishing a static HTML file, I cheated and just made a little direct action. But boy, am I happy to be here. I'm very happy to be here. So what is involved with this application? I made a little core framework wrapping the Apache XMLRPC jar files. The one thing that I've done that is not-- well, two things that I've done. The first thing that I did that was not standard or does not come with the Apache XMLRPC file is I wrote a little converter that converts NSDictionary's and NSArrays to vectors and hash tables and back and forth again. So that way, I don't need to modify the Apache code, and I can still use all of the native types that come with WebObjects and come from my EOs and EOF and just have to call one static method conversion of my array. And you can see here, depending on the various types that they are, instance of, I convert it one way, and then I convert it back another way. The second thing that I've done is I've wrapped... Hmm, what are you doing here? The second thing that I've done is I've wrapped... Well, it doesn't seem to be happy.

I wrapped the XML RPC code with a whoa method call. The machine appears to be spinning, so I will talk for a second while I try and get back the machine here. And that, um, allowed me to, uh, make the code smaller for the demonstration, which I can't seem to get to right here. I'm trying.

Trust me, it worked perfectly in rehearsal. At this point, while this reboots, can we go back? I think, actually, you'd probably want to pay me not to sing. But at this point, I have one last wrap-up slide. Maybe if you have some time at the end of Q&A, I'll show some more demo later. I just wanted to summarize a few things about XMLRPC and compare it with SOAP in one more way.

that it really is a very simple protocol. It says to the remote server, go ahead and do this one function for me and give me back this one result. The spec for XMLRPC, if you go to user land, this is it. It's only about, let's see, six pages long. But if you were to go to the W3C and ask them, the simple this is like you know in soap is like the green in Greenland because if you you know print this out you know It's like 50 pages long. And so I just wanted to point out that it's good for doing very limited tasks, but I think that that will cover a lot of what people want. At this point, I think while the demo machine comes back to life slowly, we could probably take some Q&A.