Custom Protocols
XML-RPC is vastly underpowered for many
For example, if an online broker such as Ameritrade wanted to
provide its
There are still many advantages to using a standard format for
exchanging data rather than rolling your own every time you need
one. Most important, a standard format such as XML-RPC or SOAP
makes it much easier for other developers to integrate their
systems with yours. Furthermore, if your system can be easily
|
Summary
XML protocols allow widely distributed systems to communicate
with each other over standard HTTP. These protocols have many
advantages compared with traditional RPC systems such as CORBA and
RMI, including simplicity, transparency, and platform independence.
Using HTTP allows
Some XML protocols are based on custom XML applications.
Slashdot's Backslash is one example. Others use standard formats
such as RSS, XML-RPC, and SOAP. RSS is limited to distributing news
headlines and summaries. XML-RPC is more general, allowing the
transmission of method calls and arguments to remote systems that
invoke those
Throughout the rest of this book, we're going to build multiple servers and clients for RSS, XML-RPC, SOAP, and custom systems. We'll use Java's networking classes to hide the fact that the XML documents we're working with are coming from and going to the network. We're going to focus on the contents of those documents, and how to access and manipulate those contents from inside our own Java programs. |
Chapter 3. Writing XML with Java
No one ever believes me when I tell them how easy it is to
develop programs that write XML documents. In fact, writing a
program to output an XML document is unbelievably trivial. It's
something an eight-year-old typing BASIC in his or her first class
at computer camp can do. In Java, it's even easier than that due to
Java's strong Unicode support. You don't need to know any special
APIs like DOM, or SAX, or JDOM. All you need to know is how to
System.out.println()
. If you want to store your XML
document in a file, you can use the
FileOutputStream
class
instead. If you want to serve the document dynamically over a
network, it helps to know something about servlets; but in the end,
it all
In this chapter, I'm going to develop a program that
I'm going to show you how to use classes you're already familiar
with, such as
OutputStreamWriter
,
String
, and
HTTPServlet
, to generate XML documents. I am going to beat
this idea into the ground until you are
|