Last Modified: 12/08/05
Web Service endpoints can be created and published programmatically
using javax.xml.ws.Endpoint API. An endpoint consists of a Web Service
Implementation object and some configuration information. The
implementation hosts the web service endpoint using a light weight http
server and clients can access the
web service as if the endpoint is deployed in a J2EE container. This
means that there is no need to have any J2EE servlet or ejb container
to host the endpoint. The Endpoint API provides a way to
configure the endpoint with the necessary binding, metadata(WSDL and
schema documents), handlers etc.
Endpoint
Endpoint.create(implementor)Once the Endpoint object is created using the first two constructors, it can be published using Endpoint.publish(). Any published Endpoint can be stopped using Endpoint.stop(). supplychain sample shows creating and publishing an Endpoint.
Endpoint.create(bindingId, implementor)
Endpoint.publish(address, implementor)
Endpoint and Properties
An endpoint can be configured to match service name and port name of WSDL using properties. This overwrites implementor object's serviceName, portName from @WebService annotation. The port address for an endpoint is patched only if the corresponding port's service name, and port name in WSDL are matched.
For example:
Endpoint endpoint = ...
Map<String, Object> map = new HashMap<String, Object>();
map.put(Endpoint.WSDL_SERVICE, new QName(...));
map.put(Endpoint.WSDL_PORT, new QName(...));
endpoint.setProperties(map);
Endpoint and Binding
Endpoint can be configured for different bindings using binding ids. These binding ids are defined in JAX-WS API and endpoint can be configured by specifying @BindingType annotation or using binding id in the Endpoint() constructors. The parameter in constructor overwrites binding defined by @BindingType annotation. If the binding is not specified using @BindingType or using a parameter in Endpoint() constructor, the default binding is SOAP1.1/HTTP. Binding object is used to configure MTOM, handler chain etc. SOAP binding object is used to configure SOAP binding specifics like roles.
For example:
The following configures the endpoint for XML/HTTP binding.
Endpoint endpoint = Endpoint.create(HTTPBinding.HTTP_BINDING, implementor);
For example:
// setting MTOM
SOAPBinding binding = (SOAPBinding)endpoint.getBinding();
binding.setMTOMEnabled((true);
// setting SOAP binding roles
binding.setRoles(...);
// setting handler chain
binding.setHandlerChain(...);
Endpoint
and metadata
// metadata processing for WSDL, schema files
List <File> metadataFile = ...
List<Source> metadata = new ArrayList<Source>();
for(File file : metadataFile) {
Source source = new StreamSource(new FileInputStream(file));
source.setSystemId(file.toURL().toExternalForm());
metadata.add(source);
}
endpoint.setMetadata(metadata);
Copyright © 2005 Sun Microsystems, Inc. All rights reserved.