473,395 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

xml post slow

I'm posting an XML-string to a website. I'm using the function below.
The problem is that it is extremely slow and I get many time-outs. Does
anyone have any solutions ? Other solutions to post an XML to a website
are also welcome.

Many thanks,

Steven
Private Function postXMLToSite(ByVal xml As String, ByRef errors As
String) As Boolean
Try
Dim bytes As Byte()
bytes = Encoding.UTF8.GetBytes(xml)
Dim request As HttpWebRequest
request =
CType(WebRequest.Create(MySettings.getValue("xmlsi te")), HttpWebRequest)
request.Method = "POST"
request.ContentLength = bytes.Length
request.ContentType = "text/xml"
Dim requestStream As Stream
request.GetRequestStream.Write(bytes, 0, bytes.Length)
Dim resp As HttpWebResponse
resp = CType(request.GetResponse, HttpWebResponse)
If resp.StatusCode = HttpStatusCode.OK Then
resp.Close()
Return True
Else
resp.Close()
Return False
End If
Catch ex As Exception
Return False
End Try
End Function


MySettings.getValue("xmlsite") returns the url where the xml is posted to.
Nov 21 '05 #1
2 2604
PS: I get the timeout at the line:

request.GetRequestStream.Write(bytes, 0, bytes.Length)

Steven
steven wrote:
I'm posting an XML-string to a website. I'm using the function below.
The problem is that it is extremely slow and I get many time-outs. Does
anyone have any solutions ? Other solutions to post an XML to a website
are also welcome.

Many thanks,

Steven
Private Function postXMLToSite(ByVal xml As String, ByRef errors As
String) As Boolean
Try
Dim bytes As Byte()
bytes = Encoding.UTF8.GetBytes(xml)
Dim request As HttpWebRequest
request =
CType(WebRequest.Create(MySettings.getValue("xmlsi te")), HttpWebRequest)
request.Method = "POST"
request.ContentLength = bytes.Length
request.ContentType = "text/xml"
Dim requestStream As Stream
request.GetRequestStream.Write(bytes, 0, bytes.Length)
Dim resp As HttpWebResponse
resp = CType(request.GetResponse, HttpWebResponse)
If resp.StatusCode = HttpStatusCode.OK Then
resp.Close()
Return True
Else
resp.Close()
Return False
End If
Catch ex As Exception
Return False
End Try
End Function


MySettings.getValue("xmlsite") returns the url where the xml is posted to.

Nov 21 '05 #2
The stream seems to be the problem. I had this changed and it worked
perfectly:

....
Dim requestStream As Stream
requeststream = request.GetRequestStream
requeststream.Write(bytes, 0, bytes.Length)
requeststream.Close
Dim resp As HttpWebResponse
....

Thanks anyway.

Steven

steven wrote:
PS: I get the timeout at the line:

request.GetRequestStream.Write(bytes, 0, bytes.Length)

Steven
steven wrote:
I'm posting an XML-string to a website. I'm using the function below.
The problem is that it is extremely slow and I get many time-outs.
Does anyone have any solutions ? Other solutions to post an XML to a
website are also welcome.

Many thanks,

Steven
Private Function postXMLToSite(ByVal xml As String, ByRef errors
As String) As Boolean
Try
Dim bytes As Byte()
bytes = Encoding.UTF8.GetBytes(xml)
Dim request As HttpWebRequest
request =
CType(WebRequest.Create(MySettings.getValue("xmlsi te")), HttpWebRequest)
request.Method = "POST"
request.ContentLength = bytes.Length
request.ContentType = "text/xml"
Dim requestStream As Stream
request.GetRequestStream.Write(bytes, 0, bytes.Length)
Dim resp As HttpWebResponse
resp = CType(request.GetResponse, HttpWebResponse)
If resp.StatusCode = HttpStatusCode.OK Then
resp.Close()
Return True
Else
resp.Close()
Return False
End If
Catch ex As Exception
Return False
End Try
End Function


MySettings.getValue("xmlsite") returns the url where the xml is posted
to.

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Lipei | last post by:
Testonly
2
by: cyberleo80 | last post by:
i'm tring to send post data using set objSrvHTTP = Server.CreateObject ("WinHTTP.WinHTTPRequest.5.1") .... objSrvHTTP.send xmlstring but the transfer rate is very low(4 min per MB on LAN).....
2
by: David | last post by:
Hi, We have an internal network of 3 users. Myself & one other currently have individual copies of the front-end MS Access forms and via our individual ODBC links we have used the: File > Get...
5
by: Tarapia Tapioco | last post by:
FIRE THE DANAS FOR WRONG REPORTING, to MSNBC or WASH-POST JOURNALIST ACCURACY Hello American Sheeple, Tell us a glaring mistake in this article. If your IQ is TOO LOW, from eating McDeath...
3
by: Jennyfer J Barco | last post by:
In my application I have a datagrid. The code calls a Stored procedure and brings like 200 records. I created a dataset and then a dataview to bind the results of the query to my grid using ...
8
by: Gert | last post by:
Hi, I have a form (server side) because of the filling of variables through the application. But now I need to post it to an url on submit. My .HTML form looks like this, but how to translate it...
9
by: c676228 | last post by:
Hi, I am new to this discussion forum. I started to post questions on this forum since this Jan. and got many good responses and I am very appreciated to those who are willing to help with their...
1
by: vertigo | last post by:
Hello Sorry for my previous post (forget to change language) I use mail(). Postfix configured locally - properly - works fine and fast. But when i use mail() it's processed about 60 seconds....
2
by: =?Utf-8?B?UGF1bA==?= | last post by:
This is probably not the correct forum but not sure where to post this. I have a dell pc 2.4 gig intel processor, 1 gig ram, and am runing sql2005 and have vs 2003 and vs2005 installed plus...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.