Click here to Skip to main content
15,887,373 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I need to add a method to my webservice that creates automatically a new log.xml file instead of creating it manually. I am working on visual studio 2010 with vb.net and soap webservice. I need to know where I have to add this method as it is not a webmethod?
any help is appreciated

What I have tried:

In website there are many events to deal with: pre-render, onload... but here i don't know what are the handled events.
Posted
Updated 3-Oct-16 4:01am

1 solution

Your question is very vague. If you need to create an XML file, this functionality is very well documented.

create XML file vb.net - Google Search[^]

Simply add a web method if you need one to your webservice to do this. If that is not a possibility, create a new class that generates log files with a method that takes the parameters you need to populate the log file. Inside that method, create the log file and then utilize that method in your code wherever you need it.

There isn't much we can help you with here as we don't have access to your computer, your code, nor do we read minds or know anything about your project. If you get working on your issue and get stuck somewhere, feel free to come back with a clear explanation of your issue and some sample code so we can try and replicate your issue. If you are able to do both of those things, I am sure you'll get more meaningful assistance.
 
Share this answer
 
Comments
H.AL 4-Oct-16 1:46am    
Dear,
thank you for your declaration, I was wondering how I can create a new log.xml file monthly for my webservice to catch data before being manipulated in our database. As we have a large amount of data and users, we need to create this file monthly to avoid issues of logging with big data. My question was: I have created a method to do all this but I don't want to implement it as a webmethod as it it is not used by clients, so where I have to place it? You suggested to put it wherever I am using logging, but I don't want to decelerate users work, isn't there any other way that automatically detects the first day of month and creates a new xml file? Below is my method:

Public Function CreateFile()
Dim firstDateNextMonth As Date = DateSerial(Date.Today.Year, Date.Today.Month + 1, 1) ' first day of next month
If Date.Now >= firstDateNextMonth Then

Dim Logfile = HttpContext.Current.Server.MapPath("~/Bin/log.xml") ' current log file name
Dim d = DateAdd("M", -1, Date.Now) ' getting the date of previous month
Dim fileRenamed = "log_" & d.ToString("MM") & ".xml" ' current file new name

If File.Exists(Logfile) Then
My.Computer.FileSystem.RenameFile(Logfile, fileRenamed) ' renaming current file
End If

Dim writer As New XmlTextWriter(Logfile, System.Text.Encoding.UTF8) ' creating new log.xml file
writer.WriteStartDocument(True)
writer.WriteStartElement("SUBMIT")
writer.WriteEndElement()
writer.WriteEndDocument()
writer.Close()

End If

End Function

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900