• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Basic Authentication 401 Unauthorized error calling restful web service

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All:

I am using spring-web-4.3.6.RELEASE.jar which contains Spring RestTemplate.java.
I wrote 4 junit test 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!!


   


 
Clowns were never meant to be THAT big! We must destroy it with this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic