问题描述
我使用Jersey客户端API提交SOAP请求到JAX-WS Web服务。默认情况下泽西以某种方式使用我进行身份验证的Windows NT凭据挑战时。谁能解释新泽西州的地方这是否在code?它能被重写?
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 challenged. Can anyone explain where Jersey does this in the code? And can it be overriden?
我曾尝试使用HTTPBasicAuthFilter并添加作为客户端的过滤器。我也尝试添加我的凭据不过无论是WebResoruce queryParams领域正在回升。
I have tried using HTTPBasicAuthFilter and adding as a filter on the Client. I have also tried adding my credentials to the WebResoruce queryParams field however neither are being picked up.
推荐答案
起初,我得到这个工作作为记录的球衣用户指南中
At first I got this working as documented in the Jersey User guide
Authenticator.setDefault (authinstance);
不过,我不喜欢这个,因为它依赖于设置一个全球性的认证。经过一番研究,我发现,新泽西州有一个 HTTPBasicAuthFilter
这是更容易使用。
Client c = Client.create();
c.addFilter(new HTTPBasicAuthFilter(user, password));
请参阅:
http://jersey.java.net/nonav/apidocs/1.10/jersey/com/sun/jersey/api/client/filter/HTTPBasicAuthFilter.html
http://jersey.java.net/nonav/apidocs/1.10/jersey/com/sun/jersey/api/client/filter/Filterable.html#addFilter(com.sun.jersey.api.client.filter.ClientFilter)
这篇关于Jersey客户端API - 验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!