我已经从saajsoapmessagefactory中提取了附件
@SuppressWarnings("rawtypes")
public class MtomContentRespExtractor implements WebServiceMessageExtractor {
private static final Logger logger = LoggerFactory.getLogger(MtomContentRespExtractor.class);
private JAXBContext jaxbContext = null;
private Class<MyContentResponse> responseType;
public MtomContentRespExtractor(JAXBContext jaxbContext,
Class<MyContentResponse> responseType) {
this.jaxbContext = jaxbContext;
this.responseType = responseType;
}
@Override
public Object extractData(WebServiceMessage webServiceMsg) throws IOException, TransformerException {
JAXBElement<MyContentResponse> jaxbElement = null;
MyContentResponse myContResp = null;
try {
jaxbElement = jaxbContext.createUnmarshaller()
.unmarshal(webServiceMsg.getPayloadSource(), responseType);
Attachment attachment = (Attachment) ((SaajSoapMessage) webServiceMsg).getAttachments().next();
myContResp = (MyContentResponse) jaxbElement.getValue();
attachment.getInputStream()
//Logic for response
} catch (JAXBException e) {
logger.error(e.getMessage());
}
return myContResp;
}