getting Status500 when i call HttpClient.executeMethod(Post)

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

SubhachanduAsked:
Who is Participating?
 
Ajay-SinghCommented:
> 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
 
Ajay-SinghCommented:
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
 
objectsCommented:
check the server logs, 500 indicates an error on the sertver
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
SubhachanduAuthor Commented:
Yes, I know i passed in valid credentials, but any idea why Status 500 is getting for executeMethod()??
0
 
SubhachanduAuthor Commented:
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
 
objectsCommented:
sounds like a problem reading xml
0
 
SubhachanduAuthor Commented:
does that mean my client is able to communicate the webservice and trying it read its xml??
0
 
objectsCommented:
no way to tell whats happening from what you have posted
0
 
SubhachanduAuthor Commented:
Do you want me post the SOAP request which i am passing in
RequestEntity entity = new StringRequestEntity(soapRequest);
                  post.setRequestEntity(entity);
                  
0
 
CEHJCommented:
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
 
SubhachanduAuthor Commented:
This helped to resolve the problem as i missed backslash to one of the tags used in my XML passing using HttpClient.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.