public OMElement processDocument(InputStream inputStream,
String contentType,
MessageContext msgContext) throws AxisFault {
QName wrapperQName = BaseConstants.DEFAULT_TEXT_WRAPPER;
if (msgContext.getAxisService() != null) {
Parameter wrapperParam = msgContext.getAxisService().getParameter(BaseConstants.WRAPPER_PARAM);
if (wrapperParam != null) {
wrapperQName = BaseUtils.getQNameFromString(wrapperParam.getValue());
}
}
OMFactory factory = OMAbstractFactory.getOMFactory();
OMElement wrapper = factory.createOMElement(wrapperQName, null);
String charSetEnc = BuilderUtil.getCharSetEncoding(contentType);
String textPayload;
try {
textPayload = IOUtils.toString(inputStream, charSetEnc);
} catch (IOException ex) {
throw new AxisFault("Unable to read message payload", ex);
}
wrapper.addChild(factory.createOMText(textPayload));
return wrapper;
}
|