Using embedded Jetty with JAX-WS. Is there any way to get the Servlet_Request ?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Using embedded Jetty with JAX-WS. Is there any way to get the Servlet_Request ?

choco vanille

Hello everyone, 

Here is my first post to the Jetty mailing list. I discovered the Jetty world a few weeks ago, and, well: it's great!

I hope you could help me in resolving my issue. 

I have developed a WebService using:

  • JAX-WS 2.2.5
  • Jetty 8.1.2, embedded, no web.xml
  • jetty-http-spi-8.1.0.RC4.jar (for using org.eclipse.jetty.http.spi.JettyHttpServer)

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:

Images intégrées 1