?
Solved

Read Continuous STream of XML

Posted on 2013-06-19
7
Medium Priority
?
315 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:sedgwick
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:sedgwick
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
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!

 
LVL 42

Expert Comment

by:sedgwick
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

777 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