Creating an Apache Axis web service client
- Create a basic web service named SimpleWebService.
- Install JDK 1.8.45 or later.
- Ensure that java and javac commands are included in the PATH.
- Install Apache Axis 1.x from http://xml.apache.org/axis.
- Install Xerces2 Java Parser 2.2.0 from http://xml.apache.org/xerces2-j/index.html.
Install JavaServer Pages 1.2 class files from http://java.sun.com/products/jsp/download.html.
Set CLASSPATH to include Axis and Xerces JAR files as follows:
set AXIS_DIR=<axisInstallDir>
set AXIS_LIB_DIR=%AXIS_DIR%\lib
set XERCES_DIR=<xercesInstallDir>
set JSP_DIR=<jspInstallDir>
set CLASSPATH=.;%AXIS_LIB_DIR%\axis.jar;%AXIS_LIB_DIR%\saaj.jar;%AXIS_LIB_DIR%\ log4j-1.2.4.jar;%AXIS_LIB_DIR%\wsdl4j.jar;%AXIS_LIB_DIR%\commons-discovery.jar;%AXIS_LIB_DIR%\jaxrpc.jar;%AXIS_LIB_DIR%\commons-logging.jar;%XERCES_DIR%\xercesImpl.jar;%XERCES_DIR%\xmlParserAPIs.jar; %JSP_DIR%\servlet.jar- Create a directory for building an Axis web service client (for example, C:\temp\axisclient).
- Change directory to C:\temp\axisclient.
At the command prompt, enter the following command:
java org.apache.axis.wsdl.WSDL2Java -W -p ARWSClient http://<midTierServer>/arsys/WSDL/<arServer>/SimpleWebServiceThis command generates proxy classes for writing the client program.
- Create a directory for storing the class files (for example, C:\temp\axisclient\classes).
- Change directory to ARWSClient.
Create a new file called TestClient.java and add the following lines of code:
/**
* TestClient.java
*
*/
package ARWSClient;
import javax.xml.rpc.holders.StringHolder;
import javax.xml.rpc.holders.CalendarHolder;
public class TestClient {
public static void main(String args[]) throws Exception
{
SimpleWebServicePortType binding;
binding = new SimpleWebServiceServiceLocator().getSimpleWebServiceSoap();
// declare variables
CreateInputMap createInput = new CreateInputMap();
// supply values for creating an entry using OpCreate
createInput.setAssigned_To("Frank");
createInput.setShort_Description("Testing Axis Client");
createInput.setStatus(StatusType.New);
createInput.setSubmitter("Joe");
// make web service request to create an entry
CreateOutputMap createOuput = binding.opCreate(createInput);
System.out.println("Successfully created a request with id: " + createOuput.getRequest_ID());
// declare additional variables for get operation
GetInputMap getInput = new GetInputMap();
getInput.setRequest_ID(createOuput.getRequest_ID());
ARWSClient.GetOutputMap getOutput;
getOutput = binding.opGet(getInput);
System.out.println();
System.out.println("Following values have been returned by OpGet");
System.out.println();
System.out.println("Request_ID : " + getOutput.getRequest_ID());
System.out.println("Assigned_To : " + getOutput.getAssigned_To());
System.out.println("Create_Date : " + getOutput.getCreate_Date().getTime());
System.out.println("Last_Modified_By : " + getOutput.getLast_Modified_By());
System.out.println("Modified_Date : " + getOutput.getModified_Date().getTime());
System.out.println("Short_Description : " + getOutput.getShort_Description());
System.out.println("Status : " + getOutput.getStatus());
System.out.println("Status_History : " + getOutput.getStatus_History());
System.out.println("Submitter : " + getOutput.getSubmitter());
}
}- Enter the following command:
javac -d ..\classes *.java - Open the BMC Remedy Mid Tier Configuration Tool, and under WebService Settings, enter an anonymous user name (for example, Demo), leaving the password blank.
- Change directory to ..\classes.
- Enter the following command to run the client:
java ARWSClient.TestClient
Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*