Java 如何使用 Axis2 ADB 客户端进行基本身份验证?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1528089/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to do Basic Authentication with an Axis2 ADB Client?
提问by Mike C.
I'm trying to figure out how to do Basic Authentication with an ADB Axis2 version 1.5 Client.
我试图弄清楚如何使用 ADB Axis2 1.5 版客户端进行基本身份验证。
I'm trying the following:
我正在尝试以下操作:
HttpTransportProperties.Authenticator basicAuth = new HttpTransportProperties.Authenticator();
basicAuth.setUsername(username);
basicAuth.setPassword(password);
final Options clientOptions = serviceStub._getServiceClient().getOptions();
clientOptions.setProperty(HTTPConstants.AUTHENTICATE, basicAuth);
However this does not work and the needed line in the message header is not being added.
但是,这不起作用,并且未添加消息标题中所需的行。
采纳答案by Mike C.
Got the answer from the following site:
从以下网站得到答案:
http://www.inpc.de/blog/2007/05/axis2-12-basic-authentication.html
http://www.inpc.de/blog/2007/05/axis2-12-basic-authentication.html
Apparently I was missing:
显然我失踪了:
basicAuth.setPreemptiveAuthentication(true);