SOAP request

  • I'm trying to test a SOAP request from powershell, but getting an error. I goggled error but solutions don't seem to be working... any suggestions to fix?


    Reading and converting file to XmlDocument: c:\miscjunk\soap-W.txt

    Sending SOAP Request To Server:

    Initiating Send.

    Send Complete, Waiting For Response.

    Exception calling "GetResponse" with "0" argument(s): "The underlying connection was closed: The connection was closed unexpectedly."



    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()

    write-host “Send Complete, Waiting For Response.”
    $resp = $soapWebRequest.GetResponse()
    $responseStream = $resp.GetResponseStream()
    $soapReader = [System.IO.StreamReader]($responseStream)
    $ReturnXml = [Xml] $soapReader.ReadToEnd()

    write-host “Response Received.”

    return $ReturnXml

    function Execute-SOAPRequestFromFile
    [String] $SOAPRequestFile,
    [String] $URL
    write-host “Reading and converting file to XmlDocument: $SOAPRequestFile”
    $SOAPRequest = [Xml](Get-Content $SOAPRequestFile)

    return $(Execute-SOAPRequest $SOAPRequest $URL)

    $x = Execute-SOAPRequestFromFile -SOAPRequestFile c:\miscjunk\soap-W.txt -URL ""
  • Thanks for posting your issue and hopefully someone will answer soon.

    This is an automated bump to increase visibility of your question.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply