If you used the Java first development model or you do not want to use the generated server mainline you can write your own. To write your server mainline you must do the following:
Instantiate an javax.xml.ws.Endpoint
object for the endpoint.
Create an optional server context to use when publishing the endpoint.
Publish the endpoint using one of the publish()
.
You can instantiate an Endpoint
using one of the following three methods provided by Endpoint
:
static Endpoint create(Object implementor);
This create()
method returns an Endpoint
for the specified service implementation. The created Endpoint
is created using the information provided by the implementation class'javax.xml.ws.BindingType
annotation if it is present. If the annotation is not present, the Endpoint
will use a default SOAP 1.1/HTTP binding.
static Endpoint create(URI bindingID,
Object implementor);
This create()
method returns an Endpoint
for the specified implementation object using the specified binding. This method overrides the binding information provided by the javax.xml.ws.BindingType
annotation if it is present. If the bindingID
cannot be resolved, or is null
, the binding specified in the javax.xml.ws.BindingType
is used to create the Endpoint
. If neither the bindingID
or the javax.xml.ws.BindingType
can be used, the Endpoint
is created using a default SOAP 1.1/HTTP binding.
static Endpoint publish(String address,
Object implementor);
The publish()
method creates an Endpoint
for the specified implementation and publishes it. The binding used for the Endpoint
is determined by the URL scheme of the provided address
. The list of bindings available to the implementation are scanned for a binding that supports the URL scheme. If one is found the Endpoint
is created and published. If one is not found, the method fails.
Tip | |
---|---|
Using |
Important | |
---|---|
The implementation object passed to any of the |
You can publish an endpoint using one of the following Endpoint
methods:
void publish(String address);
This publish()
method publishes the endpoint at the address specified.
Important | |
---|---|
The |
void publish(Object serverContext);
This publish()
method publishes the endpoint based on the information provided in the specified server context. The server context must define an address for the endpoint and it also must be compatible with one of the endpoint's available bindings.
Example 6.2, “Custom Server Mainline” shows code for publishing an endpoint.
Example 6.2. Custom Server Mainline
package org.apache.hello_world_soap_http; import javax.xml.ws.Endpoint; public class GreeterServer { protected GreeterServer() throws Exception { } public static void main(String args[]) throws Exception { GreeterImpl impl = new GreeterImpl(); Endpoint endpt.create(impl); endpt.publish("http://localhost:9000/SoapContext/SoapPort"); boolean done = false; while(!done) { ... } System.exit(0); } }
The code in Example 6.2, “Custom Server Mainline” does the following: