B
Brent
For the life of me, I cannot understand why I'm getting this error
constantly with the ASP.Net 1.1 code below:
"The underlying connection was closed: An unexpected error occurred on
a receive."
I've tried just about everything I know how to do. My best guess is
that the error is somehow related to an SSL problem, or perhaps a
certificate store policy, while working on a Windows Vista machine.
Could it be that Vista blocks connections differently than XP?
Whatever the case, I have tried various fixes for these problems with
no success.
The code here is complete and ready to paste into a .Net 1.1 console
app. The dummy username and password has no effect on the error I
receive.
Thanks for any help you can give.
--Brent
=======================================================
using System;
using System.Net;
using System.IO;
using System.Text;
using System.Xml;
namespace CallReportsConsole
{
class MainClass
{
public static void Main(string[] args)
{
try
{
string username = "username";
string password = "password";
//Create SOAP XML
StringBuilder sbSoap = new StringBuilder();
//1. Build SOAP string
sbSoap.Append("<? xml version=\"1.0\" encoding=\"utf-8\" ?>");
sbSoap.Append("<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/
XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">");
sbSoap.Append("<soap:Body>");
sbSoap.Append("<TestUserAccess xmlns=\"http://cdr.ffiec.gov/public/
services\">\n");
sbSoap.Append("<user>" + username + "</user>\n");
sbSoap.Append("<password>" + password + "</password>\n");
sbSoap.Append("</TestUserAccess>\n");
sbSoap.Append("</soap:Body></soap:Envelope>");
string soapAction = "http://cdr.ffiec.gov/public/services/
TestUserAccess";
//2. Send XML to CDR server
string cdrURL = "https://cdr.ffiec.gov/pws/
retrievalservice.asmx";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(cdrURL);
req.ContentType = "text/xml; charset=utf-8";
req.Accept = "text/xml";
req.Method = "POST";
req.ContentLength = sbSoap.Length;
req.Headers.Add("SOAPAction", soapAction);
req.KeepAlive = false;
Stream strm = req.GetRequestStream();
byte[] bytes =
System.Text.Encoding.ASCII.GetBytes(sbSoap.ToString());
strm.Write(bytes, 0, bytes.Length);
strm.Close();
//3. Get response & send back filename
HttpWebResponse resp =
(HttpWebResponse)req.GetResponse();
StreamReader r = new
StreamReader(resp.GetResponseStream());
XmlTextReader xmlRead = new XmlTextReader(r);
while (xmlRead.Read())
{
Console.Write(xmlRead.Value.ToString());
}
r.Close();
strm.Close();
}
catch (WebException wex)
{
Console.Write(wex.ToString());
Console.Write(wex.Message.ToString());
}
catch (Exception ex)
{
Console.Write(ex.ToString());
Console.Write(ex.Message.ToString());
}
}
}
}
constantly with the ASP.Net 1.1 code below:
"The underlying connection was closed: An unexpected error occurred on
a receive."
I've tried just about everything I know how to do. My best guess is
that the error is somehow related to an SSL problem, or perhaps a
certificate store policy, while working on a Windows Vista machine.
Could it be that Vista blocks connections differently than XP?
Whatever the case, I have tried various fixes for these problems with
no success.
The code here is complete and ready to paste into a .Net 1.1 console
app. The dummy username and password has no effect on the error I
receive.
Thanks for any help you can give.
--Brent
=======================================================
using System;
using System.Net;
using System.IO;
using System.Text;
using System.Xml;
namespace CallReportsConsole
{
class MainClass
{
public static void Main(string[] args)
{
try
{
string username = "username";
string password = "password";
//Create SOAP XML
StringBuilder sbSoap = new StringBuilder();
//1. Build SOAP string
sbSoap.Append("<? xml version=\"1.0\" encoding=\"utf-8\" ?>");
sbSoap.Append("<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/
XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"
xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">");
sbSoap.Append("<soap:Body>");
sbSoap.Append("<TestUserAccess xmlns=\"http://cdr.ffiec.gov/public/
services\">\n");
sbSoap.Append("<user>" + username + "</user>\n");
sbSoap.Append("<password>" + password + "</password>\n");
sbSoap.Append("</TestUserAccess>\n");
sbSoap.Append("</soap:Body></soap:Envelope>");
string soapAction = "http://cdr.ffiec.gov/public/services/
TestUserAccess";
//2. Send XML to CDR server
string cdrURL = "https://cdr.ffiec.gov/pws/
retrievalservice.asmx";
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(cdrURL);
req.ContentType = "text/xml; charset=utf-8";
req.Accept = "text/xml";
req.Method = "POST";
req.ContentLength = sbSoap.Length;
req.Headers.Add("SOAPAction", soapAction);
req.KeepAlive = false;
Stream strm = req.GetRequestStream();
byte[] bytes =
System.Text.Encoding.ASCII.GetBytes(sbSoap.ToString());
strm.Write(bytes, 0, bytes.Length);
strm.Close();
//3. Get response & send back filename
HttpWebResponse resp =
(HttpWebResponse)req.GetResponse();
StreamReader r = new
StreamReader(resp.GetResponseStream());
XmlTextReader xmlRead = new XmlTextReader(r);
while (xmlRead.Read())
{
Console.Write(xmlRead.Value.ToString());
}
r.Close();
strm.Close();
}
catch (WebException wex)
{
Console.Write(wex.ToString());
Console.Write(wex.Message.ToString());
}
catch (Exception ex)
{
Console.Write(ex.ToString());
Console.Write(ex.Message.ToString());
}
}
}
}