473,472 Members | 2,191 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 6476
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.