Jersey Client API - authentication

后端 未结 7 2106
不知归路
不知归路 2020-11-30 23:14

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

7条回答
  •  栀梦
    栀梦 (楼主)
    2020-12-01 00:15

    Jersey 2.x:

    HttpAuthenticationFeature feature = HttpAuthenticationFeature.basicBuilder()
        .nonPreemptive()
        .credentials("user", "password")
        .build();
    
    ClientConfig clientConfig = new ClientConfig();
    clientConfig.register(feature) ;
    
    Client client = ClientBuilder.newClient(clientConfig);
    

    Reference: 5.9.1. Http Authentication Support

提交回复
热议问题