I\'m using the Jersey client API to submit SOAP requests to a JAX-WS webservice. By default Jersey is somehow using my Windows Nt credentials for authentication when challen
Adding this answer as I keep finding answers for older versions of Jersey that are no longer relevant in 2.x.
For Jersey 2 there are several ways. Take a look at:
JavaDoc for org.glassfish.jersey.client.authentication.HttpAuthenticationFeature
Here is the one that is working for me (simplest basic auth IMHO).
ClientConfig config = new ClientConfig();
HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic("username", "password");
Client client = ClientBuilder.newClient(config);
client.register(feature);
WebTarget webTarget = client.target("http://api.asite.com/api").path("v1/reports/list");
Invocation.Builder invocationBuilder = webTarget.request(MediaType.TEXT_PLAIN_TYPE);
Response response = invocationBuilder.get();
System.out.println( response.getStatus() );
System.out.println( response.readEntity(String.class) );