226
Developing Client Applications to Use a Web Service
(The WSDL Basic Profile 1.0 does not support
javax.xml.transform.Source
objects as mime types. As a result, you should avoid this usage until it is sup
ported by a future WSDL version.) A service may also return complex types, and
these are mapped to Java
Object
representations. For more information, see
Parameter Types for Web Service Operations on page 72.
When stubs are used, the JAX RPC WSDL to Java mapping tool maps
parameter, exception, and return value types into the generated classes using
information contained in the developer provided WSDL document. Complex
types defined within a WSDL document are represented by individual Java classes,
as are faults. A WSDL to Java mapping tool included with the JAX RPC runtime
also generates classes to serialize and deserialize these values to XML. The JAX
RPC runtime uses these generated classes to serialize parameter values into a
SOAP message and deserialize return values and exceptions.
E
Use WSDL to Java tools to generate support classes, even if using the dynamic
proxy or DII approach.
Whenever possible, developers should try to use a tool to do the WSDL to
Java mapping, since a tool correctly handles the WSDL format and mapping
semantics. Note that the Java objects generated by these mapping tools contain
empty constructors and get and set methods for elements. You should use the
empty constructor to create an instance of the object and set any field or element
values using the corresponding set methods. JAX RPC does not guarantee that it
will correctly map values created as part of the constructor to the corresponding
fields.
Although not advisable, it is possible for a developer to work without the
benefit of a mapping tool, if none are available. However, without such mapping
tools the scope of the developer's work greatly expands. For example, just to
compile the client code, the developer must understand the WSDL for a service
and generate by hand Java classes that match the parameter and return types
defined in the WSDL document or, in the case of a dynamic proxy, the client side
representation of the service endpoint interface. These classes must be set up prop
erly so that the JAX RPC runtime can match SOAP message types to the corre
sponding Java objects.
New Page 1