By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,912 Members | 1,723 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,912 IT Pros & Developers. It's quick & easy.

Closed Connections, WebRequest and Cast error

P: n/a
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 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),
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.
XataDataClasses.XataReportDataServices.ReportDataW se.GetWebRequest (Uri
turi) in C:\Documents and Settings\p1c1179\My Documents\Visual Studio
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
Lead Developer, USFood Services, Inc.

Jan 17 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.