The TableOfContents.doc in $NX_ROOT/samples/sdk/websvc lists several Java sample programs.
Each sample program contains notes on how it can be compiled and run using the script files run_java_test_bat.txt (Windows) and run_java_test_sh.txt (UNIX). These scripts demonstrate how to use org.apache.axis.wsdl.WSDL2Java to generate the CA SDM web services client-side stub files.
The –w parameter is required to properly generate the stub files when using Axis 1.4. Running WSDL2Java as shown will generate the stub files in subdirectory com/ca/www/UnicenterServicePlus/ServiceDesk. The following files are generated:
Import these classes with the following statement:
import com.ca.www.UnicenterServicePlus.ServiceDesk.*;
Many Web Service methods have parameters of type ArrayOfString, a proprietary class. For example, the createRequest() method’s attrVals, propertyValues and attributes parameters are all ArrayOfString parameters.
To set the values in an ArrayOfString variable, instantiate the variable and then use setString() as follows:
ArrayOfString attrVals = new ArrayOfString();
attrVals.setString(new String[]{"customer", customerHandle, "description", "description text"});
To set it to empty
attrVals.setString(new String[0]);
Use a variable of type ListResult, another proprietary class, as the return value from the List methods: doQuery(), getRelatedList(), getNotificationsForContact(), getPendingChangeTaskListForContact() and getPendingIssueTaskListForContact(). A ListResult contains listHandle and listLength elements, which can be retrieved using getListHandle() and getListLength() as shown in this example:
ListResult doQueryResult = new ListResult(); doQueryResult = USPSD.doQuery(sid, "iss", "active = 1"); int listHandle = doQueryResult.getListHandle(); int listLength = doQueryResult.getListLength();
The getListValues() method uses the listHandle, retrieving the values from a subset of the list.
The Handles parameter of the freeListHandles() method is an ArrayOfInt, another proprietary class. Call freeListHandles() using the listHandle taken from a ListResult:
ArrayOfInt handleList = new ArrayOfInt();
handleList.setInteger(new java.lang.Integer []{ new java.lang.Integer(listHandle) });
USPSD.freeListHandles(sid, handleList);
Some methods have pass by reference parameters of type javax.xml.rpc.holders.StringHolder. For example, createRequest() has two parameters of this type, NewRequestHandle and NewRequestNumber.
StringHolder NewRequestNumber = new StringHolder(); StringHolder NewRequestHandle = new StringHolder(); String result; result = USPSD.createRequest(sid, creatorHandle, attrVals, propertyValues, template, attributes, NewRequestHandle, NewRequestNumber);
The Request’s handle and reference number (ref_num) can then be obtained from NewRequestHandle.value and NewRequestNumber.value respectively.
|
Copyright © 2013 CA.
All rights reserved.
|
|