473,242 Members | 1,483 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,242 software developers and data experts.

HttpPost

I'm writing an app that needs to send info to a client by their specs,

m_request= "https://website.com/app?xml=xml_file&xmlString=<?xml
version='1.0' encoding='utf-8' ?>xmlfilecontentset...etc</endfile>"
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(m_request);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

Which works fine for a small file, 3k or less, but for a file with more
items in the xml file the server return a "500 Internal Server Error"

Is the HTTPWebResponse call basically a send statement instead of an
HttpPost? How would I do an HttpPost?

Thanks
Jun 27 '08 #1
5 6471
On May 16, 10:51 am, "Dave" <D...@newsgroup.nospamwrote:
I'm writing an app that needs to send info to a client by their specs,

m_request= "https://website.com/app?xml=xml_file&xmlString=<?xml
version='1.0' encoding='utf-8' ?>xmlfilecontentset...etc</endfile>"
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(m_request);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

Which works fine for a small file, 3k or less, but for a file with more
items in the xml file the server return a "500 Internal Server Error"

Is the HTTPWebResponse call basically a send statement instead of an
HttpPost? How would I do an HttpPost?

Thanks
You are probably exceeding the querystring limit. Most browsers limit
it to between 2k-3k. In this case, its getting exceeded on the server
side.

for posting you could use WebClient.UploadString method.
Jun 27 '08 #2
"500 Internal Server Error" is a problem on the server side not the
client side (your code).

The URL in a request has a size limit. You may be overflowing this
limit with a very large string.

You can use the WebClient object to .UploadString or .UploadValues for
name/value pairs but this limits your properties you can set.

I typically use the following just like a FORM POST.

