Saturday, May 08, 2004 1:21 PM Jan Tielens

Solving "The underlying connection was closed" when using WSE

Some time ago I've posted a code snippet to solve following exception which in some cases can happen when you're calling a web service:

System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send.
at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
at ...

It seems that this exception also pops up when using Web Services Enhancements (WSE), but the solution I provided doesn't work in that case. You can't get directly to the underlying HttpWebRequest to set the KeepAlive property to false. But recently some people posted two solutions in the comments, so all kudos goes to these people, this time I'm just the messenger! Both solutions use Reflection to get a hold of the HttpWebRequest, nice work!

Solution by Skeup&Zeb
using System;
using System.Net;
using System.Reflection;

// Web service reference entered in wizard was "MyWebService.MyWebServiceWse"
using MyProject.MyWebService;

namespace MyProject
{
    public class MySubClassedWebService : MyWebServiceWse { 
        private static PropertyInfo requestPropertyInfo = null;

        public MySubClassedWebService(){}

        protected override System.Net.WebRequest GetWebRequest(Uri uri) { 
            WebRequest request = base.GetWebRequest(uri);

            if (requestPropertyInfo==null) 
            // Retrieve property info and store it in a static member for optimizing future use 
            requestPropertyInfo = request.GetType().GetProperty("Request");

            // Retrieve underlying web request 
            HttpWebRequest webRequest = 
            (HttpWebRequest)requestPropertyInfo.GetValue(request,null);

            // Setting KeepAlive 
            webRequest.KeepAlive = false; 
            return request; 
        } 
    }
}

Solution by Schwank:
protected override System.Net.WebRequest GetWebRequest(Uri uri)

    PropertyInfo requestPropertyInfo = null;

    WebRequest request = base.GetWebRequest(uri);

    if (requestPropertyInfo==null)

    requestPropertyInfo = request.GetType().GetProperty("Request");

    // Retrieve underlying web request 
    HttpWebRequest webRequest = (HttpWebRequest)requestPropertyInfo.GetValue(request, null);

    // Setting KeepAlive 
    webRequest.KeepAlive = false;

    return request;
}

Comments

# Solving

Saturday, May 08, 2004 1:23 AM by TrackBack

# re: Solving "The underlying connection was closed" when using WSE

Monday, May 10, 2004 2:35 PM by Scott

I've seen this happen when I call web services with proxy servers. We used the same approach mentioned above with the exception of changing the protocol version instead of setting keep-alives.

webRequest.ProtocolVersion = System.Net.HttpVersion.Version10;

# Some details...

Thursday, June 10, 2004 6:16 PM by Skeup&Zeb

Some explanations :
In the code we post on 4/30/2004, we created a class that inherits the wrapper VS.Net build for the web service instead of modifying the wrapper class itself.

The reason for this is quite simple. Since the web service class is not modified, you can get new versions of it without having to apply the fix again and again. (this is very useful when the design of the web service is done along with the development of the client side).

