 |
.NET Web Services Discussions about .NET XML Web Service technologies including ASMX files, WSDL and SOAP. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the .NET Web Services section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|

October 26th, 2004, 08:52 AM
|
Registered User
|
|
Join Date: Oct 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
xins please, could you provide me a sample to how can I use it.
Thank you.:)
Quote:
quote:Originally posted by xins
"The underlying connection was closed: An unexpected error occurred on a receive."
hii,
i have the same problem as you. please see this page first for the main problem in .NET web.services :
http://support.microsoft.com/default...en-us%3b819450
well i added thos recommended code but it still has the same error in my program so i add some code and it's works, try this :
private string requestpost(String TheURL,string postdata, String TheProxy)
{
Uri uri = new Uri(TheURL);
HttpWebRequest request = (HttpWebRequest) WebRequest.Create(uri);
string page;
try
{
string postsourcedata=postdata;
// start added codes
request.KeepAlive = false;
request.ProtocolVersion=HttpVersion.Version10;
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = postsourcedata.Length;
request.Proxy = System.Net.WebProxy.GetDefaultProxy();
request.AllowAutoRedirect=true;
request.MaximumAutomaticRedirections=10;
request.Timeout=(int) new TimeSpan(0,0,60).TotalMilliseconds;
request.UserAgent="Mozilla/3.0 (compatible; My Browser/1.0)";
// end added codes
Stream writeStream = request.GetRequestStream();
byte[] bytes = System.Text.Encoding.ASCII.GetBytes(postsourcedata );
writeStream.Write(bytes, 0, bytes.Length);
writeStream.Close();
HttpWebResponse response = (HttpWebResponse) request.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader readStream = new StreamReader (responseStream, Encoding.UTF8);
page = readStream.ReadToEnd();
}
catch (Exception ee)
{
page = "fail!";
}
return page;
}
hopefully your troubled solved..
regards,
-xins.
(by the way have u watch LORD OF THE RING : RETURN OF THE KING?)
:)
See u in matrix
|
|

March 9th, 2005, 04:15 AM
|
Registered User
|
|
Join Date: Mar 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
This is an old thread so someone must have an answer to my question.
I am getting the same error as jhause that started this thread 'The underlying connection was closed: An unexpected error occurred on a RECEIVE'
But every advise to this error is a solution to another problem 'The underlying connection was closed: An unexpected error occurred on a SEND'
So if someone knows how to fix the RECEIVE error please post it here.
Since none of the above seems to correct that error for me.
Thanks
|

June 24th, 2005, 12:06 AM
|
Registered User
|
|
Join Date: Jun 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Can U please tell me how can we send SMS from ASP.NET?, Please... Do we need any 3rd party support..?
|

August 17th, 2005, 11:19 PM
|
Registered User
|
|
Join Date: Aug 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi All,
this "The underlying connection was closed" often comes when you access the something of which you don't have access.
DSBisht
|

October 12th, 2005, 09:19 AM
|
Registered User
|
|
Join Date: Oct 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi guys,
I had the same problem as okll and found that the ACLs on the target file were too restrictive. (Thanks for the help, Dinesh!) Unfortunately this has not solved the problem, though. I am still on the trail....
|

October 12th, 2005, 11:46 AM
|
Registered User
|
|
Join Date: Oct 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
SOLUTION?
I wrote a utility to test the faulty sites: it is a winforms application, and returns "407: remote proxy requires authentication". I hope this is of help.
|

