Before creating a Web service by using the WSTK, we will discuss the toolkit in general.
The WSTK contains several tools that help you to create, discover, and invoke a Web service. These tools are explained in the following list:
Creating the Web Service
To create a Web service, you first create a Java class file. In this case, because you are creating a credit card validation Web service, you need to use the CCheck.java file. Compile the .java file to create the .class file.
The next step is to create a WSDL file from the class file that you created. To do this, you use the java2wsdl.bat file present in the WSTK_HOMEin folder. Create a folder Ccheck in the < WSTK_HOME> services applications folder. The command to create a WSDL file is shown in the following example:
As you can see, the preceding code uses the java2wsdl command, which has several options, as explained in Table.
Options Used with the java2wsdl Command
The java2wsdl command creates a WSDL file. The content of this file is as shown:
Creating the Deployment Descriptor
The deployment descriptor is a file, usually in the XML format, which stores the data used to deploy a Java application. Version 3.0 of the WSTK uses the old version of the deployment descriptor instead of the WSDD version. Therefore, you need to create the deployment descriptor. You can do this by using the following code:
Creating a Folder Structure for the WSTK
A folder structure for the WSTK includes a root folder containing all Web service files that are deployed by using the WSTK.
You need to create the exact folder structure for each Web service that you deploy using the WSTK. Therefore, it is advisable that you replicate the folder structure for the sample Web services created by using the toolkit to create the folder structure for your Web service.
Whenever you want to deploy a new service, create a new folder under the Applications directory. This folder should contain at least three subdirectories, as discussed in the following list:
The contents of the import.xml file are as shown:
The preceding code uses the fromdir attribute to indicate a path to the source file relative to %WSTK_HOME%. The files identified by the fromdir attribute are copied into the directory indicated by the todir attribute. However, you need to copy the actual class file for the CCheckServer class to the WEB-INFclasses folder.
The WEB-INF folder contains a web.xml file, which is a standard Java Web application deployment descriptor. This file deploys the AxisServlet that is used as the entry point for the service. The contents of the web.xml file are shown in the following code:
Deploying the Web Service
After you create the directory structure, you need to deploy the Web service on the Tomcat server. To do this, perform the following steps:
Selecting the Web Service to be Deployed
Performing these steps deploys the WAR files. Next, you need to perform an additional task:registering the Web service with the Axis toolkit. The following section discusses this.
Registering the Web Service with the Axis Toolkit
Copy the file deploy.bat from one of the sample applications in the <WSTK_HOME> servicesapplications folder and use it to deploy your Web service. The command used to register a Web service with the Axis toolkit is as follows:
In the case of the CCheck Web service, the command would be as follows:
After you execute the previous command, your Web service is ready to be used. You can use the following client code to test the Web service:
However, the steps followed in the previous sections to create and deploy a Web service can be tedious and time consuming, especially when you need to deploy large-scale Web services. Therefore, IBM provides you with a complete commercialIDE, which simplifies greatly the task of building all kinds of J2EE applications, including Web services t,the Websphere Studio Application Developer.
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.