136
Designing XML Based Applications
Returned to a Web service client: if the application is accessing a Web service
through JAX RPC. (See Chapter 5 for more details.)
Through a JMS queue or topic (possibly attached to a message driven bean in
the EJB tier) when implementing a business process workflow or implement
ing an asynchronous Web service architecture. (See Delegating Web Service
Requests to Processing Layer on page 92.)
Note that a generic XML based application can additionally receive and
return XML documents through a servlet over plain HTTP.
Recall from Chapter 3 that a Web service application must explicitly handle
certain XML schemas schemas for SOAP parameters that are not bound to Java
objects and schemas of XML documents passed as attachments to SOAP mes
sages. Since the JAX RPC runtime passes SOAP parameter values (those that are
not
bound to Java objects) as
SOAPElement
document fragments, an application
can consume and process them as DOM trees and even programmatically bind
them to Java objects using XML data binding techniques such as JAXB. Docu
ments might be passed as attachments to SOAP messages when they are very
large, legally binding, or the application processing requires the complete docu
ment infoset. Documents sent as attachments may also conform to schemas
defined in languages not directly supported by the Web service endpoint.
Code Example 4.2 and Code Example 4.3 illustrate sending and receiving
XML documents.
public class SupplierOrderSender {
private SupplierService_Stub supplierService;
public SupplierOrderSender(URL serviceEndPointURL) {
// Create a supplier Web service client stub
supplierService = ...
return;
}
// Submits a purchase order document to the supplier Web service
public String submitOrder(Source supplierOrder)
throws RemoteException, InvalidOrderException {
String trackingNumber
= supplierService.submitOrder(supplierOrder);
return trackingNumber;
New Page 1