In most real-life situations, deploying a Web service as a .jws file is insufficient. This implies that these Web services are not able to meet the requirements of a real-life Web service, such as the ability to specify custom type mappings or create handler chains. Therefore, in such complicated cases, a deployment file, as shown in the following code, is used:Save the file as deploy.wsdd.
In the preceding code, we created a new Web service that uses the Java class: CCheck. Then, the code exposes the isValid() method.
You can expose several methods in the preceding code. To do so, you need to separate the names of methods with spaces.
The next step is to deploy the Web service. The steps to do so are as shown:
In this case, the requestor and provider applications (endpoints in a Web services scenario) are AxisServlet instead of .jws files. Now, the servlet locates and creates an instance of the class that corresponds to the service name CCheckServer. Next, the servlet converts the SOAP messages into Java calls and invokes the Java calls on the instantiated service class.
Testing the Web Service
Now you can test the Web service created in the previous section by using a client application. The client application used in this case is similar to the client application used to test the Web service in which the endpoints were .jws files. However, please note the change in the endpoint.
The differences in the preceding code and the code used to call a Web service with endpoints as .jws files are in bold type.
Creating a Client Application by Using Axis Tools
In addition to the client application discussed in the previous section, you can create a client application by using the tools that the Axis toolkit provides. You can then use this client application to test the Web service.
To create a client application by using the tools in the Axis toolkit, you first need to create a proxy class for the Web service. To do this, use the following command:
The preceding code uses the Wsdl2java command. Some of the commonly used options with the Wsdl2java command are discussed in Table.
Options Used with the Wsdl2java Command
When you execute the Wsdl2java command, a folder named proxy, which contains three files, is created. The files in the proxy folder represent the SOAP bindings, the port type, and the Web service proxy class. In addition, the Wsdl2java command creates the following:
The following section discusses the contents of these files in detail.
File That Contains Port Types
As discussed, the Wsdl2java command creates a file that contains a Java class, CCheckServerPortType.Java. The code for this file is as follows:
File That Contains Bindings
In addition, a file that contains stubs is created. The content of the CCheckServerSoapBinding Stub.java file is as follows:
File That Contains the Web Service Proxy Interface Class
The Wsdl2java command creates a file that contains the code for the Web service proxy class. The content of the CCheckServer.Java file is shown in the following code:
File That Contains the Web Service Proxy Implementation
A client program does not instantiate a stub; it would rather instantiate a service locator class, which exposes a method that would return a stub. This locator class implements the service interface class shown earlier. Following is the code for a service locator class for the CCheck Web service:
Compiling the Files That the Wsdl2java Command Created
When these files are created, you need to compile them in the following order:
Create a Client Application That Uses the Files
Next, you need to create a client application that calls the Web service by using the classes that are contained within the three files discussed in the previous sections. The code for the client application is as follows:
XML Related Interview Questions
|Soap Tool Interview Questions||HTML Interview Questions|
|PHP Interview Questions||ASP.NET Interview Questions|
|PHP5 Interview Questions||Java Interview Questions|
|CSS Interview Questions||XSLT Interview Questions|
|Java XML Interview Questions||XMLHttpRequest (XHR) Interview Questions|
|ebXML Interview Questions||XML DOM Interview Questions|
|XML-RPC Interview Questions||XSD Interview Questions|
|Soap Web Services Interview Questions||XSL Interview Questions|
|Xml Publisher Interview Questions|
All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.