Library Link To Toggle Frames Print Feedback

Build and Run the Servlet Container Demonstration

Follow the instructions in this section to build and run the servlet container demonstration. These instructions assume that you have already configured your environment as described in Before You Start .

Build the demonstration

Build the servlet container demonstration as follows:

  1. Open a command prompt and change directory to CeltixInstallDir/samples/service_creation/hello_world.

  2. Enter the following command to build the .war file for the servlet container:

    ant war
    

    The command produces output similar to the following:

    Buildfile: build.xml
    
    maybe.generate.code:
    
    compile:
    
    build:
    
    war:
        [mkdir] Created dir: C:\Programs\Celtix\samples\service_creation\hello_world\build\war
          [war] Building war: C:\Programs\Celtix\samples\service_creation\hello_world\build\war\hell
    oworld.war
    
    BUILD SUCCESSFUL
    Total time: 2 seconds
    

    The result of running this command is a file, helloworld.war, which is stored in the hello_world/build/war subdirectory.

Deploy the .war file

To deploy the .war file, copy the helloworld.war file to the Tomcat webapps directory, as follows:

Windows:

> copy CeltixInstallDir\samples\service_creation\hello_world\build\war\helloworld.war CeltixInstallDir\containers\servlet\webapps

UNIX:

% cp  CeltixInstallDir/samples/service_creation/hello_world/build/war/helloworld.war CeltixInstallDir/containers/servlet/webapps

Start the Web server

To start the Tomcat Web server, enter the following command:

Windows:

> tomcat_start

UNIX:

% tomcat_start.sh

As the Tomcat server starts up, it automatically loads and deploys the helloworld.war file from the webapps directory.

Run the client

To run the client using ant, you need to provide the base URL of the deployed servlet as a parameter. The base URL is simply an URL of the form http://Hostname:Port that accesses the Tomcat root page. For example, if the base URL is http://localhost:8080, you can run the client with the following ant command:

ant client-servlet -Dbase.url=http://localhost:8080

Alternatively, instead of using the ant command, you can run the client directly using the java command. Assuming that the ./build/classes directory is on your CLASSPATH, you can change directory to the samples/service_creation/hello_world directory and enter the following command:

Windows:

> java -Djava.util.logging.config.file=%CELTIX_HOME%\etc\logging.properties
demo.hw.client.Client http://localhost:8080/helloworld/services/hello_world?wsdl

UNIX:

% java -Djava.util.logging.config.file=$CELTIX_HOME/etc/logging.properties
demo.hw.client.Client http://localhost:8080/helloworld/services/hello_world?wsdl

In this case, the parameter provided to the client is the WSDL query URL for the Greeter service, not just the base URL. This command produces output similar to the following:

http://localhost:8080/helloworld/services/hello_world?wsdl
Invoking sayHi...
Server responded with: Bonjour

Invoking greetMe...
Server responded with: Hello fbolton

Invoking greetMe with invalid length string, expecting exception...

Invoking greetMeOneWay...
No response from server as method is OneWay

Invoking pingMe, expecting exception...
Expected exception: PingMeFault has occurred: PingMeFault raised by
server
FaultDetail major:2
FaultDetail minor:1