K
Kevin Schneider
I am trying to POST an XML string to a Java servlet, but I am getting
the error "The underlying connection was closed: An unexpected error
occurred on a receive." when I try to get the response. Here's the
relevant code (some of the names have been changed to protect the
innocent):
string lcUrl = "http://10.10.10.10:8503/Servlet";
HttpWebRequest loHttp = (HttpWebRequest) WebRequest.Create(lcUrl);
loHttp.Method="POST";
byte [] lbPostBuffer =
System.Text.Encoding.GetEncoding(1252).GetBytes(xmlRequest);
loHttp.ContentType = "text/xml";
loHttp.ContentLength = lbPostBuffer.Length;
//Send the POST data
Stream loPostData = loHttp.GetRequestStream();
loPostData.Write(lbPostBuffer,0,lbPostBuffer.Length);
loPostData.Close();
//////////
//Exception happens here
HttpWebResponse loWebResponse = (HttpWebResponse)
loHttp.GetResponse();
///////
Encoding enc = System.Text.Encoding.GetEncoding(1252);
StreamReader loResponseStream = new
StreamReader(loWebResponse.GetResponseStream(),enc);
string lcHtml = loResponseStream.ReadToEnd();
loWebResponse.Close();
loResponseStream.Close();
The XML data looks is
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
<ContactRequestElementDO>
<ContactSearchDO>
<ProductInstID>BBCB7987</ProductInstID>
</ContactSearchDO>
</ContactRequestElementDO>"
Any ideas?
the error "The underlying connection was closed: An unexpected error
occurred on a receive." when I try to get the response. Here's the
relevant code (some of the names have been changed to protect the
innocent):
string lcUrl = "http://10.10.10.10:8503/Servlet";
HttpWebRequest loHttp = (HttpWebRequest) WebRequest.Create(lcUrl);
loHttp.Method="POST";
byte [] lbPostBuffer =
System.Text.Encoding.GetEncoding(1252).GetBytes(xmlRequest);
loHttp.ContentType = "text/xml";
loHttp.ContentLength = lbPostBuffer.Length;
//Send the POST data
Stream loPostData = loHttp.GetRequestStream();
loPostData.Write(lbPostBuffer,0,lbPostBuffer.Length);
loPostData.Close();
//////////
//Exception happens here
HttpWebResponse loWebResponse = (HttpWebResponse)
loHttp.GetResponse();
///////
Encoding enc = System.Text.Encoding.GetEncoding(1252);
StreamReader loResponseStream = new
StreamReader(loWebResponse.GetResponseStream(),enc);
string lcHtml = loResponseStream.ReadToEnd();
loWebResponse.Close();
loResponseStream.Close();
The XML data looks is
"<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
<ContactRequestElementDO>
<ContactSearchDO>
<ProductInstID>BBCB7987</ProductInstID>
</ContactSearchDO>
</ContactRequestElementDO>"
Any ideas?