The CA Gen Web Service Wizard (WSW) allows you to create a web service that can be used to provide access to an CA Gen server load module. You must first generate a Java Proxy (with the XML interface selected) for the server load module. Then the WSW can be used to generate a web service that invokes the Java Proxy.
The WSW generates the following five files, along with the other necessary files to build and deploy the web service:
<web_service_name>.java - This file contains the source code for the web service. It prepares the XML message to send to the Java Proxy, calls the Java Proxy, and receives the XML message returned from the Java Proxy.
<web_service_name>Client.java - This file contains the source code for a sample client that invokes the web service. This is just an example to show how the web service can be called and is provided as a way to quickly test the web service. It prepares the SOAP message to send to the web service, calls the web service, and receives the SOAP message returned from the web service.
<web_service_name>.wsdl - This file contains the Web Service Definition Language for the web service. It describes the web service so programs will know how to communicate with this web service.
<web_service_name>Deploy.wsdd - This file contains a Web Service Deployment Descriptor for the web service that can be used to register the web service with Apache Axis.
<web_service_name>Undeploy.wsdd - This file contains a Web Service Deployment Descriptor for the web service that can be used to unregister the web service with Apache Axis.
Modifying the sample web service client:
The Web Service Wizard Guide describes all of the above files and explains how to use the WSW to generate a web service. This article will focus mainly on the sample client file since it usually requires modifications and it must be compiled before it can be used.
The first modification you may need to make to the sample client file is to populate the import views for the server Procedure Step. In the "main" method at the bottom of the file, there will be statements to set each import view attribute. Modify these statements so that the desired data is sent to the import views. Pay particular attention to any Date, Time, or Timestamp attributes since the WSW does not populate these types of attributes with valid values. It only populates these types of attributes with strings showing the possible formats for the data. Change these strings to have valid dates, times, or timestamps.
The second modification you may need to make to the sample client file is to specify the character set that will be used to display the web service's SOAP messages. In the "main" method at the bottom of the file, there will be a variable named "charsetName". By default, this variable is set to the value of the system's file encoding property. This default setting may be sufficient for your environment, but if it is not then you will need to modify this variable's value.
The value you choose for the "charsetName" variable really depends upon how you plan to view the SOAP messages sent to/returned from the web service. If you plan to just let the output be displayed in a DOS window, then you may need to use the DOS character set for your environment. If you decide to pipe the output to a file and view the contents of the file using an editor like Notepad, then you may need to use the Windows character set for your environment.
The main thing to understand is that you need to have the sample client write out the SOAP messages using the same character set that you intend to use to view the messages. In other words, if you intend to view the SOAP messages in a DOS window, then you need to tell the sample client to write out the messages using the DOS character set for your environment.
The SOAP messages sent to/returned from the web service are always in UTF-8. The sample client just needs to be told how you want this data to be displayed. See the J2EE documentation on the Charset class to determine the appropriate "charsetName" value to use for your environment.
Building and executing the sample web service client:
Once you have made all of the necessary modifications to the sample client file, you will need to compile the sample client file. You do this using the "javac" command as described in the Web Service Wizard Guide and also shown below:javac -classpath <path to saaj.jar> <web_service_name>Client.java
Once you have successfully compiled the sample client file, you are ready to execute it. You do this by using the "java" command as described in the Web Service Wizard Guide and also shown below:java -cp %ClientClassPath% <web_service_name>Client
Running this command as shown above will send the output to the DOS window where the command was executed. If you prefer to have the output sent to a file, you can pipe the output to a file as shown below:java -cp %ClientClassPath% <web_service_name>Client >> c:\output.txt
Modifying the Web Service Wizard templates:
The WSW was designed with the understanding that certain customizations may need to be made to the generated web services depending upon each customer's specific requirements. For this reason, the majority of the generated source is built using templates. These templates can be modified to add customizations as required. Then the WSW will use the modified templates to generate the customized code. The templates can be found in the "Templates" directory underneath the directory where the WSW was installed.
As an example, let's assume that you have determined the appropriate "charsetName" value for your environment and now you want to modify the WSW templates so that the appropriate value will be used in all future sample clients that you generate with the WSW. To do this, you would modify the WebServicePluginSampleClientTemplate.java template to set "charsetName" to the desired value. The next time you generate a web service, the new value will be used in the generated sample client.
The Web Service Wizard Guide contains information about the purpose of each template to help you determine which template to modify. NOTE: It is recommended that you always make a backup copy of any template before modifying it.