Java Reference
In-Depth Information
Three Approaches
There are three different ways to approach developing applications with JAX-WS:
The WSDL to Java approach
The WSDL to Java approach
Point to a WSDL and use tools such as wsimport to generate portable web service arti-
facts.
The Java to WSDL approach
The Java to WSDL approach
Create a Service Endpoint Interface as Java source files. Use them as inputs to generate
the WSDL and other required portable artifacts.
The Start from Java and WSDL approach
The Start from Java and WSDL approach
This can be a smart way of working. Write Java classes and let wsgen create WSDL
and schema for you. Then save the generated artifacts locally, modify them as necessary,
and point your service implementation to them via the wsdlLocation attribute of the
@WebService annotation. This means you have to keep your classes in synch with your
schema and WSDL, but it puts you in the sweet spot that maximizes convenience and con-
trol.
With any approach, JAX-WS will generate significant amount of code for you, and reduce the
challenges of dealing with what was designed to be machine-readable code. Moreover, these
generated artifacts are portable across vendors. As with EJBs or any other “portable” Java ar-
tifact, there can be slight variations in generated code that either do not conform entirely to
the specification, or do conform to the specification but touch on an area of the spec that was
slightly ambiguous or left the implementation decision up to vendors. In these cases, you can
have portability issues. So if that's a concern for you, then you may consider taking an extra
look at the generated artifacts for potential areas of conflict.
Annotations
JAX-WS makes heavy use of Java 5 annotations. Therefore, the source code that you write
will be fairly slim, and then tools will process your annotations to create the infrastructure ar-
tifacts necessary to run or consume the service. The generated artifacts themselves, including
clients, services, and JAXB 2.0 value classes, all are heavily annotated as well.
That has certain ramifications for developers. For example, because annotations don't allow
runtime arguments, you have to work around the annotation attributes if you need to specify
something different than what was generated. There are recipes in this chapter that show you
how to do that with certain items, such as changing the WSDL location on a client proxy. But
Search WWH ::




Custom Search