我使用apache CXF处理soap消息。我需要处理RequestSecurityTokenResponse以从RequestSecurityToken(request)获取与MessageID相关联的标识符。我已经按如下方式添加了SOAPHandler:
<camel-cxf:cxfEndpoint id="serviceEndpoint"
address="..."
serviceClass="..."
wsdlURL="..."
endpointName="..."
serviceName="..."
xmlns:s="...">
<camel-cxf:properties>
<entry key="ws-security.callback-handler" value-ref="keystorePasswordCallbackHandler" />
<entry key="security.sts.token.do.cancel" value="true" />
</camel-cxf:properties>
<camel-cxf:handlers>
<bean class="ws.MySoapHandler" />
</camel-cxf:handlers>
</camel-cxf:cxfEndpoint>
MySoapHandler记录入站/出站邮件:
public class MySoapHandler implements SOAPHandler<SOAPMessageContext> {
private static final Logger log = LoggerFactory.getLogger(LoggingHandler.class);
@Override
public Set<QName> getHeaders() {
return new HashSet<>();
}
@Override
public boolean handleMessage(SOAPMessageContext context) {
Boolean isOutBound = (Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
try {
if (isOutBound){
log.info("############# Intercepting outbound message #############");
} else {
log.info("############# Intercepting inbound message #############");
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
context.getMessage().writeTo(baos);
log.info(baos.toString());
} catch (SOAPException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return true;
}
@Override
public boolean handleFault(SOAPMessageContext context) {
return false;
}
@Override
public void close(MessageContext context) {
System.out.println("Do some cleanup handling .. ");
}
}
当我查看日志时,我没有看到RequestSecurityTokenResponse消息。 你能告诉我为什么吗?是否可以处理RequestSecurityTokenResponse