• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Invoking webservice- Server returned HTTP response code: 500

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem is not this line:



The problem can be the SOAP action or the message you are sending.

You can try checking the response code before reading the actual connection input stream (connection.getResponseCode()) and if the response code is not 200 (OK) then instead of the input stream read the connection error stream for more details (connection.getErrorStream()).


 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic