편안한 서비스가받는 모든 요청에 헤더를 추가하려고합니다. 아래의 인바운드 http 인터셉터가 호출되지만 헤더를 추가하지는 않습니다.http 요청 요격기 - cxf를 사용하는 안정적인 웹 서비스
package com.client.interceptors;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import org.apache.cxf.interceptor.Fault;
import org.apache.cxf.message.Message;
import org.apache.cxf.phase.AbstractPhaseInterceptor;
import org.apache.cxf.phase.Phase;
public class ClientInterceptor extends AbstractPhaseInterceptor<Message> {
public ClientInterceptor() {
super(Phase.PRE_INVOKE); // Put this interceptor in this phase
System.out.println("inside constructor");
}
public void handleMessage(Message msg) throws Fault {
// process the message
System.out.println("inside interceptor");
Map<String, List> headers = (Map<String, List>) msg
.get(Message.PROTOCOL_HEADERS);
headers.put("token",
Collections.singletonList("abcd1234xyz56sa"));
msg.put(Message.PROTOCOL_HEADERS, headers);
}
}
어떻게 달성 할 수 있습니까?
하지만 편안하게 웹 서비스를 사용하고 있습니까? – Krishna
예, 간단한 GET 서비스이고 브라우저에서 호출하면 – skonka
브라우저에서 똑바로 가려는 경우 U 동일한 포스터로 도구를 사용할 수 있습니다. – Krishna