[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How to stream large amount of data from windows service to web service?

Posted on 2004-09-15
2
Medium Priority
?
289 Views
Last Modified: 2012-05-05
Hi,
 I am writing both the windows service and the web service.
 The windows service is supposed to transfer a large amount of data to the web service.   I would like to stream data if possible.  How can I do this?  
Both services will be written in VB.NET.

Thanks

K
0
Comment
Question by:Khaki
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Accepted Solution

by:
samitt earned 450 total points
ID: 12105855
With an HTTP Post you could stream upto 1 GB of data. Here's an example
/********************Windows Service**************************/
  Private Sub btnPost_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPost.Click

        Dim xDoc = New XmlDocument

        Dim mywriter As StreamWriter
        Try

            Dim input, ip As String
            Dim s_strURL As String
            Dim strRead As StreamReader = File.OpenText("C:\ABC.txt")
            Dim strR As StreamReader = File.OpenText("C:\ABC.txt")


            s_strURL = "http://........./WebForm1.aspx"

            Dim bojRequest As HttpWebRequest = WebRequest.Create(s_strURL)

            bojRequest.Method = "POST"

            'input = strRead.ReadToEnd
            ip = strR.ReadToEnd

            bojRequest.ContentLength = ip.Length

            bojRequest.ContentType = "text/text"



            Try

                mywriter = New StreamWriter(bojRequest.GetRequestStream())

                input = strRead.ReadLine
                While Not input Is Nothing

                    mywriter.Write(input)
                    input = strRead.ReadLine

                End While

                'mywriter.Write(input)


                mywriter.Close()

            Catch ex As Exception

                MsgBox(ex.Message())

            End Try

            Dim objResponse As HttpWebResponse = bojRequest.GetResponse()

            Dim sr As StreamReader


            sr = New StreamReader(objResponse.GetResponseStream())

            result = sr.ReadToEnd

            MsgBox(result)

        Catch ex As Exception

            MsgBox(ex.Message())

        End Try

    End Sub


/******************Web Form (or Service)*************************/

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here




        ''Response.Write(Request.Files.Count & ": Files Received")

        Dim str As Stream, strmContents As String
        Dim counter, strLen, strRead As Integer


        str = Request.InputStream


        strLen = CInt(str.Length)


        Dim strArr(strLen) As Byte


        strRead = str.Read(strArr, 0, strLen)


        For counter = 0 To strLen - 1
            strmContents = strmContents & Chr(strArr(counter).ToString)
        Next counter

        Response.Write(strmContents)





    End Sub
0
 

Author Comment

by:Khaki
ID: 12120323
thanks, that is one solution, but I found another solution using DIME
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question