473,769 Members | 2,085 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Crea te(target);
string request = "<ARCXML
version='1.1'>< REQUEST><GET_IM AGE><PROPERTIES ></PROPERTIES></GET_IMAGE><
/REQUEST></ARCXML>";
encoding = new UTF8Encoding();
byte[] byte1 = encoding.GetByt es(request); httprequest.Con tentLength =
request.Length;
httprequest.Met hod = "POST";
httprequest.Con tentType = "text/xml; encoding='utf-8'";
requestStream = httprequest.Get RequestStream() ;
requestStream.W rite(byte1, 0, byte1.Length);
requestStream.C lose();
code end--------------------------------------------------
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #1
2 6050
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*****@studen t.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.Crea te(target);
string request = "<ARCXML
version='1.1'>< REQUEST><GET_IM AGE><PROPERTIES ></PROPERTIES></GET_IMAGE><
/REQUEST></ARCXML>";
encoding = new UTF8Encoding();
byte[] byte1 = encoding.GetByt es(request); httprequest.Con tentLength =
request.Length;
httprequest.Met hod = "POST";
httprequest.Con tentType = "text/xml; encoding='utf-8'";
requestStream = httprequest.Get RequestStream() ;
requestStream.W rite(byte1, 0, byte1.Length);
requestStream.C lose();
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.co m>
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
20748
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 But the problem occures when i want to send a data with & sign (i.e: Firm=F&B). I try to solve this problem with using boundary, but i failed. Any idea!?
3
15756
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
17390
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. string get_url = "http://scmvs4:9090/gtccinfo/H485W020.HTML"; --url contains a form string post_url = "http://scmvs4:9090/cgi-bin/gticglnk/P485VEGA"; --called by get_Url upon submit
6
2076
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 (Page2). I have looked at HttpWebRequest on numerous coding websites but have not found a method that works. Does anyone have a solution for this or has seen an example that works for this situation? This is one very frustrating issue that I...
5
3029
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 need to send data from my server via the post method to the payment server. The payment server does not run asp.net. I dont know what they run. The payment server then returns to my server with the
7
4264
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" value="Merchant Name"> <input type="hidden" name="OrderID" value="Unique OrderID value"> <input type="hidden" name="email" value="Customers email address (OPTIONAL)">
0
3884
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 tools like ieHTTPHeaders v1.6, and I perform a normal login (using the normal website), I see that the viewstate is __VIEWSTATE=dDwxMzU4OTE3NTA2Ozs%2BTK88jS63JXN181X3N8zKivua8co%3D&txt_username=xxx&txt_password=xxxxxx&btn_login=Login. When I...
3
6932
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 as per RFC 2617 (http://www.faqs.org/rfcs/rfc2617.html). My attempts to authenticate are failing. The server requires the header to be present with the request. For security reasons, it will not reply in any way if the header is not present. ...
4
12711
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 advices but still having troubles... it might some obvious error that I am making but I just dont see it. ==================FIRST - Webclient=================================
0
12782
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 problem. I'm using this code in a ASP.NET 2.0 application just in case that matters, maybe someone knows a better way to do this?
0
9589
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10216
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10049
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8873
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5309
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3965
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 we have to send another system
2
3565
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.