473,397 Members | 2,056 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,397 software developers and data experts.

post data with HttpWebRequest to server

Hy
I have a problem with sending a request to an ArcIMS server. The data
never reaches the server and I get the following error message:
...
AXLParser: Document cannot be parsed correctly. Check encoding.
...

Please have a look at my code and tell me what I'm doing wrong!
Thanks

code start-----------------------------------------------
httprequest = (HttpWebRequest) WebRequest.Create(target);
string request = "<ARCXML
version='1.1'><REQUEST><GET_IMAGE><PROPERTIES></PROPERTIES></GET_IMAGE><
/REQUEST></ARCXML>";
encoding = new UTF8Encoding();
byte[] byte1 = encoding.GetBytes(request); httprequest.ContentLength =
request.Length;
httprequest.Method = "POST";
httprequest.ContentType = "text/xml; encoding='utf-8'";
requestStream = httprequest.GetRequestStream();
requestStream.Write(byte1, 0, byte1.Length);
requestStream.Close();
code end--------------------------------------------------
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #1
2 6033
Natalie wrote:
Hy
I have a problem with sending a request to an ArcIMS server. The data
never reaches the server and I get the following error message:
The data certainly reaches the server, or where do you expect the error
message from the parser to come from ;-)
..
AXLParser: Document cannot be parsed correctly. Check encoding.
..

Please have a look at my code and tell me what I'm doing wrong!


Well, can't you debug or at least log on the server-side? The error message
is pretty obvious, although I can't see no good reason why your code should
fail -- maybe adding an XML declaration helps?

Cheers,
--
Joerg Jooss
jo*********@gmx.net

Nov 16 '05 #2
Natalie <tr*****@student.ethz.ch> wrote:
I have a problem with sending a request to an ArcIMS server. The data
never reaches the server and I get the following error message:
..
AXLParser: Document cannot be parsed correctly. Check encoding.
..

Please have a look at my code and tell me what I'm doing wrong!
Thanks

code start-----------------------------------------------
httprequest = (HttpWebRequest) WebRequest.Create(target);
string request = "<ARCXML
version='1.1'><REQUEST><GET_IMAGE><PROPERTIES></PROPERTIES></GET_IMAGE><
/REQUEST></ARCXML>";
encoding = new UTF8Encoding();
byte[] byte1 = encoding.GetBytes(request); httprequest.ContentLength =
request.Length;
httprequest.Method = "POST";
httprequest.ContentType = "text/xml; encoding='utf-8'";
requestStream = httprequest.GetRequestStream();
requestStream.Write(byte1, 0, byte1.Length);
requestStream.Close();
code end--------------------------------------------------


Well, the first problem is that you've set the content length to the
number of *characters* rather than the number of bytes. As it happens,
that's okay in your example as the characters will all be encoded in
one byte each, but it's not a good idea in general.

The second problem is that you've got utf-8 in quotes in the content
type, which I don't believe it's meant to be.

The third problem *may* be that your XML doesn't start with a
<?xml version="1" encoding="UTF-8" ?> tag - I believe the UTF-8 is
implicit, but not having it at all may confuse the parser.

I don't know whether or not it's okay to be utf-8 instead of UTF-8, but
I have experience of the latter working.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3

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

Similar topics

2
by: Fatih BOY | last post by:
Hi, I want to send a report from a windows application to a web page like 'report.asp' Currently i can send it via post method with a context like local=En&Username=fatih&UserId=45&Firm=none...
3
by: ME | last post by:
Hi; I am getting "Unhandled Exception: System.Net.WebException: The remote server returned an erro r: (401) Unauthorized." when I am trying to get a page via post. Code follows...
5
by: Tammy | last post by:
Hi, I have an aspx app which needs to post data to a form and read the response. I am confused on whether I should be using the get_url using "POST" method or the post_url using "GET" method. ...
6
by: someone | last post by:
I am in a situation where I need to package some information from Page1, submit it via POST to another server which will process the information and then send the user to another page on my server...
5
by: Vishal | last post by:
Hello, I already asked this question in the ASP.NET forums, but no help came. So I am hoping that somebody can help me out. This is really very URGENT me. For my e-commerce application, I...
7
by: | last post by:
Hello, I would like to do the following from a asp.net button click: <form method="POST" action="https://www.1234.com/trans_center/gateway/direct.cgi"> <input type="hidden" name="Merchant"...
0
by: WIWA | last post by:
Hi, I want to login to a password protected website and fetch the content of the page behind. I have based my code on http://weblogs.asp.net/jdennany/archive/2005/04/23/403971.aspx. When I use...
3
by: Patrick Fogarty | last post by:
I am programming what is to be a web service client that will use an HTTP-POST to request and retrieve data. The remote server (written in java for what it's worth) requires basic authentication...
4
by: Natalia | last post by:
Hello, I need to provide the ability to post file and some form elements via our website (asp.net) to the third party website (asp page). On http://aspalliance.com/236#Page4 - I found great...
0
by: barrybevel | last post by:
Hi, I'm trying to login to the www.vodafone.ie website using HttpWebRequest. It works fine with IE/Firefox and the .NET Web Control too, just not with my code. I think it's a redirect 302...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...
0
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...

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.