我有实现org.springframework.oxm.mimeMimeUnmarshaller
的旧代码:
import javax.xml.bind.attachment.AttachmentUnmarshaller;
import javax.xml.transform.Source;
import org.springframework.oxm.UnmarshallingFailureException;
import org.springframework.oxm.XmlMappingException;
import org.springframework.oxm.mime.MimeContainer;
import org.springframework.oxm.mime.MimeUnmarshaller;
import org.springframework.xml.transform.StaxSource;
public class MISMarshaller implements MimeUnmarshaller {
.
.
.
public Object unmarshal(Source source, MimeContainer mimeContainer) throws XmlMappingException {
AttachmentUnmarshaller au = null;
if (this.mtomEnabled && mimeContainer != null) {
au = new MISMarshaller.MISAttachmentUnmarshaller(mimeContainer);
}
if (source instanceof StaxSource && ((StaxSource)source).getXMLStreamReader() != null) {
try {
return this.context.unmarshal(au, ((StaxSource)source).getXMLStreamReader());
} catch (Exception var5) {
throw new UnmarshallingFailureException(var5.getMessage(), var5);
}
} else {
throw new IllegalStateException(
"Only StAX is supported for MIS marshaller. Use AXIOM message factory.");
}
}
.
.
.
}
我正在将该代码升级到Spring 5,并且类StaxSource
不在Spring 5中。如何将其重写为在Spring 5中工作?
import org.springframework.util.xml.StaxUtils;
.
.
.
return this.context.unmarshal(au, StaxUtils.getXMLStreamReader(source));