Click here to Skip to main content
15,881,715 members
Articles / Web Development / ASP.NET

Building a Generic Data Feed Web Service

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
31 Dec 2010CPOL2 min read 22.1K   176   13  
How to build a multi-purpose Web Service for recieving multiple data feeds.
Imports System.IO
Imports System.Data
Imports Microsoft.VisualBasic

Public Class CaseElse
    Inherits ACommand

    Protected mBaseDirectory As String = AppDomain.CurrentDomain.BaseDirectory & "Feeds\"

    Public Overrides Function Execute(ByVal args As PropertyCollection) As Object
        Dim feedName As String = args("feedName")
        Dim xmlData As String = args("xmlData")
        Dim fileName As String = Format(Date.Now, "yyyyMMddhhmmssfff") & ".xml"
        Dim wrt As StreamWriter

        Try

            If Not Directory.Exists(mBaseDirectory) Then
                Directory.CreateDirectory(mBaseDirectory)
            End If

            If Not Directory.Exists(mBaseDirectory & feedName & "\") Then
                Directory.CreateDirectory(mBaseDirectory & feedName & "\")
            End If

            wrt = New StreamWriter(mBaseDirectory & feedName & "\" & fileName)
            wrt.Write(xmlData)
            wrt.Flush()
            wrt.Close()

            Return "Okay"

        Catch ex As Exception

            Return ex.ToString

        Finally

            wrt = Nothing

        End Try

    End Function

End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

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


Written By
Software Developer Self-Employed
United States United States
I have over 25 years experience in programming desktop applications and over 10 years in web applications. I've written two books on computer programming: "Hands-On Programming Fundamentals, 2nd Ed" and "Hands-On Design Patterns for Visual Basic, 3rd Ed."

Comments and Discussions