[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 264
  • Last Modified:

Is it possible Http POST with response and listener

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
lrbrister
Asked:
lrbrister
1 Solution
 
käµfm³d 👽Commented:
What is your business goal?
0
 
lrbristerAuthor Commented:
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
 
lrbristerAuthor Commented:
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
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.  

 
Monica PCommented:
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
 
CodeCruiserCommented:
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
 
lrbristerAuthor Commented:
CodeCruiser
That sounds right
Do you have an example?
0
 
CodeCruiserCommented:
No. Do you have code which you use to POST and get initial response?
0
 
lrbristerAuthor Commented:
CodeCruiser
I'll post that first thing in the morning
Traveling today
0
 
lrbristerAuthor Commented:
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
 
lrbristerAuthor Commented:
That did it across the board.
Thanks
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now