PowerShell script to test interaction with SOAP Web Services
search cancel

PowerShell script to test interaction with SOAP Web Services

book

Article ID: 49239

calendar_today

Updated On:

Products

CA Service Desk Manager CA Service Management - Service Desk Manager

Issue/Introduction

Some customers may want to monitor the status of the CA SDM service to make sure it is up and running.

Some monitoring software can execute PowerShell scripts. This document provides a very basic example on how to do that.

Environment

Release 17.1 or higher
CA Service Desk Manager

Resolution

This document assumes you have some knowledge of Windows PowerShell and the CA Service Desk Manager Web Services API.

Broadcom Support provides this document as an example with no guarantees. Broadcom Support will not assist you with PowerShell. However, we can assist with any queries related to the Service Desk SOAP based Web Services API.

Requirements:

  • Windows Operating System that supports PowerShell 5.1 or later
  • Microsoft Windows PowerShell 5.1 or later on your remote host (where you plan to execute the script)
  • Location of your CA SDM SOAP Web Services WSDL, for example:

http://<example SDM server>:8080/axis/services/USD_R11_WebService?wsdl

  • Create a ps1 file called "test-sdm.ps1".  Edit the file and enter the following:

    # BEGIN SCRIPT

    # This line will create connection to the wsdl.
    $Client = New-WebServiceProxy -Uri 'http://<SDM-SERVER>:8080/axis/services/USD_R11_WebService?wsdl'

    # This line will login to SOAP Web Services
    $sid = $Client.login('<USERID>','<PASSWORD>')

    # This line will display the relevant SID generated for the login
    "SID Value:  " + $sid

    # This line will run a query of all requests and display the first 5 results
    $Client.doSelect($sid, 'cr', 'id > 0', 5, ('ref_num', 'summary'))

    # Logout the given session
    $Client.logout($sid)

    # END SCRIPT

    Substitute the values that are highlighted with the appropriate values from your own implementation

  • Save the file.

  • Open Powershell and cd to the location of the test-sdm.ps1 file.  Run the script, ie: .\test-sdm.ps1

  • You will see a result such as this:
    PS C:\PSTest> .\test-sdm.ps1
    SID Value:  1566374012
    <?xml version="1.0" encoding="UTF-8"?><UDSObjectList>
      <UDSObject>
          <Handle>cr:400001</Handle>
          <Attributes>
              <Attribute DataType="2002">
                  <AttrName>ref_num</AttrName>
                  <AttrValue>22</AttrValue>
              </Attribute>
              <Attribute DataType="2002">
                  <AttrName>summary</AttrName>
                  <AttrValue>test</AttrValue>
              </Attribute>
          </Attributes>
      </UDSObject>
      <UDSObject>
          <Handle>cr:3109</Handle>
          <Attributes>
              <Attribute DataType="2002">
                  <AttrName>ref_num</AttrName>
                  <AttrValue>UAPM:20</AttrValue>
              </Attribute>
              <Attribute DataType="2002">
                  <AttrName>summary</AttrName>
                  <AttrValue>UAPM Event</AttrValue>
              </Attribute>
          </Attributes>
      </UDSObject>

    [Rest of output omitted]
The above output demonstrates the result of running the above script, which involves creating an SID value (1566374012) and invoking the doSelect command to return the first 5 entries in the cr table.  
 
One can search the jsrvr.log for the above SID value to review activity related to the web services session that was created, ie:
03/25 19:39:31.254 [http-nio-8080-exec-5] INFO  usdsda -1 Web Services session created 1566374012; user(TESTUSER); IP(127.0.0.1); session count 10

03/25 19:39:31.254 [http-nio-8080-exec-5] INFO  usdjws65 -1 Web Services session created 1566374012 from caller IP 127.0.0.1

03/25 19:39:31.274 [http-nio-8080-exec-9] INFO  usdsda -1 Web Services session logout 1566374012 from caller IP 127.0.0.1

03/25 19:39:31.274 [http-nio-8080-exec-9] INFO  usdjws65 -1 Web Services session ended 1566374012; user(TESTUSER); IP(127.0.0.1); session count 7

Additional Information

The above is only a sample script that demonstrates basic SOAP access via Powershell and is provided "as is".  Broadcom Support does not warrant the above script for functionality and bears no responsibility for its usage in any environment.  Please take all necessary precautions before running the above script (test in a non-prod environment).  

Broadcom Support is also not permitted to advise or collaborate on the above script, including any further modifications or changes.

A counterpart document for REST Web Services and Powershell testing is available in KB Article 281217.