if (src instanceof JAXMStreamSource) {
try {
((JAXMStreamSource) src).reset();
} catch (java.io.IOException ioe) {
log.severe("SAAJ0515.source.reset.exception");
throw new SOAPExceptionImpl(ioe);
}
}
try {
saxParser = parserPool.get();
} catch (Exception e) {
log.severe("SAAJ0601.util.newSAXParser.exception");
throw new SOAPExceptionImpl(
"Couldn't get a SAX parser while constructing a envelope",
e);
}
InputSource is = SAXSource.sourceToInputSource(src);
if (is.getEncoding()== null && soapPart.getSourceCharsetEncoding() != null) {
is.setEncoding(soapPart.getSourceCharsetEncoding());
}
XMLReader rejectFilter;
try {
rejectFilter = new RejectDoctypeSaxFilter(saxParser);
} catch (Exception ex) {
log.severe("SAAJ0510.soap.cannot.create.envelope");
throw new SOAPExceptionImpl(
"Unable to create envelope from given source: ",
ex);
}
src = new SAXSource(rejectFilter, is);
}
try {
Transformer transformer =
EfficientStreamingTransformer.newTransformer();
DOMResult result = new DOMResult(soapPart);
transformer.transform(src, result);
Envelope env = (Envelope) soapPart.getEnvelope();
if (saxParser != null) {
parserPool.put(saxParser);
}
return env;
} catch (Exception ex) {
if (ex instanceof SOAPVersionMismatchException) {
throw (SOAPVersionMismatchException) ex;
}
log.severe("SAAJ0511.soap.cannot.create.envelope");
throw new SOAPExceptionImpl(
"Unable to create envelope from given source: ",
ex);
}
}