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

HTTP protocol violation - Urgent

Hi,
I am trying to send an XML request from ASPX page to A
servlet,,,and gets the XML response back. I am using
HttpWebRequest object. It throws exception as:

The underlying connection was closed: The server committed
an HTTP protocol violation.

Previously it was working fine but suddenly it has given
error like this,,,,and sometimes this error comes but
sometimes it doesnot.

Please suggest

Thanks
Sumit

Nov 18 '05 #1
3 1489
"sumit" wrote:
Hi,
I am trying to send an XML request from ASPX page to A
servlet,,,and gets the XML response back. I am using
HttpWebRequest object. It throws exception as:

The underlying connection was closed: The server committed
an HTTP protocol violation.

Previously it was working fine but suddenly it has given
error like this,,,,and sometimes this error comes but
sometimes it doesnot.

Please suggest


Um.. post some code?

--
Joerg Jooss
jo*********@gmx.net
Nov 18 '05 #2
code is as follows----

HttpWebRequest oHttpWebRequest = (HttpWebRequest)
(WebRequest.Create("http://xxx.com/abc/abc"));

Byte[] bytes = sXMLRequestStream.ToArray();

//convert byte array to string
string strReq;
strReq = Encoding.ASCII.GetString(bytes);

//convert byte array to string ends here
oHttpWebRequest.ContentType = "application/x-www-form-
urlencoded";
oHttpWebRequest.Method = "POST";
oHttpWebRequest.ContentLength = bytes.Length;
Stream oWStream = oHttpWebRequest.GetRequestStream();
oWStream.Write(bytes, 0, bytes.Length);
oWStream.Close();
//to receive
HttpWebResponse oHttpWebResponse = (HttpWebResponse)
(oHttpWebRequest.GetResponse());

OutResStream = oHttpWebResponse.GetResponseStream();
Pls suggest!!!1

-----Original Message-----
"sumit" wrote:
Hi,
I am trying to send an XML request from ASPX page to A
servlet,,,and gets the XML response back. I am using
HttpWebRequest object. It throws exception as:

The underlying connection was closed: The server committed an HTTP protocol violation.

Previously it was working fine but suddenly it has given
error like this,,,,and sometimes this error comes but
sometimes it doesnot.

Please suggest


Um.. post some code?

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

Nov 18 '05 #3
"sumit" wrote:
code is as follows----

HttpWebRequest oHttpWebRequest = (HttpWebRequest)
(WebRequest.Create("http://xxx.com/abc/abc"));

Byte[] bytes = sXMLRequestStream.ToArray();

//convert byte array to string
string strReq;
strReq = Encoding.ASCII.GetString(bytes);

//convert byte array to string ends here
oHttpWebRequest.ContentType = "application/x-www-form-
urlencoded";
oHttpWebRequest.Method = "POST";
oHttpWebRequest.ContentLength = bytes.Length;
Stream oWStream = oHttpWebRequest.GetRequestStream();
oWStream.Write(bytes, 0, bytes.Length);
oWStream.Close();
//to receive
HttpWebResponse oHttpWebResponse = (HttpWebResponse)
(oHttpWebRequest.GetResponse());

OutResStream = oHttpWebResponse.GetResponseStream();


Two things seem wrong:

- You're using ASCII encoding. Is all your XML content really plain
ASCII? Otherwise you'll lose content here.

- The content type should not be "application/x-www-form-urlencoded",
because you're not posting a HTML form. Something like "text/xml" is
more appropriate here.

Cheers,
--
Joerg Jooss
jo*********@gmx.net
Nov 18 '05 #4

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

Similar topics

8
by: turnit \(removethis\) | last post by:
I have a login form that uses the post method to carry the information to the next page. The form works just fine in ie6.0, but fails in mozilla and fails in ie5.2 on a mac. "HTTP/1.1 400 Bad...
5
by: Henrik | last post by:
Hi, I am trying to read some industrial webservers using the HTTP/CGI webequest like this: wrs = (HttpWebRequest)WebRequest.Create(HTTP/CGI-string); mwst = (HttpWebResponse wrs.GetResponse();...
0
by: Helen | last post by:
Hi, I am trying to use a .Net WebClient object to read data from a url, but I am getting the following error: System.Net.HttpWebRequest.CheckFinalStatus()...
1
by: Dan W. | last post by:
Does anyone have any experience with this problem. I am trying to post about 20 fields of information to another server using System.Net.WebClient.UploadData. This works fine for some servers but...
0
by: Glauco | last post by:
Hi all, I have an urgent issue using some WebServices in ZSI and python 2.3.3. The Server Was obviously an ISS and today all my comunication end with: File...
7
by: Tom | last post by:
Hello all: I have a method that does a POST to a secured website using HttpWebRequest. It worked when logging in the site, but it failed with an HTTP prococol violation error when it is used to...
1
by: Khadim | last post by:
I m using HTTWebResponse which is running smoothly on my system which is behing a proxy server. When I run the application with Live IP it gives "HTTP Protocol violation error" I can't use...
3
by: JansenH | last post by:
We have implemented a 'HTTP Post' client in C# that posts Xml documents to a webserver. This is working fine if the post rate is one post for every 20 seconds. But if the post rate is increased to...
0
by: Marcus Ogden | last post by:
Hello, A client of ours using the Squid proxy server (version 2.5.STABLE6-3.4E.12.1) on Red Hat Enterprise Linux 4 is experiencing a problem when running our .NET 2.0 client application, which...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.