Handling XML Documents in a Web Service
For these documents, the complete infoset of the original document should be
preserved, including comments and external entity references (as well as the
Some application processing requires the complete document infoset, includ
ing comments and external entity references. As with the legally binding doc
uments, it is necessary to preserve the complete infoset, including comments
and external entity references, of the original document.
When sent as attachments, it is possible to handle documents that may conform
to schemas expressed in languages not supported by the Web service endpoint
or that are prohibited from being present within a SOAP message infoset (such
as the Document Type Declaration
for a DTD based schema).
For example, consider the travel agency Web service, which typically receives
a client request as an XML document containing all information needed to arrange
a particular trip. The information in the document includes details about the cus
tomer's account, credit card status, desired travel destinations, preferred airlines,
class of travel, dates, and so forth. The Web service uses the documents contents
to perform such steps as verifying the customer's account, obtaining authorization
for the credit card, checking accommodations and transportation availability,
building an itinerary, and purchasing tickets.
In essence, the service, which receives the request with the XML document,
starts a business process to perform a series of steps to complete the request. The
contents of the XML document are used throughout the business process. Han
dling this type of scenario effectively requires some considerations in addition to
the general ones for all Web services.
Good design expects XML documents to be received as
objects. See Exchanging XML Documents
on page 107, which discusses exchanging XML documents as parameters.
Keep in mind the effect on interoperability (see Interoperability on page 86).
It is good design to do the validation and any required transformation of the
XML documents as close to the endpoint as possible. Validation and transfor
mation should be done before applying any processing logic to the document
content. See Figure 3.4 and the discussion on receiving requests in Receiving
Requests on page 89.