1 Reply Latest reply on Dec 28, 2011 9:28 AM by spyhunter99

    Getting Soap Header from WebServiceContext's MessageContext

    Dhanush Gopinath Newbie

      Hi,

      I want to access some SOAP Header values inside the WebService when it is called.

      (I know I can use server side handlers fro this, but I do not want to use it as I want the header values for some application inside the web service)

      So I use the injection using WebServiceContext, and then get the SOAPMessageCotnext by

      SOAPMessageContext soapMsgContext = (SOAPMessageContext) context.getMessageContext();


      And then I get the SoapMessage and Soap Header
      SOAPEnvelope envelope = soapMessageContext.getMessage().getSOAPPart()
       .getEnvelope();
      
       SOAPHeader soapHeader = envelope.getHeader();
       // Extract All header elements.
       Iterator headerElements = soapHeader.extractAllHeaderElements();


      The Iterator headerElements, doesnt have any values in it.

      Why is this happening? Doesn't the WebServiceContext return the SoapHeaders.

      I checked the rest of the SOAP Message and Soap Body is having only the body elements, it doesn't have any values.

      Please let me know in case anyone of u faced the same problems

      Thanks
      Dhanush