Solved

HttpWebRequest

Posted on 2013-07-01
8
474 Views
Last Modified: 2013-07-01
I feel stupid for asking...

Is there any way to do a "phased POST" on an HttpWebRequest?

In my code below
Without opening another connection
can the Dim newStream As Stream = sendWebRequest.GetRequestStream() be done in pieces?

Here's my code that works.
Dim sendWebRequest As HttpWebRequest = CType(WebRequest.Create(stUrl), HttpWebRequest)

'Following items 
 sendWebRequest.SendChunked = True
sendWebRequest.Method = "POST"
sendWebRequest.ContentType = "text/plain"
sendWebRequest.KeepAlive = True
sendWebRequest.UserAgent = "CometTest"
sendWebRequest.ServicePoint.ConnectionLimit = 20
sendWebRequest.Timeout = 43200


Dim encodedData As New ASCIIEncoding()
Dim byteArray As Byte() = encodedData.GetBytes(sendRow)

sendWebRequest.ContentLength = byteArray.Length

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

Open in new window

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
  • 4
  • 3
8 Comments
 
LVL 11

Expert Comment

by:lenordiste
ID: 39291121
what is supposed to be a "phased POST" for you? if you are looking for the asynchronous way of handling this, here is a start:
http://msdn.microsoft.com/en-us/library/system.net.webrequest.getrequeststreamasync.aspx

if not, what are you trying to accomplish :) ?
0
 

Author Comment

by:lrbrister
ID: 39291138
I have a POST of XML I'm sending to the HttpWebRequest
It looks like
<command><id>1</id></command>
<command><id>2</id></command>
<command><id>3</id></command>
<command><id>4</id></command>
<command><id>5</id></command>
<command><id>6</id></command>
<command><id>7</id></command>
<command><id>8</id></command>

So I want to "Open a Post???"
send first 4
pause 1000 milli seconds with a sleep
send the other 4
Complete the post.

I THINK this is a dumb question...
Just not experienced enough with the POST part to know.
0
 
LVL 82

Expert Comment

by:David Johnson, CD, MVP
ID: 39291202
After you've done the first post would not the server then think that you've finished and not know what to do with the remaining posts?
0
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 

Author Comment

by:lrbrister
ID: 39291211
ve3ofa

That's what I keep trying to say.

As I mentioned above..
This is not my area of expertise.

So that's why I'm asking if there is a "threaded" post
0
 
LVL 11

Expert Comment

by:lenordiste
ID: 39291230
the only thing that comes to mind is the http keep-alive which is turned on by default and allows http requests to reuse TCP connections. Codewise there's no really such thing as to "open a post". That being said, why don't you use more than one xml command in a single post?
0
 

Author Comment

by:lrbrister
ID: 39291237
lenordiste

Not sure that would work

In my list above I'm currently posting 4 at a time in separate threaded posts.

On the VENDOR end...
They only allow (x) numbers in the "waiting" status on the post at a time.

In any event...
How could I send more that one xml command at a time?
0
 
LVL 11

Accepted Solution

by:
lenordiste earned 500 total points
ID: 39291238
your scenario looks fine by the way:
send first 4
wait a bit
send next 4
etc.

there is some overhead for each POST of course, but you cannot reduce that overhead in any meaningful way. If you are looking for performance improvements you may consider using json or another lighter data format than XML.
0
 

Author Closing Comment

by:lrbrister
ID: 39291317
Thanks
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

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

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…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

630 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