Working with Literal XML Documents

In addition to JavaBeans, Apache SOAP also supports the passing of literal XML documents. Our third example demonstrates the main concepts. The client code will send a product query by sending a product element with a SKU attribute. For example:

<product sku="A358185"/>

The server will respond with a complete product XML document. For example, the following command line:

java com.ecerami.soap.ProductXMLClient A358185

will generate this XML response:

<product sku="A358185">
   <name>Red Hat Linux</name>
   <description>Red Hat Linux Operating System</description>
   <price>54.99</price>
</product>

Working with literal XML documents requires some knowledge of the XML Document Object Model (DOM) API. Even if you are not familiar with the DOM API, however, you should be able to follow the general flow of the example code.

Get Web Services Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.