use of org.apache.cxf.helpers.DOMUtils.NullResolver in project cxf by apache.
the class ParseBodyTest method testReadSOAPFault.
@Test
public void testReadSOAPFault() throws Exception {
InputStream inStream = getClass().getResourceAsStream("soap12-fault.xml");
Document doc = StaxUtils.read(inStream);
SoapMessage msg = new SoapMessage(new MessageImpl());
Exchange ex = new ExchangeImpl();
ex.setInMessage(msg);
SOAPMessage saajMsg = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL).createMessage();
SOAPPart part = saajMsg.getSOAPPart();
SAAJStreamWriter writer = new SAAJStreamWriter(part);
StaxUtils.copy(doc, writer);
// Source s = new StaxSource(StaxUtils.createXMLStreamReader(doc));
// part.setContent(s);
saajMsg.saveChanges();
msg.setContent(SOAPMessage.class, saajMsg);
doc = part;
// System.out.println("OUTPUT: " + StaxUtils.toString(doc));
byte[] docbytes = getMessageBytes(doc);
// System.out.println("OUTPUT: " + new String(docbytes));
XMLStreamReader reader = StaxUtils.createXMLStreamReader(new ByteArrayInputStream(docbytes));
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setValidating(false);
dbf.setIgnoringComments(false);
dbf.setIgnoringElementContentWhitespace(true);
dbf.setNamespaceAware(true);
DocumentBuilder db = dbf.newDocumentBuilder();
db.setEntityResolver(new NullResolver());
doc = StaxUtils.read(db, reader, false);
}
Aggregations