Can we use Microsoft Windows PowerShell to interact with the CA Service Desk Manager (CA SDM) SOAP based Web Services API?

Document ID : KB000049239
Last Modified Date : 14/02/2018
Show Technical Document Details

Description:

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.

Solution:

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

CA Support provides this document as an example with no guarantees. CA 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 3.0 or later
  • Microsoft Windows PowerShell 3.0 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://localhost:8080/axis/services/USD_R11_WebService?wsdl

Microsoft Documentation: http://technet.microsoft.com/en-us/library/bb978526.aspx

  1. Confirm you have the command-let Invoke-WebRequest

    For example, you can run:
    PS C:\Users\administrator> Get-Help Invoke-WebRequest

  2. Create an input file for the XML:
         mkdir c:\temp     notepad soap.txt     Place contents like the following in the soap.txt file (assuming you are calling login()        <?xml version = "1.0" ?>	       <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"	            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"	            xmlns:xsd="http://www.w3.org/2001/XMLSchema">	        <soap:Body>	        <login xmlns="http://www.ca.com/UnicenterServicePlus/ServiceDesk">	     <username>ServiceDesk</username>	     <password>Passwordr11</password>	   </login>	   </soap:Body>	  </soap:Envelope>	

  3. Run the following code in PowerShell, adjust for your environment ( commands are italicized below)

    First we need to define a HTTP Header Key Value Pair for SoapAction:
        PS C:\Users\administrator> $SoapAction = New-Object "System.Collections.Generic.Dictionary''2[System.String,System.String]"
    PS C:\Users\administrator> $SoapAction.Add("SOAPAction", "")

    Verify the values:
        PS C:\Users\administrator> $SoapAction 
    Key Value --- -----
    SOAPAction

    This command should appear on one line:

    PS C:\Users\administrator> Invoke-WebRequest http://localhost:2000/axis/services/USD_R11_WebService?wsdl -Method Post -Content
    Type "text/xml" -Headers $SoapAction -InFile C:\Temp\soap.txt -OutFile c:\Temp\soapRes.txt

  4. Verify the results in the soapRes.txt output file, they should look like the following:
        <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"    xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body>    <loginResponse	xmlns="http://www.ca.com/UnicenterServicePlus/ServiceDesk"><loginReturn	   xmlns="">713249330</loginReturn></loginResponse></soapenv:Body></soapenv:Envelope>

    In this example 713249330 is the session id, which means a successful login.

    This document is provided with no guarantees and only offered as a sample.