Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how can I get the status of webservice

 
mou haj
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am writing a utility for our project where I provide a page where the status of all the resources used in the application and the webseri
vices the application access are provided.

For Datasources I am running a dummy querry to test the status.

For webserivices I am trying to conenct to the webservce URL and if I get a response code of 200 I am saying status is OK.

--------------------------------------------------------------------
final URL url = new java.net.URL( endPointURL );
final URLConnection uconn = url.openConnection( );
final java.net.HttpURLConnection conn = (java.net.HttpURLConnection)uconn;
conn.connect( );
responseCode = conn.getResponseCode( );
--------------------------------------------------------------------

Can you suggest of any other test that I can do. These are external webserivices that my application calls.

Regards
Mou
 
mou haj
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One more thing is when I call these webservices from browser ie type the webservice URL in browser I get a response

Hi there, this is a Web service!

Is there any way of getting this test back in my java program?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13071
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any way of getting this test back in my java program?


Sure - look into use of java.net.HttpURLConnection.

Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic