Designing a Service's Interaction Layer
Considering this mapping between Java and MIME types, it is best to send im
ages and XML documents that are in a Web service interface using the Java
types shown in Table 3.1. However, you should be careful about the effect on
the interoperability of your service. See Interoperability on page 86 for more
126.96.36.199.2 XML Documents as Parameters
There are scenarios when you want to pass XML documents as parameters. Typi
cally, these occur in business to business interactions where there is a need to
exchange legally binding business documents, track what is exchanged, and so
forth. Exchanging XML documents as part of a Web service is addressed in a sepa
rate section see Handling XML Documents in a Web Service on page 105 for
guidelines to follow when passing XML documents as parameters.
188.8.131.52.3 Handling Nonstandard Type Parameters
JAX RPC technology, in addition to providing a rich standard mapping set between
XML and Java data types, also provides an extensible type mapping framework.
Developers can use this framework to specify pluggable, custom serializers and
deserializers that support nonstandard type mappings.
Extensible type mapping frameworks, which developers may use to support
nonstandard type mappings, are not yet a standard part of the J2EE platform.
Vendors currently can provide their own solutions to this problem. It must be
emphasized that if you implement a service using some vendor's implementation
specific type mapping framework, then your service is not guaranteed to be porta
ble and interoperable.
Because of portability limitations, you should avoid passing parameters that re
quire the use of vendor specific serializers or deserializers.
Instead, a better way is to pass these parameters as SOAP document frag
ments represented as a DOM subtree in the service endpoint interface. (See Figure
3.3.) If so, you should consider binding (either manually or using JAXB) the
SOAP fragments to Java objects before passing them to the processing layer to
avoid tightly coupling the business logic with the document fragment.