Hello Prashanth,
you can try below workaround. We are using the same in our projects.
Create one class for get method and inherit PostMethod in that class.
public class HttpGetWithEntity extends PostMethod {
public HttpGetWithEntity(String uri) {
super(uri);
}
@Override
public String getName() {
return "GET";
}
}
download com.sun.jersey.client.apache.ApacheHttpClientHandler java file and put it in your repository.
modify getHttpMethod as below,
private HttpMethod getHttpMethod(ClientRequest cr) {
final String strMethod = cr.getMethod();
final String uri = cr.getURI().toString();
if (strMethod.equals("GET")) {
return new HttpGetWithEntity(uri);
} else if (strMethod.equals("POST")) {
return new PostMethod(uri);
} else if (strMethod.equals("PUT")) {
return new PutMethod(uri);
} else if (strMethod.equals("DELETE")) {
return new CustomMethod("DELETE", uri);
} else if (strMethod.equals("HEAD")) {
return new HeadMethod(uri);
} else if (strMethod.equals("OPTIONS")) {
return new OptionsMethod(uri);
} else {
return new CustomMethod(strMethod, uri);
}
}
create another class to implement creatClient method,
public class QAFApacheHttpClient extends RestClientFactory {
@Override
protected Client createClient() {
HttpClient httpClient = new HttpClient();
ApacheHttpClientConfig config = new DefaultApacheHttpClientConfig();
ApacheHttpClientHandler clientHandler = new ApacheHttpClientHandler(httpClient, config);
ClientHandler root = new ApacheHttpClient(clientHandler);