Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.Ce contenu n'est pas disponible dans la langue sélectionnée.
31.2. APIs Used to Publish a Service
Overview Copier lienLien copié sur presse-papiers!
Copier lienLien copié sur presse-papiers!
The
javax.xml.ws.Enddpoint class does the work of publishing a JAX-WS service provider. To publishing an endpoint do the following:
- Create an
Endpointobject for your service provider. - Publish the endpoint.
- Stop the endpoint when application shuts down.
The
Endpoint class provides methods for creating and publishing service providers. It also provides a method that can create and publish a service provider in a single method call.
Instantiating an service provider Copier lienLien copié sur presse-papiers!
Copier lienLien copié sur presse-papiers!
A service provider is instantiated using an
Endpoint object. You instantiate an Endpoint object for your service provider using one of the following methods:
static Endpoint create(Object implementor);Thiscreate()method returns anEndpointfor the specified service implementation. TheEndpointobject is created using the information provided by the implementation class'javax.xml.ws.BindingTypeannotation, if it is present. If the annotation is not present, theEndpointuses a default SOAP 1.1/HTTP binding.static Endpoint create(URI bindingID,
Object implementor);Thiscreate()method returns anEndpointobject for the specified implementation object using the specified binding. This method overrides the binding information provided by thejavax.xml.ws.BindingTypeannotation, if it is present. If thebindingIDcannot be resolved, or it isnull, the binding specified in thejavax.xml.ws.BindingTypeis used to create theEndpoint. If neither thebindingIDor thejavax.xml.ws.BindingTypecan be used, theEndpointis created using a default SOAP 1.1/HTTP binding.static Endpoint publish(String address,
Object implementor);Thepublish()method creates anEndpointobject for the specified implementation, and publishes it. The binding used for theEndpointobject is determined by the URL scheme of the providedaddress. The list of bindings available to the implementation are scanned for a binding that supports the URL scheme. If one is found theEndpointobject is created and published. If one is not found, the method fails.TipUsingpublish()is the same as invoking one of thecreate()methods, and then invoking thepublish()method used in publish to an address.
Important
The implementation object passed to any of the
Endpoint creation methods must either be an instance of a class annotated with javax.jws.WebService and meeting the requirements for being an SEI implementation or it must be an instance of a class annotated with javax.xml.ws.WebServiceProvider and implementing the Provider interface.
Publishing a service provider Copier lienLien copié sur presse-papiers!
Copier lienLien copié sur presse-papiers!
You can publish a service provider using either of the following
Endpoint methods:
void publish(String address);Thispublish()method publishes the service provider at the address specified.ImportantTheaddress's URL scheme must be compatible with one of the service provider's bindings.void publish(Object serverContext);Thispublish()method publishes the service provider based on the information provided in the specified server context. The server context must define an address for the endpoint, and the context must also be compatible with one of the service provider's available bindings.
Stopping a published service provider Copier lienLien copié sur presse-papiers!
Copier lienLien copié sur presse-papiers!
When the service provider is no longer needed you should stop it using its
stop() method. The stop() method, shown in Example 31.1, “Method for Stopping a Published Endpoint”, shuts down the endpoint and cleans up any resources it is using.
Example 31.1. Method for Stopping a Published Endpoint
void stop();Important
Once the endpoint is stopped it cannot be republished.