Here is how to access the headers without reading the entire message using the WebSphere built-in JAX-WS implementation.
public boolean handleMessage(SOAPMessageContext context) {
AttributedURI messageIdURI = (AttributedURI)context.get("com.ibm.wsspi.wsaddressing.inbound.MessageID");
String messageId = "";
if (messageIdURI != null && messageIdURI.getURI() != null) {
messageId = messageIdURI.getURI().toString();
}
EndpointReference fromApplicationEPR = (EndpointReference)context.get("com.ibm.wsspi.wsaddressing.inbound.FromEPR");
String fromApplication = "";
if (fromApplicationEPR != null && fromApplicationEPR.getAddress() != null &&
fromApplicationEPR.getAddress().getURI() != null) {
fromApplication = fromApplicationEPR.getAddress().getURI().toString();
}
...
return true;
}
Note that this differs based on the precise JAX-WS implementation. I'll post how to do this via Apache CXF when I get a chance. Here are the needed imports for the above code:
import com.ibm.ws.wsaddressing.AttributedURI;
import com.ibm.ws.wsaddressing.EndpointReference;