Solved

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

Posted on 2004-09-15
2
287 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 150 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

695 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