我正在尝试使用jax-ws-spring框架发送一个soap请求,但是有一个更改请求以在soap标头中发送凭证。 我试图实现一种在soap标头中设置用户名和密码的方法,但是当我从eclipse的TCP / IP监视器进行监视时,请求中没有显示标头。
@PostConstruct
public void initialize(){
try {
CaseRequestService caseRequestService = new CaseRequestService();
CaseRequestPortType caseRequestPort = caseRequestService.getCaseRequestPort();
BindingProvider bindingProvider = (BindingProvider) caseRequestPort;
Log.info("wsAddress"+wsAddress);
//bindingProvider.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, wsAddress);
Map<String, Object> requestContext = ((BindingProvider)bindingProvider).getRequestContext();
Map<String, String> requestHeaders = new HashMap<String, String>();
requestHeaders.put("username", loadConfig.getSoap_header_uid());
requestHeaders.put("Password", Base64.getDecoder().decode(loadConfig.getSoap_header_pwd().getBytes()).toString());
requestContext.put(MessageContext.HTTP_REQUEST_HEADERS, requestHeaders);
} catch (Exception ex) {
log.error("Error in initializing CaseRequestService: ", ex);
}
}