尽管我设置了username
, password
, action
, and WS Security Password Type (which is PasswordText)
,但当我尝试调用 Web 服务的服务时得到此异常:No security action was defined
. 我尝试与之通信的 Web 服务Basic Authentication
使用PasswordText
WS 安全密码类型。
这是我尝试过的:
Map<String, Object> ctx = ((BindingProvider) basicHttpBindingIDeneme).getRequestContext();
ctx.put("ws-security.username", USERNAME);
ctx.put("ws-security.password", PASSWORD);
Map<String,Object> inProps = new HashMap<String,Object>();
inProps.put(WSHandlerConstants.PASSWORD_TYPE, WSConstants.PW_TEXT);
inProps.put(WSHandlerConstants.ACTION, "UsernameToken");
WSS4JInInterceptor wssIn = new WSS4JInInterceptor(inProps);
org.apache.cxf.endpoint.Client client = ClientProxy.getClient(basicHttpBindingIDeneme);
org.apache.cxf.endpoint.Endpoint cxfEndpoint = client.getEndpoint();
cxfEndpoint.getInInterceptors().add(wssIn);
Map<String,Object> outProps = new HashMap<String,Object>();
// how to configure the properties is outlined below;
WSS4JOutInterceptor wssOut = new WSS4JOutInterceptor(outProps);
cxfEndpoint.getOutInterceptors().add(wssOut);
为了定义安全操作,我还需要配置什么?
ps 使用Apache CXF 3.1.12
可用的最新版本。