You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by billybobbain <bi...@gmail.com> on 2014/12/16 21:23:43 UTC

How to Maintain Session with CXF?

The service I'm using requires that we "login" and maintain the session.
(Yuck, I know!)

I can do this using regular java and CXF, but can't figure out the right way
with Camel & CXF. 

This works with Java / CXF. 

   ((BindingProvider)
port).getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY,
true);

I've tried adding a header: 

    <setHeader headerName="org.apache.cxf.message.Message.MAINTAIN_SESSION">
      <constant>true</constant>
    </setHeader>

and using a processor:

public class SessionProcessor implements Processor {
  @Override
  public void process(Exchange exchange) throws Exception {
    // set up the response context which force start document
    Map<String, Object> map = (Map)
exchange.getOut().getHeader(Client.REQUEST_CONTEXT);
    if (map == null) {
      map = new HashMap<String, Object>();
      exchange.getOut().setHeader(Client.REQUEST_CONTEXT, map);
    }
    map.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
  }

but, I think I'm doing it too late. 



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-Maintain-Session-with-CXF-tp5760786.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: How to Maintain Session with CXF?

Posted by billybobbain <bi...@gmail.com>.
I solved this by grabbing the "Set-Cookie" header coming back from the web
service and then adding it as a "Cookie" header.

    <setHeader headerName="Cookie">
    <simple>${header.Set-Cookie}</simple>
    </setHeader>

Maybe there is a better way to do this, but it works for now. 



--
View this message in context: http://camel.465427.n5.nabble.com/How-to-Maintain-Session-with-CXF-tp5760786p5760840.html
Sent from the Camel - Users mailing list archive at Nabble.com.