this.source = new JAXMStreamSource(is);
} else if (rdr != null) {
this.source = new JAXMStreamSource(rdr);
} else {
log.severe("SAAJ0544.soap.no.valid.reader.for.src");
throw new SOAPExceptionImpl("Source does not have a valid Reader or InputStream");
}
}
else if (FastInfosetReflection.isFastInfosetSource(source)) {
// InputStream is = source.getInputStream()
InputStream is = FastInfosetReflection.FastInfosetSource_getInputStream(source);
/*
* Underlying stream must be ByteInputStream for getContentAsStream(). We pay the
* cost of copying the underlying bytes here to avoid multiple copies every time
* getBytes() is called on a ByteInputStream.
*/
if (!(is instanceof ByteInputStream)) {
ByteOutputStream bout = new ByteOutputStream();
bout.write(is);
// source.setInputStream(new ByteInputStream(...))
FastInfosetReflection.FastInfosetSource_setInputStream(
source, bout.newInputStream());
}
this.source = source;
}
else {
this.source = source;
}
sourceWasSet = true;
}
catch (Exception ex) {
ex.printStackTrace();
log.severe("SAAJ0545.soap.cannot.set.src.for.part");
throw new SOAPExceptionImpl(
"Error setting the source for SOAPPart: " + ex.getMessage());
}
}