C # calls Java WebService with 500 server errors

Source: Internet
Author: User
Tags response code

Recently in C # call Java Write WebService, found always return 500 server error, exactly what reason has not been found out,

After Google later, to find a foreign http://stackoverflow.com site has been encountered this problem.

Reprint as follows:

HttpWebRequest req = webrequest.create (URL) as HttpWebRequest; WebResponse WR = req. GetResponse ();

When the server returns Internal server Error, exception was thrown in req. GetResponse (). I would like the GetResponse () to accept this Response code, it's normal for the passed URL to throw this Response code. I would like to parse the Html despite Response Code Internal Server Error. Is it possible to say to GetResponse () method does not verify the Response Code?

Answer:

try{    HttpWebRequest req = webrequest.create (URL) as HttpWebRequest;    WebResponse WR = req. GetResponse ();} catch (WebException Wex) {    var pagecontent = new StreamReader (Wex. Response.getresponsestream ())                          . ReadToEnd ();}

The above code can be used to query the specific error message, and then further solve the problem.

Original address:

Http://stackoverflow.com/questions/18403846/httpwebrequest-accept-500-internal-server-error

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.