如何使用CXF框架使用受HTTP基本身份验证保护的Web服务? [英] How do I consume a web service protected with HTTP basic authentication using the CXF framework?

查看:104
本文介绍了如何使用CXF框架使用受HTTP基本身份验证保护的Web服务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用 CXF让它工作用户指南,但我没有运气。

I tried to get it to work using the CXF User Guide, but I've had no luck.

我正在尝试使用java代码调用Web服务。

I'm trying to call the web service using java code.

推荐答案

这由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.

这篇关于如何使用CXF框架使用受HTTP基本身份验证保护的Web服务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