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.