xmlhttp post question

G

Guest

I have the following code where I call my web service in my asp.net (version)
application.

Dim strResult As String

Dim url As String
url = "http://localhost/myservice/test"

xmlRequest = Server.CreateObject("MSXML2.XMLHTTP")
xmlRequest.Open("post", url, False)
xmlRequest.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded")
xmlRequest.setRequestHeader("charset", "utf-8")
xmlRequest.setRequestHeader("Content-Length",
CStr(Len(TextBox1.Text)))

xmlRequest.Send("order=" + TextBox1.Text)
xmlRequest.send()
strResult = xmlRequest.responseText.ToString
TextBox2.Text = strResult
xmlRequest = Nothing

Everything works well as long as the content of my textbox1 is less than 8k
in size (8968 is the maximum that my webservice is receving).

Is that a limitation of MSXML2.XMLHTTP?? Is there a workaround?

Many thanks in advance.
Shahriar
 
M

Martin Honnen

Shahriar said:
I have the following code where I call my web service in my asp.net (version)
application.

Dim strResult As String

Dim url As String
url = "http://localhost/myservice/test"

xmlRequest = Server.CreateObject("MSXML2.XMLHTTP")

Are you using MSXML in an ASP.NET application? Why don't you use managed
objects like WebRequest/HttpWebRequest or WebClient?
xmlRequest.Open("post", url, False)
xmlRequest.setRequestHeader("Content-Type",
"application/x-www-form-urlencoded")
xmlRequest.setRequestHeader("charset", "utf-8")
xmlRequest.setRequestHeader("Content-Length",
CStr(Len(TextBox1.Text)))

xmlRequest.Send("order=" + TextBox1.Text)

Where do you make sure that TextBox1.Text is properly encoded as
application/x-www-form-urlencoded?
xmlRequest.send()

Why do you call the send method twice?
 
G

Guest

Martin -
Thanks for your response.
I am aware that I can use WebRequest/HTTP webrequest or webClient as an
option. My question was related to the limitation of the msxml2.xmlhttp
itself (more educational than anything).

Since this code works perfectly for when the content of textbox1.text is
less than 8k, I was wondering if there is a way to actually make this code
work.

As for sending the request.send() twice....It was a mistake when I pasted
the code and accidentally removed the quote as it was a comment line.

THanks again.
Shahriar
 
M

Martin Honnen

Shahriar wrote:

My question was related to the limitation of the msxml2.xmlhttp
itself (more educational than anything).

Since this code works perfectly for when the content of textbox1.text is
less than 8k, I was wondering if there is a way to actually make this code
work.

Using MSXML with .NET is not supported:
<http://support.microsoft.com/kb/815112/en-us>
I am not aware of any 8k limit with POST requests by MSXML XMLHTTP. It
is hard to tell what goes wrong, it might be that the problem you see is
the not properly encoded request body as you set the request header to
indicate a certain content type but your code does nothing to ensure the
request body is encoded that way.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top