|
|
 |
| .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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.
|
 |
|

October 4th, 2003, 06:22 PM
|
|
Authorized User
|
|
Join Date: Jun 2003
Location: , , .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
The underlying connection was closed:
occasionally I recieve this error from production enviroment when asp.net call web service, the next call to web service is usually succesful. Error
System.Web.HttpUnhandledException: Exception of type System.Web.HttpUnhandledException was thrown.
---> System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive.
at System.Web.Services.Protocols.WebClientProtocol.Ge tWebResponse(WebRequest request)
at System.Web.Services.Protocols.HttpWebClientProtoco l.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke(String methodName, Object[] parameters)
at MySite.MyService.Service1.ProcessUpdates(String ApplicationName, Boolean bUpdateAllData)
at MySite.MyAspxPage.Sub_CommitTransaction(Object sender, EventArgs e)
at System.Web.UI.TemplateControl.OnCommitTransaction( EventArgs e)
at System.Web.UI.Page.ProcessRequestTransacted()
--- End of inner exception stack trace ---
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestTransacted()
Anyone else had this problem?
|

October 9th, 2003, 07:12 PM
|
|
Authorized User
|
|
Join Date: Oct 2003
Location: , , Norway.
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Do you access any data from SQL? I've had a simmilar(but not same) problem when trying to access a SQL connection that has closed during page load. Quite by accident thou, the SQL server has shutdown just as my page has loaded..
|

October 13th, 2003, 04:19 AM
|
|
Registered User
|
|
Join Date: Oct 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I got the same problem when I tried to access the web service from .NET (C#) client which was behind a http proxy server.If I access the same web service without using HTTP Proxy ,the calls are successful.There is a remedy for this problem .Just override the method getWebRequest in your reference.cs file .
and add this code
protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest webRequest = (HttpWebRequest) base.GetWebRequest(uri);
webRequest.KeepAlive = true;
return webRequest;
}
This can solve the problem
|

October 30th, 2003, 11:23 AM
|
|
Registered User
|
|
Join Date: Oct 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
My old post had an error please consider this,
and add this code to reference.cs
protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest webRequest = (HttpWebRequest) base.GetWebRequest(uri);
webRequest.KeepAlive = false;
webRequest.ProtocolVersion=HttpVersion.Version10;
return webRequest;
}
This can solve the problem
|

October 31st, 2003, 02:28 PM
|
|
Registered User
|
|
Join Date: Oct 2003
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi all,
I have developed a WebApplication that sends messages to mobile phones by connecting to an integrator platform. I use VB.NET. Although my application seems to connect and authorise ok, right after it sends the message, the connection is broken and I get the System.Net.WebException. The first time I run the app, I get an error on a send, all the subsequent runs fail on the receive, the stack trace is the same, though:
[WebException: The underlying connection was closed: An unexpected error occurred on a receive.]
System.Web.Services.Protocols.WebClientProtocol.Ge tWebResponse(WebRequest request) +58
System.Web.Services.Protocols.HttpWebClientProtoco l.GetWebResponse(WebRequest request) +5
System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke(String methodName, Object[] parameters) +183
WebApplication1.localhost.BrokerService.sendsimple message(simplemessageRequest Request, String& ErrorMessage, Object[]& Failed_MSISDN, Int32& RequestID) in C:\Inetpub\wwwroot\WebApplication1\Web References\localhost\Reference. vb:81
WebApplication1.WebForm1.Button1_Click(Object sender, EventArgs e) in C:\Inetpub\wwwroot\WebApplication1\WebForm1.aspx.v b:61
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
System.Web.UI.Page.ProcessRequestMain() +1277
I tried the suggested solution, but I still get the same error. Any ideas?
|

January 11th, 2004, 10:38 PM
|
|
Registered User
|
|
Join Date: Jan 2004
Location: Surabaya, East Java, Indonesia.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
"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
|

January 12th, 2004, 01:59 PM
|
|
Registered User
|
|
Join Date: Jan 2004
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
How would I go about writing this in VB.NET. What class would it need to be in and what inheritance would I need.
protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest webRequest = (HttpWebRequest) base.GetWebRequest(uri);
webRequest.KeepAlive = false;
webRequest.ProtocolVersion=HttpVersion.Version10;
return webRequest;
}
|

May 17th, 2004, 12:51 AM
|
|
Registered User
|
|
Join Date: May 2004
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I campareed two programs reslults-- one is in localhost with aspnet, one is consol program, same programs give different results, why? the firewall can distinguish them?
1st, I use http://localhost/quickstart/howto/sa...ebrequest.aspx
only those pages in local host can be received.
for those pages in internet: back webexception:
System.Net.WebException: The underlying connection was closed: Unable to connect to the remote server.
at System.Net.HttpWebRequest.CheckFinalStatus()
at System.Net.HttpWebRequest.EndGetResponse(IAsyncRes ult asyncResult)
at System.Net.HttpWebRequest.GetResponse()
at ASP.webrequest_aspx.btnSubmit_Click(Object sender, EventArgs e)
another is almost same program but run in console mode
quickstart/howto/samples/net/WebRequests/clientGET.cs
or
quickstart/howto/samples/net/WebRequests/clientwebexception.cs
I can get right results!
Why? these programs are all .NET 's samples, why give different results?
Who can help me?
if I upload webrequest.aspx to my web site on internet, all OK!
Is it possible for my IIS or proxy server or firewall need some special setting?
------------------
test under VS.NET and C#.net and .NET Frame SDK 1.1, OS is Window 2000 server, IIS 5, and IE 6 as internet explore.
|

May 24th, 2004, 09:51 AM
|
|
Registered User
|
|
Join Date: Apr 2004
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi
Must I use webRequest.KeepAlive = false?
I understand what Microsoft writes on theirs page.
But isn't that a simple solution for a complex situation.
Of course I can skip the use of keep alive but what does that do
for my performance?
I found when minimizing the use of static functions and variables makes the error less frequent.
Is there any more redesign one can do to make the error go away??
And keeping the KeepAlive?
/Hansiola
Quote:
quote:Originally posted by misrasandeep
My old post had an error please consider this,
and add this code to reference.cs
protected override WebRequest GetWebRequest(Uri uri)
{
HttpWebRequest webRequest = (HttpWebRequest) base.GetWebRequest(uri);
webRequest.KeepAlive = false;
webRequest.ProtocolVersion=HttpVersion.Version10;
return webRequest;
}
This can solve the problem
|
|

July 28th, 2004, 11:56 AM
|
|
Registered User
|
|
Join Date: Jul 2004
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi,
I am also getting the same error, while connecting to SQL reporting service which is a web service by itself.
But if I am updating the reference file, and run the .net program which access the webservice, I get the error "HTTP request aborted. Access denied".
When I delete the reference and add a new one that works.
If anybody has a pointer plz help me.
Thanks
Amit
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
 |