Consuming web services in asp.net using http post
Hi, I am trying to do a HTTPS POST of an xml file to the server and get the response back, by using HttpWebRequest and HttpWebResponse. Whenever I run the progran, I get an internal server 500 error on the line:
Dim resp As HttpWebResponse = CType(req.GetResponse(), HttpWebResponse)
Here is the complete code:
Try
Dim doc As XmlDocument = New XmlDocument
doc.Load("C:\Inetpub\wwwroot\testxml\XMLRequest.xm l")
Dim req As HttpWebRequest = CType(WebRequest.Create("https://www.test.com/TESTXML/XML.asmx/TESTXML"), HttpWebRequest)
req.ContentType = "text/xml"
req.Accept = "text/xml"
req.Method = "POST"
Dim stm As Stream = req.GetRequestStream()
doc.Save(stm)
stm.Close()
**** I am getting error on this line
Dim resp As HttpWebResponse = CType(req.GetResponse(), HttpWebResponse)
****
stm = resp.GetResponseStream()
Dim r As StreamReader = New StreamReader(stm)
Response.Write(r.ReadToEnd())
Catch WebExcp As WebException
End Try
I checked with the service provider, they have http get protocol commented in the machine.config file, only http post is uncommented. They say that they cannot uncomment http get protocol, is there a way to invoke the web service that has http get commented ?
Thanks in advance.
|