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. 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.
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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Lipei |
last post by:
Testonly
|
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).....
|
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...
|
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...
|
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 ...
|
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...
|
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...
|
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....
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
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...
|
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,...
|
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...
| |