Wrox Programmer Forums
|
.NET Framework 1.x For discussing versions 1.0 and 1.1 of the Microsoft .NET Framework.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the .NET Framework 1.x section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 28th, 2006, 03:14 PM
Registered User
 
Join Date: Aug 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problems in Windows Service

I have a windows service. It gets an XML form from an FTP server stores it in the local C: drive. It then takes the data and writes the content into a sql server database. Intermitently I get the following error.

Problems in loading file to read! System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive.
 at System.Net.HttpWebRequest.CheckFinalStatus()
 at System.Net.HttpWebRequest.EndGetResponse(IAsyncRes ult asyncResult)
 at System.Net.HttpWebRequest.GetResponse()
 at System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri, ICredentials credentials)
 at System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials)
 at System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn)
 at System.Xml.Schema.DtdParser.ParseDocTypeDecl()
 at System.Xml.Schema.DtdParser.Parse()
 at System.Xml.XmlTextReader.ParseDtd(XmlScanner scanner)
 at System.Xml.XmlTextReader.ParseTag()
 at System.Xml.XmlTextReader.ParseRoot()
 at System.Xml.XmlTextReader.Read()
 at System.Xml.XmlValidatingReader.ReadWithCollectText Token()
 at System.Xml.XmlValidatingReader.Read()
 at System.Xml.XmlLoader.LoadCurrentNode()
 at System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc)
 at System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean preserveWhitespace)
 at System.Xml.XmlDocument.Load(XmlReader reader)
 at System.Xml.XmlDataDocument.Load(XmlReader reader)
 at System.Xml.XmlDocument.Load(String filename)
 at System.Xml.XmlDataDocument.Load(String filename)
 at MyService.ParseXML.GetData(String filename) in C:\k\MyService\ParseXML.vb:line 32

I am catching errors at various places. I know there is no problem in downloading the file. The error happens when the service tries to open the xml file to write it to the database.

I am also attaching some of my code.

Private Sub dowloadAndWriteIntoDatabase(ByVal time As String)
 Call DeleteIfFileExists()
 DownloadFile()
 objWriteError.OnSuccess("Successfully completed download at " & time) //This is successful all the time
 objParseXml.GetData("C:\temp\test.dat")
 objWriteError.OnSuccess("Successfully entered into a database at " & time)
End Sub


Public Sub GetData(ByVal filename As String)
 Dim objXml As XmlDocument = New XmlDataDocument
 Try
  objXml.Load(filename)
 Catch ex As Exception
//This is the line that throws the error
  objWriteError.onfailure("Problems in loading file to read! " & ex.ToString) End Try
 Call GetNewsFeed(objXml)
End Sub

Can anyone please help me. It is driving me nuts and I have read a lot about it but I am not able to find a solution.



Thank You
Kal30
 
Old August 29th, 2006, 10:27 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

Quote:
quote:I am catching errors at various places. I know there is no problem in downloading the file. The error happens when the service tries to open the xml file to write it to the database.
Have your tried opening the file manually once its downloaded to a local folder?
Try by breaking your code in two parts, make sure that the file is getting downloaded properly.

I'm saying this because you are getting an error when you are trying to
load the document. Now one of the very few possiblities of getting an error while
doing that is if the document is not in keeping with XML standards which in
turn could be a case of document getting corrupted in transit.

So make sure that you local copy of the xml document is in proper shape.

Regards
Ankur
 
Old September 11th, 2006, 01:54 PM
Registered User
 
Join Date: Aug 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am sorry I did not get to you earlier. I am still getting the error. When I just try to open my xml file I get 'The server committed an HTTP protocol violation' this error. Can anyone knows how fix this error while using windows service. I would really appreciate any help.


Thank You
Kal30





Similar Threads
Thread Thread Starter Forum Replies Last Post
Impersonate with windows service for Service A/C vinod_yadav1919 C# 0 October 18th, 2008 02:29 PM
windows service MunishBhatia WinForms/Console Application Design 0 September 27th, 2007 10:27 AM
Windows service exarkuun General .NET 0 September 7th, 2007 10:19 AM
Windows Service everest C# 1 March 8th, 2007 01:10 PM
Accessing Windows service from a windows app sajid08 C# 1 October 6th, 2006 10:25 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.