HttpWebRequest req =
(HttpWebRequest)WebRequest.Create(@"http://website.com/webapp/
page.aspx");
req.Credentials = new NetworkCredential("name",
"pass");
req.KeepAlive = true;
req.Method = "POST"; //must be uppercase on some
webservers
req.ContentType = @"text/xml";
req.ProtocolVersion = HttpVersion.Version11;
using (StreamWriter writer = new
StreamWriter(req.GetRequestStream()))
{
string uploadString = "xml=xml_file&xmlString=" +
data; //where data is your predefined payload
writer.WriteLine(uploadString);
}
WebResponse res = req.GetResponse();
StreamReader read = new
StreamReader(res.GetResponseStream());
string fullResponse = read.ReadToEnd();
Jun 27 '08 #3
Hi Dave,

As other members have mentioned, the error you encounter is likely due to
the data you appened in request's url(querystring) has exceeded the max
length of the http querystring limit. Normally, for very large data, HTTP
POST protocol is surely the recommended means to post them.

As for how to do http post with .NET component, you can use either
WebClient or HttpWebRequest class. For webrequest class, you need to open
the "RequestStream" of it and then write the message body(you want to
transfer) into the requeststream and then send it. AdemusPrime has posted
some detailed code sample in his message, you can have a look.

Here are some other web article provided sample code of doing http post
with .NET webrequest component:

http://authors.aspalliance.com/steve...netscrape2.asp

http://weblogs.asp.net/ngur/archive/...11/129951.aspx

http://www.netomatix.com/httppostdata.aspx

Hope this also helps some.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>From: "Dave" <DW**@newsgroup.nospam>
Subject: HttpPost
Date: Fri, 16 May 2008 10:51:45 -0400
I'm writing an app that needs to send info to a client by their specs,

m_request= "https://website.com/app?xml=xml_file&xmlString=<?xml
version='1.0' encoding='utf-8' ?>xmlfilecontentset...etc</endfile>"
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(m_request);
HttpWebResponse response = (HttpWebResponse)request.GetResponse();

Which works fine for a small file, 3k or less, but for a file with more
items in the xml file the server return a "500 Internal Server Error"

Is the HTTPWebResponse call basically a send statement instead of an
HttpPost? How would I do an HttpPost?

Thanks
Jun 27 '08 #4
Hi Dave,

Have you got any progress? If there is anything else need help, welcome to
post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: st*****@online.microsoft.com (Steven Cheng [MSFT])
Organization: Microsoft
Date: Mon, 19 May 2008 02:36:47 GMT
Subject: RE: HttpPost
>
Hi Dave,

As other members have mentioned, the error you encounter is likely due to
the data you appened in request's url(querystring) has exceeded the max
length of the http querystring limit. Normally, for very large data, HTTP
POST protocol is surely the recommended means to post them.

As for how to do http post with .NET component, you can use either
WebClient or HttpWebRequest class. For webrequest class, you need to open
the "RequestStream" of it and then write the message body(you want to
transfer) into the requeststream and then send it. AdemusPrime has posted
some detailed code sample in his message, you can have a look.

Here are some other web article provided sample code of doing http post
with .NET webrequest component:

http://authors.aspalliance.com/steve...netscrape2.asp

http://weblogs.asp.net/ngur/archive/...11/129951.aspx

http://www.netomatix.com/httppostdata.aspx

Hope this also helps some.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

================================================= =
Get notification to my posts through email? Please refer to
http
Jun 27 '08 #5
Steve,
I am using the WebClient and receiving this (500) Internal Server Error
message.

Here is my code for sending my XML data:
Dim strXML As String = "<?xml version='1.0' encoding='utf-8'?>" &
CustomerInformation.DataSet.GetXml()
'Dim XmlData() As Byte =
System.Text.Encoding.UTF8.GetBytes(strXML.ToString ())
Dim WebClient As New System.Net.WebClient()
WebClient.Headers.Add("Content-Type", "text/xml")
WebClient.Encoding = System.Text.Encoding.UTF8
CustomerNumber = WebClient.UploadString(New Uri(RegURI &
"RegisterClient.aspx"), strXML.ToString)

Here is my code for receiving the XML Data in RegisterClient.aspx:
Request.ContentType = "application/x-www-form-urlencoded"
Request.ContentEncoding = System.Text.Encoding.UTF8
Dim CustomerInformation As New
ENv.ClientRegistrationData.CustomerInformationData Table

Try
CustomerInformation.ReadXml(Request.InputStream)
Catch ex As Exception
Exit Sub
End Try

What could be wrong here?

THanks in advance!
Ron
"Steven Cheng [MSFT]" wrote:
Hi Dave,

Have you got any progress? If there is anything else need help, welcome to
post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: st*****@online.microsoft.com (Steven Cheng [MSFT])
Organization: Microsoft
Date: Mon, 19 May 2008 02:36:47 GMT
Subject: RE: HttpPost

Hi Dave,

As other members have mentioned, the error you encounter is likely due to
the data you appened in request's url(querystring) has exceeded the max
length of the http querystring limit. Normally, for very large data, HTTP
POST protocol is surely the recommended means to post them.

As for how to do http post with .NET component, you can use either
WebClient or HttpWebRequest class. For webrequest class, you need to open
the "RequestStream" of it and then write the message body(you want to
transfer) into the requeststream and then send it. AdemusPrime has posted
some detailed code sample in his message, you can have a look.

Here are some other web article provided sample code of doing http post
with .NET webrequest component:

http://authors.aspalliance.com/steve...netscrape2.asp

http://weblogs.asp.net/ngur/archive/...11/129951.aspx

http://www.netomatix.com/httppostdata.aspx

Hope this also helps some.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http

Jul 20 '08 #6

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

Similar topics

0
by: samtai | last post by:
I need to do a synchronous POST to a web server with a string variable and receive back the response into a second string variable. It seems that with .NET I find myself needing to use lots of...
4
by: MTB | last post by:
I created a webservice, but I can't call the webservice using HTTP GET. SOAP and POST work fine, but not GET. Am I missing something in the configuration?
14
by: John A Grandy | last post by:
has anyone successfully used HttpWebRequest or WebClient class to simulate submission of a simple HTML form? for example: a very simple plain-vanilla form with a textbox and a button. when the...
1
by: Kevin Landymore | last post by:
I have a vb.net service running under a Domain account. I'm trying to call a web service on our Mainframe (IBM CICS via SSL and Client Certificates) and after a while (1 or 2 days.. thousands of...
0
by: Edmund Green | last post by:
Included below is a minimal web-service implementation to recreate a problem I've encountered in a web service that has methods returning classes with the same local name (but in different...
1
by: Maxwell2006 | last post by:
Hi, How can I disable HttpGet and HttpPost access to my asmx webservice? Thank you,
0
by: Matthew Lock | last post by:
Hello, I am enabling my web service via HttpPost so that a simple Javascript client can access web services by posting with XmlHttpRequest. I have added the following nodes into my web.config to...
1
by: miki | last post by:
i m trying to get xml response from httppost, the xml include the char "&" thnks miki
5
by: thisismykindabyte | last post by:
Hello, I was wondering if anyone could refer me to a good website that details what exactly makes up the GET and POST methods of a HttpRequest/Response class? Basically, I am trying to figure...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.