I have written the following code to Parse SOAP message using STAX. I am getting null pointer exception at xmlStreamReader.hasNext(). Please help.
Source src = soapMsg.getSOAPPart().getContent(); ... HorizonHeaderData header = parser.parseHorizonHeader(src); ... public HorizonHeaderData parseHorizonHeader(Source src) { HorizonHeaderData header = new HorizonHeaderData(); XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance(); if (null != src) { try { XMLStreamReader xmlStreamReader = xmlInputFactory.createXMLStreamReader(src); if(xmlStreamReader==null){ System.out.println("xmlStreamReader is null"); } while(xmlStreamReader.hasNext()){ int event = xmlStreamReader.getEventType(); switch(event){ case XMLStreamConstants.START_ELEMENT: System.out.println("Element: "+ xmlStreamReader.getLocalName() + "\nValue: "+ xmlStreamReader.getElementText()); } xmlStreamReader.next(); The input XML is
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:bpel="http://xmlns.oracle.com/TestLoggingComposite/SSNService/BPELProcess2"> <soapenv:Header> <oas:Security soapenv:mustUnderstand="0" xmlns:oas="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:soap="soap" xmlns:xsi="xsi"> <wsu:SecurityContextToken xmlns:wsu="http://docs.oasis-open.org/ws-sx/ws-secureconversation/200512"> <wsu:Identifier>${=java.util.UUID.randomUUID()}</wsu:Identifier> </wsu:SecurityContextToken> </oas:Security> </soapenv:Header> <soapenv:Body/> </soapenv:Envelope> I am able see the values using DOM but there is exception using STAX. Kindly help.
No comments:
Post a Comment