在 CXF 的 HTTP conduit 中设置代理账号
在 SOAP 客户端所用的 conduit 上配置 CXF 的 ProxyServer 策略与 proxyAuthorization 账号。
CXF 的 SOAP 客户端可以把代理配置放在 HTTP conduit 上。客户端策略负责选择端点,proxyAuthorization 则提供中间代理的账号:
<http-conf:conduit name="{urn:reports}ReportsPort.http-conduit">
<http-conf:proxyAuthorization>
<sec:UserName>PROXY_USER</sec:UserName>
<sec:Password>PROXY_PASSWORD</sec:Password>
<sec:AuthorizationType>Basic</sec:AuthorizationType>
</http-conf:proxyAuthorization>
<http-conf:client ProxyServer="proxy.example" ProxyServerPort="8080" />
</http-conf:conduit>
这段片段假定现有 CXF 配置已经声明了 HTTP-conduit 与安全命名空间。请把示例中的端口 QName 换成正在配置的客户端端口;把正确的配置块挂在别的 conduit 上,不会影响这次调用。
主机和数字端口描述的是正向代理。proxyAuthorization 块是 schema 中专用的代理账号设置。CXF 另有一个用于目标端凭据的 authorization 元素。代理账号与目标账号始终相互独立。
所示的 Basic 类型必须与代理接受的方案一致,并且所选的 CXF 传输要能使用该方案。匹配的 conduit 载入后,经由它发出的操作就会获得这份客户端策略和账号配置。