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

Popular posts from this blog

Task 12 - Create Java Program with MySQL Database Connectivity

Java Interfaces and Exception Handling - Practice Problem with Solution

Task 16 - Javafx Program to Create, Retrieve, Update and Delete records with Database