Testing the Web Service by Using a Client Application - XML

The following code calls the Web service:

The preceding code creates new Service and Call objects, which are JAX-RPC objects. These objects store metadata about the Web service that you need to invoke.

If you have worked with the earlier versions of the Apache SOAP toolkit, you will appreciate the simplicity of the code used in the latest version.

You need to define the URL of the receiver application that receives a SOAP message. In addition, you need to specify the Web service to be invoked by passing parameters to it. The parameters are passed as an array.

The following code sample shows the SOAP message generated when the client application sends a request:

As you see in the preceding code, the value passed as a parameter to the Java client application is serialized into XML. The following code shows the corresponding response for the request. The response is sent from the Web service to the client application:

The Web service validates the number 1111111111111, which you passed for testing, and sends a response. In the preceding response, the Web service finds the number to be invalid.

Remember to shut down and restart the Tomcat server when you copy the .jws file for the first time to the Axis folder or make changes to the .jws file.

As you can see, using .jws files is one of the simplest ways to create Web services. However, in some cases, you might face problems while working with the .jws file. For example, you might experience problems while trying to fit the entire functionality of a Web service into a single .jws file. Similarly, you can run into problems when the code to be deployed is in the form of a class file. In such a case, the deployment can be done using a .wsdd file.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

XML Topics