 <p>Please get the HTTP status from the response as below.</p> <pre><code>URL url = new URL("http://example.com"); HttpURLConnection connection = (HttpURLConnection)url.openConnection(); connection.setRequestMethod("GET");//Or POST, depending on your service connection.connect(); int code = connection.getResponseCode(); </code></pre> <p>This should return a 401 if your web service is a Restful service.</p>