I am using spring-web-4.3.6.RELEASE.jar which contains Spring RestTemplate.java.
I wrote 4 junittest case to call the "https" basic authentication restfull web services. I already dealt with the "https" issue by registering the certificate to the java keystore cacerts file. Now I getting "http 401 Unauthorized" error when I call the restfull web services through java but not through soapUI or postman:
In Junit test case 2("testLocalCreateABCVersion2()"), I used custom ContextAwareHttpComponentsClientHttpRequestFactory.java class. Which I provided at the bottom.
In Junit test case 3("testLocalCreateABCVersion3()"), I used custom BasicAuthRestTemplate.java which I provided below.
In Junit test case 4(testLocalCreateABCVersion4()), I used org.apache.commons.httpclient.HttpClient and set client.getParams().setAuthenticationPreemptive(true) to true. This HttpClients comes from commons-httpClient-3.1.jar and does why the "setAuthenticationPreemptive" exists. In org.apache.httpcomponents.httpClient_4.5.3.jar it doesnt't contain the method setAuthenticationPreemptive.
Any help or hint would be greatly appreciated it!!
Do not threaten THIS beaver! Not even with this tiny ad: