473,396 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Closed Connections, WebRequest and Cast error

Hell there,

I tried to post a reply to a message thread created back in July 2006
regarding the override of WebRequest, Closed Conenctions and setting
KeepAlive to false,but it's been over 60 days so I am creating a new
topci in the hopes of an answer to a related issue.

GhostAK suggested some vb.net code that should work to allow the
setting of the Keep Alive property. yes, I am having connection close
errors. The code suggested was this:

Protected Overrides Function GetWebRequest(ByVal turi As
System.Uri) As System.Net.WebRequest
Dim webRequest As System.Net.HttpWebRequest
webRequest = CType(MyBase.GetWebRequest (turi),
System.Net.HttpWebRequest)
webRequest.KeepAlive = False
webRequest.ProtocolVersion = HttpVersion.Version10
Return webRequest
End Function

I modified it by one line, splitting out the dim and assignment
statements for the HTTPWebRequest.

I am writing now because the code made sense, but now I get this error:

"System.InvalidCastException: Specified cast is not valid.
at
XataDataClasses.XataReportDataServices.ReportDataW se.GetWebRequest (Uri
turi) in C:\Documents and Settings\p1c1179\My Documents\Visual Studio
Projects\XataWebServices\Web
References\XataReportDataServices\Reference.vb:lin e 79
at System.Web.Services.Protocols.SoapHttpClientProtoc ol.Invoke
(String methodName, Object[] parameters)

I get it on the " webRequest =
CType(MyBase.GetWebRequest(turi), System.Net.HttpWebRequest)" line and
I have no clue why I have searched the web, googled various phrases
with no help. I have a client app that randomly fails and the company
that provides the service tells me to set KeepAlive to false.

I've added this code to the References.vb file in the Web References
for the service. I am using WSE (Web Services 2.0), and I am stuck.
can anyone provide any insight, or any direction to resolving either
this cast error or getting around the connection closed error? No
matter what I thank you for your time reading this and any response you
may have.

Justin Hull
ju*********@usfood.com
Lead Developer, USFood Services, Inc.

Jan 17 '07 #1
0 1162

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Suhail Kaleem | last post by:
Hi ! When i try to use webrequest class i get this error The underlying connection was closed: An unexpected error occurred on a receive. I ma uisng vb.net and have no control on the server ...
26
by: Rajeev Tipnis | last post by:
http://support.microsoft.com/default.aspx?scid=kb;en- us;819450 Questions: 1) Is this patch (fix) applicable to the .NET 1.1 Framework as well? That is, if we have Framework 1.1 (On...
5
by: Tim Reynolds | last post by:
My app calls a web service. After a few minutes of inactivity, we receive: System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. A call...
1
by: Tim Reynolds | last post by:
Team, From a windows service, we consume a web service on another server and occasionally receive System.Net.WebException: The underlying connection was closed:. For some clients we call, we do...
1
by: matt | last post by:
hello, i am using a .NET 1.1 winform to perform webrequests via the System.Net.WebClient class (not a webservice, actually). It uploads values via a POST command & a URL, then receives the html...
0
by: pinky | last post by:
Hi all I am having one web service where in at a time of calling one webmethod through client application i am continuously getting following error :- The underlying connection was...
2
by: Andrew Hunot | last post by:
I have VB code in VS2003 which creates a HttpWebRequest and performs a POST operation to a remote URL (an https site), which runs fine and receives a valid response. However exactly the same...
6
by: Doug Ferguson | last post by:
I am using a webservice client that was created from a WSDL file in .Net 1.1. The client ALWAYS works the first time I call it. The second call returns one of two exceptions. It either returns...
4
by: =?Utf-8?B?QXJuYXVkIFZpc2N1c2k=?= | last post by:
Hi all, we meet a problem since we use WCF to consume java WebServices. Often the first call works then the second raises the following error : "The underlying connection was closed : " We...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.