Library Link To Toggle Frames Print Feedback

Main Function for a Standalone Service

The Celtix ASE product is capable of running Web services in a standalone mode. In order to run a Celtix ASE standalone service, you must provide just a few lines of code to define a main() function for the server program.

Server main() function

Example 2.1, “Server main() Function for the Greeter Service” shows the code for a simple Celtix ASE main() function. This is all the code that is required to launch the Greeter service as a standalone service.

Example 2.1. Server main() Function for the Greeter Service

package demo.hw.server;

import javax.xml.ws.Endpoint;

public class Server {

    protected Server() throws Exception {
        System.out.println("Starting Server");

        Object implementor = new GreeterImpl();
        String address = "http://localhost:9000/SoapContext/SoapPort";
        Endpoint.publish(address, implementor);
    }

    public static void main(String args[]) throws Exception {
        new Server();
        System.out.println("Server ready...");

        Thread.sleep(5 * 60 * 1000);
        System.out.println("Server exiting");
        System.exit(0);
    }
}

The Server.main() function creates a new Server instance and then goes to sleep for five minutes, giving the background thread a chance to process incoming requests.

The Server() constructor is responsible for launching the Greeter service. It creates a GreeterImpl instance and then starts the service by calling the Endpoint.publish() method. The publish() method kicks off a background thread to process incoming requests to the Greeter service and starts listening on the IP port specified by address.