aspose file tools
The moose likes Web Services and the fly likes Invoking webservice- Server returned HTTP response code: 500 Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Web Services
Reply Bookmark "Invoking webservice- Server returned HTTP response code: 500" Watch "Invoking webservice- Server returned HTTP response code: 500" New topic
Author

Invoking webservice- Server returned HTTP response code: 500

purnima Nair
Greenhorn

Joined: Oct 23, 2008
Posts: 8
I am trying to invoke webservice from jsp.
URL url = new URL(SOAPUrl);
URLConnection connection = url.openConnection();
HttpURLConnection httpConn = (HttpURLConnection) connection;

byte[] b = reqXml.getBytes();

httpConn.setRequestProperty( "Content-Length",
String.valueOf( b.length ) );
httpConn.setRequestProperty("Content-Type","text/xml; charset=utf-8");
httpConn.setRequestProperty("SOAPAction",SOAPAction);
httpConn.setRequestMethod( "POST" );
httpConn.setDoOutput(true);
httpConn.setDoInput(true);

OutputStream out2 = httpConn.getOutputStream();
out2.write( b );

out2.close();

// Read the response and write it to standard out.
InputStreamReader isr =new InputStreamReader(httpConn.getInputStream());

When it reaches the above line httpConn.getInputStream() it throws the error
java.io.IOException: Server returned HTTP response code: 500 for URL:
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1313)

Due to this,response is not generated and webservice methods are not called.What could be wrong?Please help.

Regards,
Purnima Nair
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12271
    
    1
Problem may be this line



You should never close a connection until you have also handled the matching input stream. You can flush() to ensure the entire request is sent.

The close will close both sides of the connection.

Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Invoking webservice- Server returned HTTP response code: 500
 
Similar Threads
Web service using HttpURLConnection
ASP.net web service + java Client
Problems connecting to LDAP from Weblogic Server: BAD_CERTIFICATE error!
Calling a web service using https post
Servlet design - static methods