// Post the Request.
httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
// If the submission is success, Status Code would be OK
if (httpWebResponse.StatusCode == HttpStatusCode.OK){
// Read response
responseStream = httpWebResponse.GetResponseStream();
if (responseStream != null){
var objXmlReader = new XmlTextReader(responseStream);
// Convert Response stream to XML
var xmldoc = new XmlDocument();
xmldoc.Load(objXmlReader);
xmlResponse = xmldoc;
objXmlReader.Close();
}
}
// Close Response
httpWebResponse.Close();
}
catch (WebException webException)
{
throw new Exception(webException.Message);
}
catch (Exception exception)
{
throw new Exception(exception.Message);
}
finally
{
// Release connections
if (requestStream != null){
requestStream.Close();
}
if (responseStream != null){
responseStream.Close();
}
if (httpWebResponse != null){
httpWebResponse.Close();
}
}
Leave a comment