Solved

Read Continuous STream of XML

Posted on 2013-06-19
7
298 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
  • 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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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 500 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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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:…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

759 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now