我想在CXF响应中添加客户标题。
实际上,在服务器上,我使用OutInterceptor来查看标头。
public RLECompressionOutInterceptor() {
super(Phase.PRE_LOGICAL);
}
@Override
public void handleMessage(SoapMessage paramT) throws Fault {
// TODO Auto-generated method stub
List<Header> head = new ArrayList<Header>();
head.addAll(paramT.getHeaders());
for (Iterator<Header> i = head.iterator(); i.hasNext();) {
Header h = i.next();
Element n = (Element) h.getObject();
if (n.getLocalName().equals("transactionID")) {
String transactionID = n.getTextContent();
//transactionID is information of a "transactionID" header
}
}
}
但是,在Client,InInterceptor中,响应中的标头为NULL。
public CompressingInInterceptor() {
super(Phase.PRE_LOGICAL);
}
@Override
public void handleMessage(SoapMessage arg0) throws Fault {
List<Header> head = new ArrayList<Header>();
head.addAll(arg0.getHeaders());
for (Iterator<Header> i = head.iterator(); i.hasNext();) {
Header h = i.next();
Element n = (Element) h.getObject();
if (n.getLocalName().equals("transactionID")) {
transactionID = n.getTextContent();
System.out.println("ID: "+transactionID);
}
}
}
我不知道为什么在这种情况下标头为空?请问如何解决?