Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Read Continuous STream of XML

Posted on 2013-06-19
7
Medium Priority
?
317 Views
Last Modified: 2013-06-24
I am trying to figure out the best way to consume a continuous stream of XML data from a service that is sending the data as a "constant" feed over HTTP.

I was considering using HttpWebRequest/Response but I am not sure how that will behave if the data just continuously streams.

Any thoughts?
0
Comment
Question by:lrbrister
[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
  • 3
  • 3
7 Comments
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 39261941
do u know when the stream is ended, i mean when the xml is response was fully received?
0
 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 39261951
0
 

Author Comment

by:lrbrister
ID: 39262292
sedgwick,
 I've implemented that

I get the initial response and then after 10 seconds or so the thread exits

I need that to stay open

I see in the example code this comment in the Main section...

        ' Keep the main thread from continuing while the asynchronous
        ' operation completes. A real world application
        ' could do something useful such as updating its user interface.
        allDone.WaitOne()

How do I keep this open???
That is what is killing me

Here's what is supposed to happen
This is a VOIP Phone system and my POST starts the monitoring process on a phone
I start to request by posting some xml to the URL
I get an initial response on that connection pretty much saying "Monitoring"
The connection stays open
Anything done on that phone causes more xml to come in on that same connection (thread?)

I'm getting the initial response...
I am not getting the following response streams

Seems to me this part should be changed in the
GetResponseCallback(ByVal asynchronousResult As IAsyncResult) ???

        Dim streamResponse As Stream = response.GetResponseStream()
        Dim streamRead As New StreamReader(streamResponse)
        Dim responseString As String = streamRead.ReadToEnd()


        Debug.WriteLine(responseString)
0
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

 
LVL 42

Expert Comment

by:Meir Rivkin
ID: 39262682
u mean the allDone.WaitOne() is signald but the stream is partial?
0
 

Author Comment

by:lrbrister
ID: 39262991
sedgewick,
  I guess...I'll try and explain the issue.
Sorry for any non sensical verbiage...

The Async is working
I post my xml command to the vendors server and get a response.
My command is basically "Start monitoring this phone number"  (Our VOIP System)

Their initial response is "yep...we're monitoring"
And I get this back
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<org.m5.api.v1.Response xmlns:m5="http://www.m5net.com/org/m5/data/v2/cti" xmlns:csta="http://www.ecma-international.org/standards/ecma-323/csta/ed5">
    <ErrorCount>0</ErrorCount>
    <Id>1</Id>
    <Result xsi:type="org.m5.data.v2.cti.HostedConnectObject" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <csta:MonitorStartResponse>
            <csta:monitorCrossRefID>400</csta:monitorCrossRefID>
        </csta:MonitorStartResponse>
    </Result>
</org.m5.api.v1.Response>

After I get this is where my current code is exiting from the process

But what is SUPPOSED to happen is

If my phone makes a call or receives one...the vendor sends me additional xml "chunks"

If nothing happens on my phone I get a "still monitoring" every 30 seconds

In any case I get additional xml at the most every 30 seconds
Example
<command>
  csta:monitorCrossRefID>400</csta:monitorCrossRefID>
</command>

The ongoing stream is what I'm not getting
My thread exits
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 39270879
Try setting the KeepAlive property of request to true and then call the responsestream.read in a loop.
0
 

Author Closing Comment

by:lrbrister
ID: 39271351
That did it.
Thanks
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

610 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