How to Extract SOAP Header Information from a SOAP Message in JAX-WS class

Lets assume, you have username and password in your Inbound SOAP Message header. Here is how you can get these headers:

    String userName, password; 

for (Iterator it = soapMessageContext.getMessage().getSOAPHeader().examineAllHeaderElements(); it.hasNext(); ) {

SOAPHeaderElement e = (SOAPHeaderElement);
String eName = e.getElementName().getLocalName();

if (eName.equals("username")) {
userName = e.getValue();
} else if (eName.equals("password")) {
password = e.getValue();


  1. Hello,
    I got into this link thro

    This solved my problem today. Thank you so much !

    - A new-bie in using JAX-WS :-)


Post a Comment