The easiest way is to move your interceptor a bit later in the chain (at least
after the ReadHeadersInterceptor in the READ phase, but any later phase would
do as well) and do:
public void handleMessage(SoapMessage message) throws Fault {
Header header = message.getHeader(new QName("http://soap.ws.xxx.com/",
"AuthHeader"));
The header.getObject() call will likely return a DOM Element. (You can
register a header processor with the bus which could make it return a concrete
object if you want.)
Dan
On Thu November 12 2009 12:52:45 am Pydipati, Karuna wrote:
> Hi
>
> I have hard time extracting the following information from request XML.
> How do get hold of <soap:AuthHeader> piece and access
> ClientApplicationId and Password into Interceptor java program?
>
> <soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:soap="http://soap.ws.xxx.com/">
> <soapenv:Header>
> <soap:AuthHeader>
> <ClientApplicationId>abcd</ClientApplicationId>
> <Password>xxxx</Password>
> </soap:AuthHeader>
> </soapenv:Header>
> <soapenv:Body>
> <soap:patientMatchesByMRNRqst>
> <MRN>1234</MRN>
> </soap:patientMatchesByMRNRqst>
> </soapenv:Body>
> </soapenv:Envelope>
>
> I tried to write something like this. I am able to create
> DepthXMLStreamReader from SoapMessage. Then, I am struck. I am fine if I
> am able to get hold of XML Document in the form of org.w3c.dom.Document.
> I can navigate through that Document. Any clues or help is appreciated.
>
>
> My Interceptor class:
> ================
> public class SoapHeaderInInterceptor extends AbstractSoapInterceptor {
>
> private static Logger LOG = Logger.getLogger(PosidexServiceImpl.class);
>
> public SoapHeaderInInterceptor() {
> super(Phase.PRE_PROTOCOL);
> //getAfter().add(ReadHeadersInterceptor.class.getName());
>
> }
>
> public void handleMessage(SoapMessage message) throws Fault {
> DepthXMLStreamReader xmlReader = getXMLStreamReader(message);
> try{
> StaxUtils.toNextElement(xmlReader);
> System.out.println("Here's the xml:\n\n" +
> xmlReader.getName());
> } catch (Exception e) {
> throw new Fault(e);
> }
> }
>
> protected DepthXMLStreamReader getXMLStreamReader(Message message) {
> XMLStreamReader xr = message.getContent(XMLStreamReader.class);
> if (xr instanceof DepthXMLStreamReader) {
> return (DepthXMLStreamReader) xr;
> }
> DepthXMLStreamReader dr = new DepthXMLStreamReader(xr);
> message.setContent(XMLStreamReader.class, dr);
> return dr;
> }
>
> }
>
>
> Regards
>
> Karuna Pydipati
>
> StubHub/eBay - Platform & Services
>
> Phone: (415)222-8752
>
> Email: [email protected] <mailto:[email protected]>
>
--
Daniel Kulp
[email protected]
http://www.dankulp.com/blog