The Web Service works pretty well using https. I need now to add a client authentifcation. I would like to use HttpSessionScope, however, HttpSessionScope needs to access the servlet request from the WebServiceContext (SERVLET_REQUEST), which is in my case always NULL.
Do you know how to configure an embedded Jetty with HttpSessionScope working ? If not, do you know how to get the servlet request not NULL ?
FYI, I have posted this question to the JAX-WS forum as well with no answer yet (http://www.java.net/forum/topic/glassfish/metro-and-jaxb/using-httpsessionscope-embedded-jetty)
Hope you can help,
Mabda
Here is my (really simple) code:
Server
import ht.controler.server.service.ControlerImpl;
import javax.xml.ws.Endpoint;
import org.eclipse.jetty.http.spi.JettyHttpServer;
import org.eclipse.jetty.server.Connector;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
import org.eclipse.jetty.server.ssl.SslSelectChannelConnector;
import org.eclipse.jetty.util.ssl.SslContextFactory;
(...)
Server server = new Server(8081);
SslContextFactory sslFactory = new SslContextFactory("e:/keystore.jks");
sslFactory.setKeyStorePassword("password");
SslSelectChannelConnector selectChannelConnector = new SslSelectChannelConnector(sslFactory);
selectChannelConnector.setPort(8081);
server.setConnectors(new Connector[] {selectChannelConnector });
JettyHttpServer jettyServer = new JettyHttpServer(server, true);
Endpoint endpoint = Endpoint.create(new ControlerImpl());
ContextHandlerCollection collection = new ContextHandlerCollection();
server.setHandler(collection);
endpoint.publish( jettyServer.createContext("/Service") );
server.start();
WebService Class (I removed the @HttpSessionScope to check that the servlet request was NULL)
@WebService(endpointinterface="service.Controler")
//@HttpSessionScope
public class ControlerImpl implements Controler
{
@Resource private WebServiceContext wsContext;
@WebMethod
public String executeCommand(String name)
{
System.out.println(wsContext.getMessageContext().get(MessageContext.SERVLET_REQUEST)); // NULL
return "Command executed";
}
}
If I use @HttpSessionScope, I get the following exception:
