Question

This is my code on main:

Endpoint.publish("http://0.0.0.0:8080/ws/WebServices", new WebServicesImpl());

And this is my WebServicesImpl:

@WebService(endpointInterface = "ws.WebServices")
public class WebServicesImpl implements WebServices {

    @Override
    public void recibirTramaPosicionWS(AnObject anobject) {
        AThread ttp  = AThread(anobject);
            ttp.start();
    }
}

The web service works without problems, I can access to it and all fine, but I have a big question: can I get the session of my clients, or requests, or something to use in the WebServicesImpl?? I need to implement security in this web service.

Any idea?

Thanks a lot!

Was it helpful?

Solution

see an example here: How to get session object while working on webservices?

normally this is depending on the container you use, but the @Resource Annotation gives you some default objects like the WebserviceContext

OTHER TIPS

First of all, in regular life we don't publish web services like this approach. Its typically done by different api like apache-cxf, axis etc. You can also use different frameworks to expose web services like spring.

Coming to your problem, this is just a program which is listening on a port for http calls. It should only be used for testing purpose. The "Endpoint" class is a class which ships with jdk bundle. You cannot get session management with this approach. If you want session management, i would suggest to go for real application server and deploy your application on that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top