且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用CXF框架使用受HTTP基本身份验证保护的Web服务?

更新时间:2023-12-01 08:07:52

这由JAX-WS规范涵盖。基本上,在请求上下文中将用户名/密码设置为属性:

This is covered by the JAX-WS Specification. Basically, set the username/password as properties on the request context:

((BindingProvider)proxy).getRequestContext().put(
    BindingProvider.USERNAME_PROPERTY, "joe");
((BindingProvider)proxy).getRequestContext().put(
    BindingProvider.PASSWORD_PROPERTY, "pswd");

运行时将它们放入HTTP标头。

The runtime puts them into the HTTP header.