Submitting Server Requests
Requests are submitted to the server using the executeServerRequests WCC public method.
this.executeServerRequests(socketId, arrRequests, asyncClass, asyncFunction);
where:
- socketId - (String) Information identifying this particular set of requests. The socketIds can be reused, although if the application will be making requests asynchronously, it must make sure no two outstanding requests have the same socketId.
- arrRequests (Array[Objects]) An array of request objects created using the server requests that are documented in Server Request Reference.
More about creating the request object is provided below.
- asyncClass (Object) (optional) This is specified if the response is to be returned asynchronously. It identifies the class/object that contains the function that is called once the response has come back from the server.
- asyncFunction (String) (optional) This is specified if the response is to be returned asynchronously. It identifies the name of the function that is called once the response has come back from the server.
To execute a server request, you must first create a request object using one of the server requests (for a complete list of the available server requests, see Server Request Reference). For example:
var request = com.tibco.wcc.base.Requests.getUserPrivileges(requestId, txtResourceGuid);
The parameters specified for each request vary, depending on the request — they provide the input for the server request. For instance, the txtResourceGuid parameter for the getUserPrivileges request shown above identifies the specific user whose privileges are to be returned.
Most parameters are simple strings, numbers, or boolean values, although in some cases, a parameter may be a JavaScript object with certain properties and values, or an array of strings or JavaScript objects.
All requests have requestId as one of the parameters. Multiple requests can be submitted to the server at one time, and it is also possible to make requests asynchronously. This requestId is echoed in the response to help your code match up the response with the request.
If you do not supply the optional parameters of asyncClass and asyncFunction in the call to executeServerRequests, the method call returns a jsx3.xml.Document object containing the server response.
If the optional parameters are specified, the method call returns nothing. Later, when the response arrives from the server, the specified function (asyncFunction parameter) in the specified class (asyncClass parameter) is called. The function should be set up with two parameters:
- socketId (String) The socketId that was submitted when executeServerRequests was called.
- oResponseXml (jsx3.xml.Document) A TIBCO General Interface XML Document that contains response information for all of the requests, or possible error information if any of the requests could not be successfully executed.