Just a remark : This error may occur even if the code above has been applied. It seems that Microsoft identified a bug in ASP.Net and has a non-public patch for this (http://support.microsoft.com/default.aspx?scid=kb;EN-US;819450).


So, still investigating...

# re: Solving "The underlying connection was closed" when using WSE

Friday, July 02, 2004 11:47 AM by Dan Smith

Thanks for the fix, it works great.

I also have a question. Should you use this method only for web service calls that include WSE functionality or can you use it on all web service calls.

P.S.
I did see the example on how to fix the issue for non-WSE web services that link to this page...

# re: Solving "The underlying connection was closed" when using WSE

Tuesday, August 03, 2004 12:13 PM by Jef Newsom

another thing you might try...

You can access the SoapHttpChannelOptions if you downcast (errr) the Channel property of the SoapSender/SoapClient to SoapHttpOutputChannel. SoapHttpChannelOptions has a KeepAlive property. At least that way you don't have to subclass.

# Underlying Connection Was Closed

Tuesday, October 12, 2004 9:59 PM by TrackBack

# re: Solving "The underlying connection was closed" when using WSE

Wednesday, June 14, 2006 5:07 AM by Sundher Ganesh

I have added that method in Reference.cs, now I am having a different kind of problem, the request object credentials are not carried and I am getting "Unauthorized access" exception.

Is there anything that I am missing.

# re: Solving "The underlying connection was closed" when using WSE

Wednesday, July 26, 2006 11:46 AM by Le

You can also use this

 Protected Overrides Function GetWebRequest(ByVal uri As System.Uri) As WebRequest

           Dim w As Microsoft.Web.Services2.SoapWebRequest = MyBase.GetWebRequest(uri)

           Dim httpw As HttpWebRequest = w.Request

           httpw.KeepAlive = False

           httpw.ProtocolVersion = HttpVersion.Version10

           Return w

       End Function

# re: Solving "The underlying connection was closed" when using WSE

Tuesday, January 16, 2007 8:07 PM by Winston

After implementing the suggested workarounds, I have not been able to get the Trace files to output and I also get authentication errors from the web service that I am calling.

It appears that the security information is being lost when the getWebRequest method is overriden as suggested. (however, I can't verify this as the trace is not working)

Im using WSE2.0. Has anyone else experienced this and come up with a solution?

# re: Solving "The underlying connection was closed" when using WSE

Tuesday, January 23, 2007 12:22 PM by ken

Yep, still happens in ASP.Net 2.0 and WSE 2.0 and the security info is lost.  At the top level webservice level, you can't get to the underlying connection that is used and overriding the getwebrequest method loses the security info :-P

# re: Solving "The underlying connection was closed" when using WSE

Thursday, February 08, 2007 8:53 AM by sl

Authorization can't work with KeepAlive set to false because it needs more than one roundtrip.

Right ?

# re: Solving "The underlying connection was closed" when using WSE

Wednesday, March 21, 2007 8:42 PM by Vivek

Hello,

I'm trying this. However, i'm getting the following error inside this method.

Object reference not set to an instance of an object.

Anybody has any idea about this.

Thanks

# re: Solving "The underlying connection was closed" when using WSE

# re: Solving "The underlying connection was closed" when using WSE

Monday, April 02, 2007 6:02 PM by dildos for sale,http://estadium.ya.com/vorona/gok/index.html <a href="http://estadium.ya.com/vorona/gok/index.html">buy sex toys</a> http://estadium.ya.com/vorona/gok/04-01.html <a href="http://estadium.ya.com/vorona/gok/04-01.html">amateur porn</a> http://estadium.ya.com/vorona/gok/04-02.html <a href="http://estadium.ya.com/vorona/gok/04-02.html">anal sex</a> http://estadium.ya.com/vorona/gok/04-03.html <a href="http://estadium.ya.com/vorona/gok/04-03.html">asian porn</a> http://estadium.ya.com/vorona/gok/04-04.html <a href="http://estadium.ya.com/vorona/gok/04-04.html">bbw sex</a> http://estadium.ya.com/vorona/gok/04-05.html <a href="http://estadium.ya.com/vorona/gok/04-05.html">bestiality pictures</a> http://estadium.ya.com/vorona/gok/04-06.html <a href="http://estadium.ya.com/vorona/gok/04-06.html">bestiality dvd</a> http://estadium.ya.com/vorona/gok/04-07.html <a href="http://estadium.ya.com/vorona/gok/04-07.html">big dicks</a> http://estadium.ya.com/vorona/gok/04-08.html <a href="http://estadium.ya.com/vorona/gok/04-08.html">big ***</a> http://estadium.ya.com/vorona/gok/04-09.html <a href="http://estadium.ya.com/vorona/gok/04-09.html">black sex</a> http://estadium.ya.com/vorona/gok/04-10.html <a href="http://estadium.ya.com/vorona/gok/04-10.html">pornstar video</a> http://estadium.ya.com/vorona/gok/04-11.html <a href="http://estadium.ya.com/vorona/gok/04-11.html">brunettes porn</a> http://estadium.ya.com/vorona/gok/04-12.html <a href="http://estadium.ya.com/vorona/gok/04-12.html">bukkake pictures</a> http://estadium.ya.com/vorona/gok/04-13.html <a href="http://estadium.ya.com/vorona/gok/04-13.html">buy cialis</a> http://estadium.ya.com/vorona/gok/04-14.html <a href="http://estadium.ya.com/vorona/gok/04-14.html">cumshot sex</a> http://estadium.ya.com/vorona/gok/04-15.html <a href="http://estadium.ya.com/vorona/gok/04-15.html">sex dating</a> http://estadium.ya.com/vorona/gok/04-16.html <a href="http://estadium.ya.com/vorona/gok/04-16.html">porn dvd</a> http://estadium.ya.com/vorona/gok/04-17.html <a href="http://estadium.ya.com/vorona/gok/04-17.html">ebony sex</a> http://estadium.ya.com/vorona/gok/04-18.html <a href="http://estadium.ya.com/vorona/gok/04-18.html">femdom porn</a> http://estadium.ya.com/vorona/gok/04-19.html <a href="http://estadium.ya.com/vorona/gok/04-19.html">fisting sex</a> http://estadium.ya.com/vorona/gok/04-20.html <a href="http://estadium.ya.com/vorona/gok/04-20.html">footjobs porn</a> http://estadium.ya.com/vorona/gok/04-21.html <a href="http://estadium.ya.com/vorona/gok/04-21.html">gangbang sex</a> http://estadium.ya.com/vorona/gok/04-22.html <a href="http://estadium.ya.com/vorona/gok/04-22.html">granny porn</a> http://estadium.ya.com/vorona/gok/04-23.html <a href="http://estadium.ya.com/vorona/gok/04-23.html">handjobs sex</a> http://estadium.ya.com/vorona/gok/04-24.html <a href="http://estadium.ya.com/vorona/gok/04-24.html">incest porn</a> http://estadium.ya.com/vorona/gok/04-25.html <a href="http://estadium.ya.com/vorona/gok/04-25.html">indian porn</a> http://estadium.ya.com/vorona/gok/04-26.html <a href="http://estadium.ya.com/vorona/gok/04-26.html">interracial sex</a> http://estadium.ya.com/vorona/gok/04-27.html <a href="http://estadium.ya.com/vorona/gok/04-27.html">latina porn</a> http://estadium.ya.com/vorona/gok/04-28.html <a href="http://estadium.ya.com/vorona/gok/04-28.html">lesbians sex</a> http://estadium.ya.com/vorona/gok/04-29.html <a href="http://estadium.ya.com/vorona/gok/04-29.html">buy levitra</a> http://estadium.ya.com/vorona/gok/04-30.html <a href="http://estadium.ya.com/vorona/gok/04-30.html">live sex chat</a> http://estadium.ya.com/vorona/gok/04-31.html <a href="http://estadium.ya.com/vorona/gok/04-31.html">mature porn</a> http://estadium.ya.com/vorona/gok/04-32.html <a href="http://estadium.ya.com/vorona/gok/04-32.html">group sex</a> http://estadium.ya.com/vorona/gok/04-33.html <a href="http://estadium.ya.com/vorona/gok/04-33.html">pantyhose sex</a> http://estadium.ya.com/vorona/gok/04-34.html <a href="http://estadium.ya.com/vorona/gok/04-34.html">pissing girls</a> http://estadium.ya.com/vorona/gok/04-35.html <a href="http://estadium.ya.com/vorona/gok/04-35.html">preggo porn</a> http://estadium.ya.com/vorona/gok/04-36.html <a href="http://estadium.ya.com/vorona/gok/04-36.html">rape video</a> http://estadium.ya.com/vorona/gok/04-37.html <a href="http://estadium.ya.com/vorona/gok/04-37.html">redheads sex</a> http://estadium.ya.com/vorona/gok/04-38.html <a href="http://estadium.ya.com/vorona/gok/04-38.html">scat sex</a> http://estadium.ya.com/vorona/gok/04-39.html <a href="http://estadium.ya.com/vorona/gok/04-39.html">sextoys for sale</a> http://estadium.ya.com/vorona/gok/04-40.html <a href="http://estadium.ya.com/vorona/gok/04-40.html">shemales sex</a> http://estadium.ya.com/vorona/gok/04-41.html <a href="http://estadium.ya.com/vorona/gok/04-41.html">teen porn</a> http://estadium.ya.com/vorona/gok/04-42.html <a href="http://estadium.ya.com/vorona/gok/04-42.html">hardcore toons</a> http://estadium.ya.com/vorona/gok/04-43.html <a href="http://estadium.ya.com/vorona/gok/04-43.html">twink sex</a> http://estadium.ya.com/vorona/gok/04-44.html <a href="http://estadium.ya.com/vorona/gok/04-44.html">buy viagra</a> http://estadium.ya.com/vorona/gok/04-45.html <a href="http://estadium.ya.com/vorona/gok/04-45.html">voyeur porn</a>

http://estadium.ya.com/vorona/gok/index.html <a href="http://estadium.ya.com/vorona/gok/index.html">buy sex toys</a>

http://estadium.ya.com/vorona/gok/04-01.html <a href="http://estadium.ya.com/vorona/gok/04-01.html">amateur porn</a>

http://estadium.ya.com/vorona/gok/04-02.html <a href="http://estadium.ya.com/vorona/gok/04-02.html">anal sex</a>

http://estadium.ya.com/vorona/gok/04-03.html <a href="http://estadium.ya.com/vorona/gok/04-03.html">asian porn</a>

http://estadium.ya.com/vorona/gok/04-04.html <a href="http://estadium.ya.com/vorona/gok/04-04.html">bbw sex</a>

http://estadium.ya.com/vorona/gok/04-05.html <a href="http://estadium.ya.com/vorona/gok/04-05.html">bestiality pictures</a>

http://estadium.ya.com/vorona/gok/04-06.html <a href="http://estadium.ya.com/vorona/gok/04-06.html">bestiality dvd</a>

http://estadium.ya.com/vorona/gok/04-07.html <a href="http://estadium.ya.com/vorona/gok/04-07.html">big dicks</a>

http://estadium.ya.com/vorona/gok/04-08.html <a href="http://estadium.ya.com/vorona/gok/04-08.html">big ***</a>

http://estadium.ya.com/vorona/gok/04-09.html <a href="http://estadium.ya.com/vorona/gok/04-09.html">black sex</a>

http://estadium.ya.com/vorona/gok/04-10.html <a href="http://estadium.ya.com/vorona/gok/04-10.html">pornstar video</a>

http://estadium.ya.com/vorona/gok/04-11.html <a href="http://estadium.ya.com/vorona/gok/04-11.html">brunettes porn</a>

http://estadium.ya.com/vorona/gok/04-12.html <a href="http://estadium.ya.com/vorona/gok/04-12.html">bukkake pictures</a>

http://estadium.ya.com/vorona/gok/04-13.html <a href="http://estadium.ya.com/vorona/gok/04-13.html">buy cialis</a>

http://estadium.ya.com/vorona/gok/04-14.html <a href="http://estadium.ya.com/vorona/gok/04-14.html">cumshot sex</a>

http://estadium.ya.com/vorona/gok/04-15.html <a href="http://estadium.ya.com/vorona/gok/04-15.html">sex dating</a>

http://estadium.ya.com/vorona/gok/04-16.html <a href="http://estadium.ya.com/vorona/gok/04-16.html">porn dvd</a>

http://estadium.ya.com/vorona/gok/04-17.html <a href="http://estadium.ya.com/vorona/gok/04-17.html">ebony sex</a>

http://estadium.ya.com/vorona/gok/04-18.html <a href="http://estadium.ya.com/vorona/gok/04-18.html">femdom porn</a>

http://estadium.ya.com/vorona/gok/04-19.html <a href="http://estadium.ya.com/vorona/gok/04-19.html">fisting sex</a>

http://estadium.ya.com/vorona/gok/04-20.html <a href="http://estadium.ya.com/vorona/gok/04-20.html">footjobs porn</a>

http://estadium.ya.com/vorona/gok/04-21.html <a href="http://estadium.ya.com/vorona/gok/04-21.html">gangbang sex</a>

http://estadium.ya.com/vorona/gok/04-22.html <a href="http://estadium.ya.com/vorona/gok/04-22.html">granny porn</a>

http://estadium.ya.com/vorona/gok/04-23.html <a href="http://estadium.ya.com/vorona/gok/04-23.html">handjobs sex</a>

http://estadium.ya.com/vorona/gok/04-24.html <a href="http://estadium.ya.com/vorona/gok/04-24.html">incest porn</a>

http://estadium.ya.com/vorona/gok/04-25.html <a href="http://estadium.ya.com/vorona/gok/04-25.html">indian porn</a>

http://estadium.ya.com/vorona/gok/04-26.html <a href="http://estadium.ya.com/vorona/gok/04-26.html">interracial sex</a>

http://estadium.ya.com/vorona/gok/04-27.html <a href="http://estadium.ya.com/vorona/gok/04-27.html">latina porn</a>

http://estadium.ya.com/vorona/gok/04-28.html <a href="http://estadium.ya.com/vorona/gok/04-28.html">lesbians sex</a>

http://estadium.ya.com/vorona/gok/04-29.html <a href="http://estadium.ya.com/vorona/gok/04-29.html">buy levitra</a>

http://estadium.ya.com/vorona/gok/04-30.html <a href="http://estadium.ya.com/vorona/gok/04-30.html">live sex chat</a>

http://estadium.ya.com/vorona/gok/04-31.html <a href="http://estadium.ya.com/vorona/gok/04-31.html">mature porn</a>

http://estadium.ya.com/vorona/gok/04-32.html <a href="http://estadium.ya.com/vorona/gok/04-32.html">group sex</a>

http://estadium.ya.com/vorona/gok/04-33.html <a href="http://estadium.ya.com/vorona/gok/04-33.html">pantyhose sex</a>

http://estadium.ya.com/vorona/gok/04-34.html <a href="http://estadium.ya.com/vorona/gok/04-34.html">pissing girls</a>

http://estadium.ya.com/vorona/gok/04-35.html <a href="http://estadium.ya.com/vorona/gok/04-35.html">preggo porn</a>

http://estadium.ya.com/vorona/gok/04-36.html <a href="http://estadium.ya.com/vorona/gok/04-36.html">rape video</a>

http://estadium.ya.com/vorona/gok/04-37.html <a href="http://estadium.ya.com/vorona/gok/04-37.html">redheads sex</a>

http://estadium.ya.com/vorona/gok/04-38.html <a href="http://estadium.ya.com/vorona/gok/04-38.html">scat sex</a>

http://estadium.ya.com/vorona/gok/04-39.html <a href="http://estadium.ya.com/vorona/gok/04-39.html">sextoys for sale</a>

http://estadium.ya.com/vorona/gok/04-40.html <a href="http://estadium.ya.com/vorona/gok/04-40.html">shemales sex</a>

http://estadium.ya.com/vorona/gok/04-41.html <a href="http://estadium.ya.com/vorona/gok/04-41.html">teen porn</a>

http://estadium.ya.com/vorona/gok/04-42.html <a href="http://estadium.ya.com/vorona/gok/04-42.html">hardcore toons</a>

http://estadium.ya.com/vorona/gok/04-43.html <a href="http://estadium.ya.com/vorona/gok/04-43.html">twink sex</a>

http://estadium.ya.com/vorona/gok/04-44.html <a href="http://estadium.ya.com/vorona/gok/04-44.html">buy viagra</a>

http://estadium.ya.com/vorona/gok/04-45.html <a href="http://estadium.ya.com/vorona/gok/04-45.html">voyeur porn</a>

# re: Solving "The underlying connection was closed" when using WSE

Tuesday, April 03, 2007 4:05 AM by rzliw

<a href= http://adderall.livelog.com#1 >adderall xr</a>[url=http://adderall.livelog.com#1]adderall xr[/url]<a href= http://adderall.livelog.com#3 >adderall xr</a>[url=http://adderall.livelog.com#3]adderall xr[/url]<a href= http://adderall.livelog.com#4 >adderall abuse</a>[url=http://adderall.livelog.com#4]adderall abuse[/url]

# re: Solving "The underlying connection was closed" when using WSE

<a href=" http://tomcochrane.com/artwork/video/poker/Full-Tilt-Poker-Freeroll.html ">Full Tilt Poker Freeroll</a>

<a href=" http://tomcochrane.com/artwork/video/poker/Full-Login-Poker-Tilt.html ">Full Login Poker Tilt</a>

<a href=" http://tomcochrane.com/artwork/video/poker/Full-Hockey-Jersey-Poker-Tilt.html ">Full Hockey Jersey Poker Tilt</a>

<a href=" http://tomcochrane.com/artwork/video/poker/Full-Point-Poker-Tilt.html ">Full Point Poker Tilt</a>

<a href=" http://tomcochrane.com/artwork/video/poker/index.html ">index</a>,

<a href=" http://tomcochrane.com/artwork/video/poker/Full-Tilt-Poker-Freeroll.html ">Full Tilt Poker Freeroll</a>

<a href=" http://tomcochrane.com/artwork/video/poker/Full-Login-Poker-Tilt.html ">Full Login Poker Tilt</a>

<a href=" http://tomcochrane.com/artwork/video/poker/Full-Hockey-Jersey-Poker-Tilt.html ">Full Hockey Jersey Poker Tilt</a>

<a href=" http://tomcochrane.com/artwork/video/poker/Full-Point-Poker-Tilt.html ">Full Point Poker Tilt</a>

<a href=" http://tomcochrane.com/artwork/video/poker/index.html ">index</a>,

<a href=" http://tomcochrane.com/artwork/video/poker/Full-Tilt-Poker-Freeroll.html ">Full Tilt Poker Freeroll</a>

<a href=" http://tomcochrane.com/artwork/video/poker/Full-Login-Poker-Tilt.html ">Full Login Poker Tilt</a>

<a href=" http://tomcochrane.com/artwork/video/poker/Full-Hockey-Jersey-Poker-Tilt.html ">Full Hockey Jersey Poker Tilt</a>

<a href=" http://tomcochrane.com/artwork/video/poker/Full-Point-Poker-Tilt.html ">Full Point Poker Tilt</a>

<a href=" http://tomcochrane.com/artwork/video/poker/index.html ">index</a>,

<a href=" http://tomcochrane.com/artwork/video/poker/Full-Tilt-Poker-Freeroll.html ">Full Tilt Poker Freeroll</a>

<a href=" http://tomcochrane.com/artwork/video/poker/Full-Login-Poker-Tilt.html ">Full Login Poker Tilt</a>

<a href=" http://tomcochrane.com/artwork/video/poker/Full-Hockey-Jersey-Poker-Tilt.html ">Full Hockey Jersey Poker Tilt</a>

<a href=" http://tomcochrane.com/artwork/video/poker/Full-Point-Poker-Tilt.html ">Full Point Poker Tilt</a>

<a href=" http://tomcochrane.com/artwork/video/poker/index.html ">index</a>,

<a href=" http://tomcochrane.com/artwork/video/poker/Full-Tilt-Poker-Freeroll.html ">Full Tilt Poker Freeroll</a>

<a href=" http://tomcochrane.com/artwork/video/poker/Full-Login-Poker-Tilt.html ">Full Login Poker Tilt</a>

<a href=" http://tomcochrane.com/artwork/video/poker/Full-Hockey-Jersey-Poker-Tilt.html ">Full Hockey Jersey Poker Tilt</a>

<a href=" http://tomcochrane.com/artwork/video/poker/Full-Point-Poker-Tilt.html ">Full Point Poker Tilt</a>

<a href=" http://tomcochrane.com/artwork/video/poker/index.html ">index</a>

# re: Solving "The underlying connection was closed" when using WSE

Sunday, April 08, 2007 1:03 AM by swyah

<a href= http://domotips.com/i/zolpidem.html#1 >buy zolpidem</a>[url=http://domotips.com/i/zolpidem.html#1]buy zolpidem[/url]<a href= http://domotips.com/i/oxycodone.html#1 >order oxycodone</a>[url=http://domotips.com/i/oxycodone.html#1]order oxycodone[/url]<a href= http://domotips.com/i/soma.html#3 >order soma</a>[url=http://domotips.com/i/soma.html#3]order soma[/url]

# re: Solving "The underlying connection was closed" when using WSE

Sunday, April 08, 2007 2:54 AM by Britneyhhfgn

<a href= http://www.angelfire.com/blog/dyxavy >ab ca wcb</a> <a href= http://www.angelfire.com/planet/nexeny >aaron lewis outside lyric</a> <a href= http://www.angelfire.com/indie/sojoly >a one dollar bill</a> <a href= http://www.angelfire.com/punk/muveqe >a lack of colour tabs</a> <a href= http://www.angelfire.com/planet/mivumu >a linguistic and semiotic approach to textual analysis</a>

# re: Solving "The underlying connection was closed" when using WSE

Sunday, April 08, 2007 2:54 AM by Britneyhhfgn

<a href= http://www.angelfire.com/blog/dyxavy >ab ca wcb</a> <a href= http://www.angelfire.com/planet/nexeny >aaron lewis outside lyric</a> <a href= http://www.angelfire.com/indie/sojoly >a one dollar bill</a> <a href= http://www.angelfire.com/punk/muveqe >a lack of colour tabs</a> <a href= http://www.angelfire.com/planet/mivumu >a linguistic and semiotic approach to textual analysis</a>

# re: Solving "The underlying connection was closed" when using WSE

Friday, April 13, 2007 7:14 PM by Sean

Hello,

I just wanted to add to this that I'm using the 2.0 Framework and have upgraded to WSE 3 and am not experiencing the "Invalid Cast" exception.  The underlying type has been changed to an HttpWebRequest so it works fine.

-Sean

# re: Solving "The underlying connection was closed" when using WSE

Sunday, April 15, 2007 7:01 PM by ridqo

# re: Solving "The underlying connection was closed" when using WSE

Friday, May 04, 2007 4:36 PM by ureyes84

Hi all, I'm using VS 2005 Framework 2.0 WSE 3.0. VS didn't add a class WebService\reference.cs, so I created a class called

MyWebServiceSubClass

and added the following code:

using System;

using System.Net;

using System.Reflection;

/// <summary>

/// Summary description for subClassedWebService

/// </summary>

public class subClassedWebService:SessionManager.Service

{

public subClassedWebService()

{

//

// TODO: Add constructor logic here

//

}

   private static PropertyInfo requestPropertyInfo = null;

   protected override WebRequest GetWebRequest(Uri uri)

   {

           if (requestPropertyInfo==null)

           // Retrieve property info and store it in a static member for optimizing future use

           requestPropertyInfo = request.GetType().GetProperty("Request");

           // Retrieve underlying web request

           HttpWebRequest webRequest =

           (HttpWebRequest)requestPropertyInfo.GetValue(request,null);

           // Setting KeepAlive

           webRequest.KeepAlive = false;

           return request;

   }    

}

Bu I'm getting the exception:

Object reference not set to an instance of an object.

in the line:

    requestPropertyInfo = request.GetType().GetProperty("Request");

Does somebody know why?

Thanks in advance My email is ureyes84 at gmail.com

# re: Solving "The underlying connection was closed" when using WSE

# re: Solving "The underlying connection was closed" when using WSE

Friday, May 18, 2007 5:12 PM by Valerios

Nice

# re: Solving "The underlying connection was closed" when using WSE

Friday, May 18, 2007 11:47 PM by Agias

Cool...

# re: Solving "The underlying connection was closed" when using WSE

Saturday, May 19, 2007 5:14 PM by Gustas

Sorry :(

# re: Solving "The underlying connection was closed" when using WSE

Monday, May 21, 2007 11:48 AM by Martinos

Nice!

# re: Solving "The underlying connection was closed" when using WSE

Tuesday, May 22, 2007 5:12 AM by Yioryios

Nice...

# re: Solving "The underlying connection was closed" when using WSE

Tuesday, May 22, 2007 8:21 AM by Lambros

Sorry :(

# re: Solving "The underlying connection was closed" when using WSE

Tuesday, June 05, 2007 4:55 PM by Charalambos

Interesting...

# re: Solving "The underlying connection was closed" when using WSE

Tuesday, June 05, 2007 8:18 PM by Demetri

Nice...

# re: Solving "The underlying connection was closed" when using WSE

Wednesday, June 06, 2007 6:09 PM by Constandinos

Interesting...

# re: Solving "The underlying connection was closed" when using WSE

Friday, June 08, 2007 10:05 PM by Alexios

interesting

# re: Solving "The underlying connection was closed" when using WSE

Sunday, June 10, 2007 11:18 PM by Dionyssios

Interesting...

# girls dancing infront of cameras

Wednesday, September 05, 2007 2:15 AM by girls dancing infront of cameras

Visited your site and it is great.

# Dating Triumph

Saturday, September 22, 2007 5:09 PM by Dating Triumph

Top dating reports may take a small bit of effort to spot.

# Hoodia Gordonii Plus

Monday, October 08, 2007 7:19 AM by Hoodia Gordonii Plus

It is wearing attempting to add up the time we\'ve exhausted searching for hoodia cactus extract articles.

# lose weight

Monday, October 22, 2007 5:24 AM by lose weight

It can periodically get painful to separate the insightful effects of hoodia gordonii text from the dreadful.

# Click HERE

Tuesday, October 23, 2007 3:18 AM by Click HERE

As japanese boobs related subjects continue to increase in popularity, there will be many more locations to learn more about this significant matter.

# dating web

Tuesday, October 30, 2007 1:32 AM by dating web

When you are searching for date and time information and web sites, be certain to use everyone of the sources available.

# re: Solving "The underlying connection was closed" when using WSE

Friday, November 09, 2007 4:40 AM by play keno

# Livecam Portal

Saturday, November 17, 2007 11:05 PM by Livecam Portal

Very interesting post over there