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) it.next();
String eName = e.getElementName().getLocalName();

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

Comments

  1. Hello,
    I got into this link thro http://stackoverflow.com/questions/9074360/how-to-extract-soap-header-information-from-a-jax-ws-class.

    This solved my problem today. Thank you so much !

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

    ReplyDelete

Post a Comment