Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

HttpWebRequest

Posted on 2013-07-01
8
Medium Priority
?
478 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 83

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
The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

 

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

Industry Leaders: 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!

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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 tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

715 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