掲示板

Different response when calling URL from Java Class and browser

9年前 に Kiran Kumar Boyini によって更新されました。

Different response when calling URL from Java Class and browser

Expert 投稿: 287 参加年月日: 11/06/02 最新の投稿
I am getting some strange problems. I am trying to hit 2 web service URLs or Servlet URLs from the Java class. The URLs are:

1. https://skmtest.ito.unisys.com/SKMWSLib/OpenSession?user=admin&project=Unisys
2. https://skmtest.ito.unisys.com/SKMWSLib/Cases?sessionkey=14950586e51&PAR0=SOLUTION_TYPE&VAL0=FAQ&profile=ADMIN
Here I am hitting the URLs successfully, but the response is different when I hit the same URLs from the browser.
I am executing the urls one by one here,the result is as follows

URL Response (in Java class) Response(in browser)
1 Expected one (correct) Expected one (correct)
2 Different (wrong) Expected one (correct)


Note: I am using Servlet URLs which internally calls web services of type REST.
See the code to invoke the URL every time:

GetMethod url_getMethod = new GetMethod(url);  //1  
HttpClient httpClient = new HttpClient();
int statusCode=httpClient.executeMethod(url_getMethod);  //2
System.out.println("------response------"+url_getMethod.getResponseBodyAsString());


Regards,
Kiran
thumbnail
9年前 に David H Nebinger によって更新されました。

RE: Different response when calling URL from Java Class and browser

Liferay Legend 投稿: 14919 参加年月日: 06/09/02 最新の投稿
It's always possible that the service is using details in the headers (i.e. the browser type) to do things differently.