Solved

HttpWebRequest

Posted on 2013-07-01
8
470 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
  • 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 80

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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…
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 quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

808 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