cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gabo Manuel (JIRA)" <j...@apache.org>
Subject [jira] Created: (CXF-2045) Custom headers lost when using Cxf Interceptors
Date Tue, 17 Feb 2009 11:29:03 GMT
Custom headers lost when using Cxf Interceptors
-----------------------------------------------

                 Key: CXF-2045
                 URL: https://issues.apache.org/jira/browse/CXF-2045
             Project: CXF
          Issue Type: Bug
          Components: Core, REST
    Affects Versions: 2.2
         Environment: Java 1.5
Jetty 6.1
            Reporter: Gabo Manuel


All changes to the header through the Message object in the out interceptor are not received
by client. 

Server.java

public class RetestRestServer {
    String basepath = "/someValue";
    int port = 8080;

    @SuppressWarnings("unchecked")
    protected RetestRestServer() throws Exception {
        JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
        sf.setResourceClasses(AccountService.class);
        sf.setResourceProvider(AccountService.class, 
            new SingletonResourceProvider(new AccountService()));
        sf.setAddress("http://localhost:"+port+basepath+"/rest/Accounts/");
        
        List<Interceptor> out = new ArrayList<Interceptor>(1);
        in.add(new RestOutHandler());
        sf.setOutInterceptors(in);
        
        sf.create();
    }

    public static void main(String args[]) throws Exception {
        new RetestRestServer();
        System.out.println("Server ready...");
    }
}

RestOutInterceptor.java

public class RestOutHandler extends AbstractPhaseInterceptor<Message>{
	private static Logger logger = Logger.getLogger(RestOutHandler.class);
	public RestOutHandler() {
		super(Phase.POST_PROTOCOL);
	}
	public void handleMessage(Message message) throws Fault {
		Map<String, List<String>> responseHeaders = (Map<String, List<String>>)message.get(Message.PROTOCOL_HEADERS);
		
		if (responseHeaders == null) {
			responseHeaders = new HashMap<String, List<String>>();
			message.put(Message.PROTOCOL_HEADERS, responseHeaders);
		}
		
		responseHeaders.put("header1", Arrays.asList(new String[]{"headerValue"}));
		logger.debug("out message headers: " + responseHeaders);
	}
}

AccountService.java

@Consumes("*/xml")
@Produces("text/xml")
@WebService(serviceName="AccountService", portName="AccountServicePort")
public class AccountService{
    private static Logger logger = Logger.getLogger(AccountService.class);
    @GET
    @Path("/")
    @WebMethod
    public String getAccount(
            @QueryParam("serialNumber")
            @WebParam(name="serialNumber")
            long serialNumber) {
        logger.info("get Account received: " + serialNumber);
        return "get Account received: " + serialNumber;
    }
}

Please advise if more info is needed.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message