Library Link To Toggle Frames Print Feedback

Generating a Server Mainline

The wsdl2java tool's -server flag causes the tool to generate a simple server mainline. The generated server mainline, as shown in Example 6.1, “Generated Server Mainline”, publishes one endpoint for each port defined in the WSDL contract.

Example

Example 6.1, “Generated Server Mainline” shows a generated server mainline.

Example 6.1. Generated Server Mainline

package org.apache.hello_world_soap_http;

import javax.xml.ws.Endpoint;

public class GreeterServer {

    protected GreeterServer() throws Exception {
        System.out.println("Starting Server");
1        Object implementor = new GreeterImpl();
2        String address = "http://localhost:9000/SoapContext/SoapPort";
3        Endpoint.publish(address, implementor);
    }
    
    public static void main(String args[]) throws Exception { 
        new GreeterServer();
        System.out.println("Server ready..."); 
        
        Thread.sleep(5 * 60 * 1000); 
        System.out.println("Server exiting");
        System.exit(0);
    }
}

The code in Example 6.1, “Generated Server Mainline” does the following:

1

Instantiates a copy of the service implementation object.

2

Creates the address for the endpoint based on the contents of the address child of the wsdl:port element in the endpoint's contract.

3

Publishes the endpoint.