Previous Topic: ca_pam_getSOAPData(serviceURL, methodName, inlineText, soapVersion, stripXMLNamespacesFromResponse, callBack)Next Topic: XML Parsing


Example: SOAP Method

This example uses the CA Process Automation getStartRequestForms web service method to populate a table with all Start Request Forms in the Library . The getStartRequestForms web service method returns all the start request forms to a specified folder.

Note: This method uses the ca_pam_convertXMLToJSObject(xmlString, elementTagName) method (described later in this section) to create a JavaScript object from XML.

  1. Create an interaction request form and design it as the following illustration shows:

    SOAP Method in a form

  2. Add the following fields to the interaction request form:
    soapService

    Set this field to the following URL:

    http://hostname:portNumber/itpam/soap
    
    soapAction

    Set this field to getStartRequestForms.

    soapData

    Populate this text area with the following code:

    <tns:getStartRequestForms xmlns:tns="http://www.ca.com/itpam">
     <tns:auth>
      <!--xsd:Choice Type-->
      <tns:token>token__</tns:token>
      <tns:user>pamadmin</tns:user>
      <tns:password>pamadmin</tns:password>
     </tns:auth>
     <tns:filter>
      <tns:lookUpPath isRecursive="true">/</tns:lookUpPath>
     </tns:filter>
    </tns:getStartRequestForms>
    
    retrieveSRF

    Set the onClick attribute of this check box to the ca_fd.js.retreiveSRFAndPopulateTable() value.

  3. Create a table named srfs.
  4. Add name and refPath text fields as columns to the srfs table.
  5. Add the following text in the Script section of the form:
    { 
      retreiveSRFAndPopulateTable: function() 
        { 
           var callBack = new Object();
           callBack.onSuccess = function(result)
             {
                var srfResult = ca_pam_ convertXMLToJSObject (result,'startRequest');
                var tableArray = new Array();
                for( i=0;i<srfResult .length;i++)
                  {
                     var object = new Object();
                     object.name = srfResult [i]["name"];
                     object.refPath = srfResult [i]["refPath"];
                     tableArray[i] = object ;
                  }
                ca_pam_clearTableData('Form.srfs',0,ca_pam_getTableRowCount('Form.srfs')-1);
                ca_pam_setTableDataFromJSObject('Form.srfs',tableArray);
             }
           callBack.onFailure = function(caught)
             {
                alert(caught);
             }
           ca_pam_getSOAPData(ca_pam_getTextFieldValue('Form.soapService'),ca_pam_getTextFieldValue('Form.soapAction'),ca_pam_getTextFieldValue('Form.soapData'),'SOAP_1_1',true,callBack);
        }
    }
    
  6. Click Save.
  7. To have CA Process Automation verify that the srfs table is populated dynamically with data, select the Check Box.

The script runs when the checkbox value is changed. The script populates the srfs table dynamically with the start request forms returned by the SOAP call. The getSOAPData method is used to make a SOAP query to retrieve the data and the convertXMLToJSObject is used to convert the response XML into a JavaScript object. The JavaScript object can then be used to populate the table dynamically by using the ca_pam_setTableDataFromJSObject method.