I have written a resteasy-spring service :
@Controller
@RequestMapping("/abr/asd")
@Path("/ab/ac")
public class JobSchedulerService {
private static final Logger LOGGER = Logger.getLogger(JobSchedulerService.class);
@GET
@Path("/abc/{param}")
public String scheduleJobs(@PathParam("param") String name) {
return "Success";
}
}
When i try calling this service from Browser, the response is proper :
http://localhost:8080/ControlAppWeb/rest/ab/ac/abc/name
Success
But when i try calling it from a Rest Client API, it returns a web page which is actually the welcome page for the web application where i have incoroporated the rest service :
try {
URL url = new URL("http://localhost:8080/WebApp/rest/ab/ac/abc/name");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Accept", "application/json");
if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) {
throw new RuntimeException("Failed! " + conn.getResponseCode());
}
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String output;
System.out.println("Output from Server is: ");
while ((output = br.readLine()) != null) {
System.out.println(output);
}
conn.disconnect();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
Kindly help, as to where am i going wrong in invoking from Java API
Further: i tries removing the controller and request mapping annotation from the Service, still the browser call worked and java rest client didn't. Weird thing is that even if my modify the url to anything random (in the java client) excluding the intial part (http://localhost:8080/ControlAppWeb), the output remains the same and never is an error thrown...