November 1st, 2005, 12:26 AM
|
Registered User
|
|
Join Date: Nov 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi all,
I am also getting the same problem "System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive."
I have installed the client certificate on my development maching(Window XP). i m using the following code..
HttpWebResponse result = null;
//System.Web.UI.Page obj = new System.Web.UI.Page();
try
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(m_url);
req.Credentials = CredentialCache.DefaultCredentials;
///Method1
//req.ClientCertificates.Add(X509Certificate.CreateF romCertFile("D:\\Temp\\cert\\c1.cer"));
///Method2
///Uses interop services
MyCerts mycert = new MyCerts();
mycert.CertName = certName;
if(mycert.Init() > 0)
{
req.ClientCertificates.Add(mycert[0]);
}
try
{
result = (HttpWebResponse)req.GetResponse();
}
catch (WebException ex)
{
if (ex.Status == WebExceptionStatus.ProtocolError)
{
HttpWebResponse response = ex.Response as HttpWebResponse;
if (response != null)
{
result = response;// (HttpWebResponse)req.GetResponse();
}
}
}
Stream ReceiveStream = result.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
StreamReader sr = new StreamReader( ReceiveStream, encode );
Char[] read = new Char[256];
int count = sr.Read( read, 0, 256 );
return mycert[0];
}
catch//(WebException e)
{
return null;
}
finally
{
if ( result != null )
{
result.Close();
}
}
return null;
//this function is working fine it returns the certificate from my machine
public int Init()
{
Microsoft.Web.Services2.Security.X509.X509Certific ateStore store =
Microsoft.Web.Services2.Security.X509.X509Certific ateStore.LocalMachineStore(Microsoft.Web.Services2 .Security.X509.X509CertificateStore.MyStore);
store.OpenRead();
// Looks for the first certificate called SecureMathClient in the Local
// machine store
Microsoft.Web.Services2.Security.X509.X509Certific ateCollection col = (Microsoft.Web.Services2.Security.X509.X509Certifi cateCollection)store.FindCertificateBySubjectStrin g(certName);
X509Certificate cert = null;
try
{
cert = col[0] ;
m_certs = col;
string s = col[0].GetName();
}
catch (Exception ex)
{
throw new Exception("Certificate not Found!");
}
return m_certs.Count;
}
i m getting the exception at (HttpWebResponse)req.GetResponse();.....
Any idea!!!!!!!!!
Thanks
Amit
|

November 20th, 2005, 12:09 PM
|
Registered User
|
|
Join Date: Nov 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
We are having the same problem..
Error Message
The underlying connection was closed: An unexpected error occurred on a receive
Code
byte[] data = System.Text.Encoding.ASCII.GetBytes(strPOST);
WebRequest request = WebRequest.Create(URL);
request.ContentType = "application/x-www-form-urlencoded";
request.Method = "POST";
request.ContentLength = data.Length;
request.Timeout = 120000;
The error occurs on the red line. Does anyone have a fix?
|

December 16th, 2005, 09:42 AM
|
Registered User
|
|
Join Date: Dec 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi all,
I have a problem with code above:
protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest webRequest = (HttpWebRequest) base.GetWebRequest(uri);
webRequest.KeepAlive = false;
webRequest.ProtocolVersion=HttpVersion.Version10;
return webRequest;
}
When I added the code to Reference.cs and I started the application it throws
System.Net.WebException: The request failed with HTTP status 401: Access Denied.
I'm using Windows Authentication. And the following code to call the web service:
testService.Service service = new WindowsApplication1.testService.Service();
service.Credentials = CredentialCache.DefaultCredentials;
label1.Text = service.HelloWorld();
Anyone else had this problem?
|

December 30th, 2005, 06:59 AM
|
Registered User
|
|
Join Date: Dec 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I encounter this error when trying to add a web reference. Pointing the wizard to correct URL (that resides in another place at the Internet, not on our intranet nor my local workstation), I get error "The underlying connection was closed" to the right side of the wizard and to the main, "large" window IE's error screen.
When I go to the WSDL address via IE directly, I will see the WSDL file properly. After one visit at WSDL address with IE, the Web Reference wizard is able to show the contents of WSDL in main window, but doesn't show up any services to the right "Methods" window. The underlying connection was closed -error remains up there.
I'm not behind a proxy at all, so it should not be a proxy issue. Trying to close the firewall doesn't help either.
Any ideas?
Thanks,
Ville
|
|
 |