The Hello Web Service XML

In the previous section, we gave an example of a message service. This section discusses another example, the Hello Web service. You will create and deploy the Hello Web service by using JWSDP.

The HelloIF Interface

You need to create an interface HelloIF, which exposes the service method in a hello directory. The HelloIF interface needs to extend the Remote interface. The HelloIF interface exposes a single method that clients can invoke. The following code listing illustrates the HelloIF interface:

Next, you need to implement the HelloIF interface in a Java class, HelloImpl. The following code listing illustrates the HelloImpl. java class:

package hello; public class HelloImpl implements HelloInf { public String hello(String username) { return new String("Hello " + username +" Welcome to the Hello Web service!!!"); } }

build.xml File

You can compile, package, and deploy the Hello service by using the Ant Build tool. To do this, create the build.xml file that the Ant tool uses as the build file. Place the build.xml file in the hello directory. The following code listing illustrates the build.xml file: File

Create a file in your hello directory. The build.xml file uses the file to build your service. The following code listing displays the content of the file:

Compiling the Interface

Next, you need to compile the interface and the implementation files by using the Ant tool. You can do so by executing the following command:

ant compile

After the successful execution of this command, verify the presence of two class files in the uildhello directory.


You should run the preceding command from the directory where the build.xml file for the Hello Web service is stored.

Configuration File

The next step is to create the config.xml file. The xrpcc tool uses the config.xml file to generate stubs and ties of your implementation class. The xrpcc tool also generates a WSDL file corresponding to the interface.

The code of the config.xml file is as displayed:

Now you should run the following command:

xrpcc.bat -classpath build -both -d build config.xml

The following classes are generated in the ./build/hello directory:

  • Hello_RequestStruct.class
  • Hello_RequestStruct_SOAPSerializer.class
  • Hello_ResponseStruct.class
  • Hello_ResponseStruct_SOAPSerializer.class
  • HelloInf Stub.class
  • HelloInf_Tie.class
  • MyHello.class
  • MyHello_Impl.class
  • MyHello_SerializerRegistry.class

In addition, the WSDL file, HelloService, is generated in the ./build directory. The build directory also contains a My Hello _ Config .properties file.

Packaging the Service

After you generate the required files, you need to package the service as a WAR file and deploy it in the Tomcat container of the JWSDP pack. To package your service, run the following command:

ant package

Notice the jaxrpc-hello.war file in your hello directory. Run the following command to deploy your service in the Tomcat container:

ant deployservice

The jaxrpc-hello.war file is copied in the webapps directory of your JWSDP installation. Run the following command to start the Tomcat container:


Open your browser and type the following address in the address bar:


A page appears indicating that your service is deployed, as shown in Figure.

The Web Service Has been Deployed

The Web Service Has been Deployed

Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd Protection Status

XML Topics