Java Reference
In-Depth Information
▪ Get the location of the WSDL document associated with the service
▪ Get the Executor instance associated with the service, which provides threading capability
to service invocations
▪ Create a
Dispatch
▪ Create a
Service
instance
▪ Call the
getPort
method on the
Service
instance to invoke web service operations
This class extends
javax.xml.ws.Service
, and is annotated with a
@WebServiceClient
an-
notation that specifies the location of the WSDL representing the service to be invoked. It
contains factory methods that return the Java object that represents the WSDL port you can
invoke operations on. The generated
Service
class looks like this:
@WebServiceClient(name = "CalculatorWSService",
targetNamespace = "http://calculator.me.org/",
wsdlLocation = "http://localhost:4933/CalculatorApp/
CalculatorWSService?wsdl")
public class CalculatorWSService extends Service { //...
@WebEndpoint(name = "CalculatorWSPort")
public CalculatorWS getCalculatorWSPort() {
return super.getPort(new QName("http://calculator.me.org/",
"CalculatorWSPort"), CalculatorWS.class);
}
NOTE
The
wsdlLocation
attribute must allow for the use of the XML Catalog facility specified by
OASIS, if one is available. This is discussed in
Transparently Substituting XML Files
.
Here the
getCalculatorWSPort
method returns an object that implements the
CalculatorWS
interface, which is discussed next. The no-arg
getPort
method can be used in general;
the second
getPort
method accepts a variable-length array of
javax.xml.ws.WebServiceFeature
objects that can be used by clients to configure certain
aspects of the invocation, such as whether to enable MTOM or WS-Addressing.
The generated Port class
Because the WSDL port as shown in the earlier listing has a value of
CalculatorWS
for the
name attribute, that is the name of the generated Java interface representing the port. This in-
terface is (somewhat confusingly) annotated with
@WebService
, to indicate that it is a service
endpoint interface that will be used as a proxy. There is not an implementation for this class
generated by JAX-WS. The runtime will do the work behind the scenes by delegating the in-