AnsweredAssumed Answered

ExecuteProcess SOAP call to PAM from PowerShell

Question asked by rob.mccoy on Apr 11, 2014
Latest reply on Apr 11, 2014 by rob.mccoy

First, I'm not a programmer. I have as much knowledge of what SOAP is and how it works as I do about what happens when I turn the key in my ignition.  I've successfully written a c# program to call PAM with SOAP to execute a process, but I'm trying to do the same in PowerShell.  I'm not having much luck.  Does anyone know what I'm doing wrong in this code?

function Execute-SOAPRequest 
( 
        [Xml]    $SOAPRequest, 
        [String] $URL 
) 
{ 
        write-host "Sending SOAP Request To Server: $URL" 
        $soapWebRequest = [System.Net.WebRequest]::Create($URL) 
        $soapWebRequest.Headers.Add("SOAPAction","`"ExecuteC2OFlow`"")

        $soapWebRequest.ContentType = "text/xml;charset=`"utf-8`"" 
        $soapWebRequest.Accept      = "text/xml" 
        $soapWebRequest.Method      = "POST" 
        
        write-host "Initiating Send." 
        $requestStream = $soapWebRequest.GetRequestStream() 
        $SOAPRequest.Save($requestStream) 
        $requestStream.Close() 
        
        write-host "Send Complete, Waiting For Response." 
        $resp = $soapWebRequest.GetResponse() 
        $responseStream = $resp.GetResponseStream() 
        $soapReader = [System.IO.StreamReader]($responseStream) 
        $ReturnXml = [Xml] $soapReader.ReadToEnd() 
        $responseStream.Close() 
        
        write-host "Response Received."
        return $ReturnXml 
}

$url = 'http://ourpamserver/itpam/soap'
$soap = [xml]@'
<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:itp="http://www.ca.com/itpam">
   <soapenv:Header/>
   <soapenv:Body>
      <itp:executeProcess>
         <itp:flow>
            <itp:name>/InboundWebServices/WSSResponderDCA</itp:name>
            <itp:action>start</itp:action>
            <itp:auth>
               <itp:user>myuserid</itp:user>
               <itp:password>mypassword</itp:password>
            </itp:auth>
            <itp:params>
               <itp:param name="Mozart">Symphony</itp:param>
            </itp:params>
         </itp:flow>
      </itp:executeProcess>
   </soapenv:Body>
</soapenv:Envelope>
'@

$ret = Execute-SOAPRequest $soap $url 

 

Outcomes