CXF的header处理了半天。。。
添加拦截器
public class HotelHeaderInterceptor extends AbstractSoapInterceptor {
public void handleMessage(SoapMessage message) throws Fault {
List<Header> headers = message.getHeaders();
AuthenticationHeader aheader = new AuthenticationHeader();
aheader.setCulture(com.tourico.schemas.webservices.authentication.Culture.EN_US);
aheader.setLoginName(username);
aheader.setPassword(password);
aheader.setVersion(new JAXBElement<String>(new QName("", "version"), String.class, version));
JAXBElement<AuthenticationHeader> authHeaders = new ObjectFactory().createAuthenticationHeader(aheader);
Header header;
try {
header = new Header(authHeaders.getName(), aheader,new JAXBDataBinding(AuthenticationHeader.class));
headers.add(header);
message.put(Header.HEADER_LIST, headers);
} catch (JAXBException e) {
e.printStackTrace();
}
}
调用服务之前处理
IDestinationContracts port = service.getIISDestinationHosting() ;
Client cxfClient = ClientProxy.getClient(port);
cxfClient.getOutInterceptors().add(new HeaderInterceptor(Phase.WRITE));
「真诚赞赏,手留余香」
标签
aframe
andrew-ng
arduino
blockchain
cgi
consul
docker
eth
ethereum
evm
feign
flask
golang
hw
java
javascript
jpa
js
k8s
kubernetes
linux
mac
machine-learning
math
mysql
nginx
op
opentcv
ops
poco
pptp
python
rd
spring
springboot
ssl
thymeleaf
type
vagrant
vpn
vue
webrtc
workflow
技术文章
新浪博客
无聊
生活
生活记录
股票
运维