次のコードでRESTfulサービスを呼び出すと、エラーが発生します
基になる接続が閉じられました:受信時に予期しないエラーが発生しました。
コード:
Const url As String = "http://localhost:8003/Tracker/Tracker.svc/GetTrackerDetails"
ServicePointManager.MaxServicePointIdleTime = 500
ServicePointManager.UseNagleAlgorithm = True
ServicePointManager.Expect100Continue = True
ServicePointManager.CheckCertificateRevocationList = True
ServicePointManager.DefaultConnectionLimit = ServicePointManager.DefaultPersistentConnectionLimit
req = DirectCast(WebRequest.Create(url), HttpWebRequest)
req.Method = "POST"
req.ContentType = "application/xml; charset=utf-8"
req.Timeout = 300000
req.KeepAlive = False
req.Headers.Add("SOAPAction", url)
Dim xmlDoc = New XmlDocument With {.XmlResolver = Nothing}
xmlDoc.Load(Server.MapPath("Request.xml"))
Dim sXml As String = xmlDoc.InnerXml
req.ContentLength = sXml.Length
Dim sw = New StreamWriter(req.GetRequestStream())
sw.Write(sXml)
sw.Close()
res = DirectCast(req.GetResponse(), HttpWebResponse)
Dim responseStream As Stream = res.GetResponseStream()
Dim streamReader = New StreamReader(responseStream)
'Read the response into an xml document
Dim soapResonseXmlDocument = New XmlDocument()
soapResonseXmlDocument.LoadXml(streamReader.ReadToEnd())
TextBox1.Text = Server.HtmlDecode(soapResonseXmlDocument.InnerXml)
soapResonseXmlDocument.LoadXml(TextBox1.Text)
過去数日間、このエラーに直面しています。私の呼び出しコードの何が問題になっていますか。私を助けてください。