Hello,
I use this function to make a SOAP request to my server:
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","`"`"") $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 }
The soap response is well recived but with the command "$ret | Export-Clixml c:\1.xml;Get-Content c:\1.xml", the XML file contains:
<ObjsVersion="1.1.0.1"xmlns="http://schemas.microsoft.com/powershell/2004/04"><XD> ... </XD></Objs>
Between XD tags I have my xml reponse received from the server except that "<" and ">" are converted
to the html code, "<" and ">".
I'm using select-string cmdlet with -patern option to check the response, but it would be more convenient to use the xml
way like $ret.SelectNodes()
I tried doing a replace on the response before doing the export-clixml, but it doesnt work, how can I do this ?
Thank you :)