Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

HTTP header

  Asked By: Rufus    Date: Jun 14    Category: Java    Views: 1198
  

Is there any way to utilize HTTP headers when using JAX-WS?

Share: 

 

4 Answers Found

 
Answer #1    Answered By: Huette Miller     Answered On: Jun 14

I don't know why most of Iranian IT professionals insists to solve their problems with the most abnormal way that ever exists ;)
If you are making your webservice secure, there is a perfect technology called WSIT for JAX-WS, and you can send any kind of token, secure or not secure, encrypted, signed or not signed, embedded with your webservice.
java.sun.com/.../index.html

If WSIT is not the solution, please explain the problem and the reason you're gonna do that.

 
Answer #2    Answered By: Maria Miller     Answered On: Jun 14

I forgot to let you know that it is possible to have access to http  request and response using webservice context. Following exmaple show you how to access the client IP address.


package yourpackage;

import javax.annotation.Resource;
import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.ejb.Stateless;
import javax.servlet.http.HttpServletRequest;
import javax.xml.ws.WebServiceContext;
import javax.xml.ws.handler.MessageContext;


@WebService()
@Stateless()
public class YourWebService {

@Resource
private WebServiceContext wsContext;

/**
* Web service operation
*/
@WebMethod(operationName = "retrieveClientIPAddress")
public String retrieveClientIPAddress() {
HttpServletRequest req = (HttpServletRequest) wsContext.getMessageContext().get(MessageContext.SERVLET_REQUEST);
return req.getRemoteAddr();
}
}

see https://jax-ws.dev.java.net/nonav/2.1.1/docs/api/javax/xml/ws/handler/MessageContext.html
to know other webservice context features.

 
Answer #3    Answered By: Elias Turner     Answered On: Jun 14

you can use "javax.servlet.http.HttpServletResponse" class to setHeader and add hedear Data to http  Header in your servlet and use it in your WS.

 
Answer #4    Answered By: Abrianna Rossi     Answered On: Jun 14

but I use DII(Dynamic Invocation Interface) method to call web-service, and want to add headers to HTTP request and use them in web Filters not in web-service or SOAPHandler.

 
Didn't find what you were looking for? Find more on HTTP header Or get search suggestion and latest updates.




Tagged: