Solved

getting Status500 when i call HttpClient.executeMethod(Post)

Posted on 2009-07-14
11
1,514 Views
Last Modified: 2013-11-18
Trying to call a webservice which has Basic Authetication. I am passing in the valid crediantials but some how getting status 500 at getExecuteMethod(). Does this mean call to the webservice successful?? Please help.. Its very urgent..
HttpClient client = new HttpClient();
 

			// pass our credentials to HttpClient, they will only be used for

			// authenticating to servers with realm "realm" on the host

			// "www.verisign.com", to authenticate against

			// an arbitrary realm or host change the appropriate argument to null.

			client.getState().setCredentials(

				new AuthScope(

					AuthScope.ANY_HOST,

					AuthScope.ANY_PORT,

					AuthScope.ANY_REALM),

				new UsernamePasswordCredentials(

					userName,

					password));

	

	

	

	

			// create a GET method that reads a file over HTTPS, we're assuming

			// that this file requires basic authentication using the realm above.

			post = new PostMethod(url);

					

			post.setDoAuthentication(true);
 

			RequestEntity entity = new StringRequestEntity(soapRequest);

			post.setRequestEntity(entity);

			

			

			ILogger.ITimer t = getLogger().createTimer();

			

	

			//	timer.setAutoReset(true);
 

			status = client.executeMethod(post);

			 if (status != HttpStatus.SC_OK) {

			 	System.err.println("Method failed: " + post.getStatusLine());

			 }
 

Here is the log file info:

[7/14/09 21:19:56:206 EDT] 00000027 AuthChallenge I org.apache.commons.httpclient.auth.AuthChallengeProcessor selectAuthScheme basic authentication scheme selected

[7/14/09 21:19:56:503 EDT] 00000027 SystemOut     O executeMethod() = 0.469 seconds

[7/14/09 21:19:56:503 EDT] 00000027 SystemOut     O HTTP Status Code = 500

[7/14/09 21:19:56:519 EDT] 00000027 SystemOut     O Error occured when posting soap request.  HTTP status(500). and the exception is org.xml.sax.SAXParseException: Content is not allowed in prolog.

Open in new window

0
Comment
Question by:Subhachandu
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 23

Expert Comment

by:Ajay-Singh
ID: 24855560
I don't think getting 500 response code has to do with
(in)valid credentials. You get an error "Not Authorized"
when the credentials are not valid.
0
 
LVL 92

Expert Comment

by:objects
ID: 24855585
check the server logs, 500 indicates an error on the sertver
0
 

Author Comment

by:Subhachandu
ID: 24855591
Yes, I know i passed in valid credentials, but any idea why Status 500 is getting for executeMethod()??
0
 

Author Comment

by:Subhachandu
ID: 24855600
I noticed in the logs, i am able to see this .. Why is this exception coming up??
Error occured when posting soap request.  HTTP status(500). and the exception is org.xml.sax.SAXParseException: Content is not allowed in prolog.
0
 
LVL 92

Expert Comment

by:objects
ID: 24855638
sounds like a problem reading xml
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:Subhachandu
ID: 24855656
does that mean my client is able to communicate the webservice and trying it read its xml??
0
 
LVL 92

Expert Comment

by:objects
ID: 24855708
no way to tell whats happening from what you have posted
0
 

Author Comment

by:Subhachandu
ID: 24855726
Do you want me post the SOAP request which i am passing in
RequestEntity entity = new StringRequestEntity(soapRequest);
                  post.setRequestEntity(entity);
                  
0
 
LVL 23

Accepted Solution

by:
Ajay-Singh earned 500 total points
ID: 24855737
> the exception is org.xml.sax.SAXParseException: Content
is not allowed in prolog.

This means that the XML you are sending to server doesn't
have valid syntax.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 24857190
HttpClient, btw, is not the first choice for a web service client. While it can work as one afaik, you would be better off using something like Axis
0
 

Author Closing Comment

by:Subhachandu
ID: 31603555
This helped to resolve the problem as i missed backslash to one of the tags used in my XML passing using HttpClient.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
use of cookies and regulations 1 53
HashMap Vs TreeMap 12 49
Java JRE greater than 1.6 5 21
Adjust the position 3 13
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now