Solved

Is it possible Http POST with response and listener

Posted on 2013-06-20
10
258 Views
Last Modified: 2013-06-24
Is it possible to do an HTTP post by

set a HttpWebRequest

post some xml as paramaters

set the httpwebresponse


start a httplistener

And then funnel the httpwebresponse through the listener and output insode the listener??
0
Comment
Question by:lrbrister
10 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39263324
What is your business goal?
0
 

Author Comment

by:lrbrister
ID: 39263354
kaufmed,
 I've been going after this problem from many different angles and just can't figure it out

Basically...
I do an HTTPWebRequest POST

Once that happens, the site I'm posting to will send back xml in full "sets"
ANything from 1 second to 30 seconds apart
It's an ongoing continuous stream of data

I need to handle that "ResponseStream???" without my connection being closed after the first full XML set comes back

This process will need to be started each morning and run 12 hours
And then shut down
0
 

Author Comment

by:lrbrister
ID: 39266998
So...
I think the proper way to clarify my question is that I need to open a connection with an HTTP Request
and receive an unknown (and potentially unbounded) amount of data in the response.

What should I do that with?

TCP Connection?
HttpWebrequest and Response
HttpListener?
0
MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

 
LVL 10

Expert Comment

by:Monica P
ID: 39267738
As far i understood ., i am posting this response

In case if you want to read the posted parameters in a form then
you can do as below

 
  For Each s As String In Request.Form.AllKeys
                        strTest = strTest & s & " : " & Request.Form(s)
                    Next

Open in new window


strtest will contain all posted parameter values

you can also fetch the values using
request.form("Paramtername")
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 335 total points
ID: 39268701
I have not tried this but set the KeepAlive property of request to true and then use a loop to call Read method on your response stream. This method blocks until there is data available to read.
0
 

Author Comment

by:lrbrister
ID: 39269304
CodeCruiser
That sounds right
Do you have an example?
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 39269768
No. Do you have code which you use to POST and get initial response?
0
 

Author Comment

by:lrbrister
ID: 39269872
CodeCruiser
I'll post that first thing in the morning
Traveling today
0
 

Author Comment

by:lrbrister
ID: 39271149
CodeCruiser,

Here is the POST code that I've been using

Dim myHttpWebRequest As HttpWebRequest = CType(WebRequest.Create(stUrl), HttpWebRequest)

myHttpWebRequest.SendChunked = True
Dim postData As String = strParamsPost
'Debug.WriteLine(postData)

myHttpWebRequest.Method = "POST"

myHttpWebRequest.ContentType = "text/plain"
myHttpWebRequest.KeepAlive = True
myHttpWebRequest.UserAgent = "CometTest"

Dim encodedData As New ASCIIEncoding()
Dim byteArray As Byte() = encodedData.GetBytes(postData)
myHttpWebRequest.ContentLength = byteArray.Length

Dim newStream As Stream = myHttpWebRequest.GetRequestStream()
newStream.Write(byteArray, 0, byteArray.Length)
newStream.Close()

Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)

Dim streamResponse As Stream = myHttpWebResponse.GetResponseStream()

Open in new window

0
 

Author Closing Comment

by:lrbrister
ID: 39271357
That did it across the board.
Thanks
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

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 …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
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 use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

839 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