Automatically pass cookies with every web service call

I have a separate web service client. When calling any of the web methods, the extra cookie string must be implicitly (and not as a parameter of the web method) passed to WS. WS on the other end should be able to get the string and use it. How can this be achieved?

I call the service as follows:

Service srv = Service.create(new URL(WSDL), QNAME);
myClassPort = srv.getPort(MyClass.class);

I need to put the code before the first line so that the client sends this cookie every time I call some remote method via myClassPort. thank.

+3
source share
2 answers

JAX-WS - . , cookie , . JAX-WS cookie, . , JAX-WS cookie , .

, cookie HTTP- -. ; .

:

- JAX-WS (, ), javax.xml.ws.session.maintain. - .

JAX-WS , Common Annotations Java (JSR 250), - . WebServiceContext , .

javax.xml.rpc.server.ServiceLifecycle. JAX-WS Web Service , , @Resource. java.lang.Object, javax.xml.ws.WebServiceContext.

@WebService
public class HelloWorld {
    @Resource
    private WebServiceContext wsContext;
    public void sayHello(){
        MessageContext mc = wsContext.getMessageContext();
        HttpSession session = ((javax.servlet.http.HttpServletRequest)mc.get(MessageContext.SERVLET_REQUEST)).getSession();

     }
}
+6

, . OWASP, , -, .

1) () .

2) cookie .

3) .

4) , , , nonce ( ).

5) () nonce cookie

, - OWASP . , - , , , . Auth0.com - .

0

All Articles