0
我有一个解组方法:方法跳过return语句
public static Object unmarshalXmlTo0100(String xmlMsg, String destination, String resource) throws Exception {
//init unmarshaller
ByteArrayInputStream input = new ByteArrayInputStream(xmlMsg.getBytes());
JAXBContext context = JAXBContext.newInstance(destination);
Unmarshaller unmarshaller = context.createUnmarshaller();
//init schema
SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema schema = schemaFactory.newSchema(XmlParser.class.getClassLoader().getResource(resource));
unmarshaller.setSchema(schema);
//unmarschal
Object data = unmarshaller.unmarshal(input);
//return message
return data;
}
现在,出于某种原因,当我使用以下方法来调用方法:
processDataObj = MainXMLParser.unmarshalXmlTo0100(processData, "cp.jaxb.planningBericht.classes", "source/xml/cp_md_format_planningBericht.xsd");
一切顺利。
但是,当我使用以下命令:
processDataObj = MainXMLParser.unmarshalXmlTo0100(processData, "cp.jaxb.beschikbaarheidBericht.classes", "source/xml/cp_md_format_beschikbaarheidBericht.xsd");
的解组没有返回值,但它并继续运行,所以proccesDataObj是空的...
我不知道是怎么回事错...
您是否调试过代码以查看哪行出错? – 2013-03-14 13:13:47
是的,它创建对象数据时似乎出错 – Luc 2013-03-14 13:15:50
你可能会发布资源,或者某种方式来访问它们吗?你的代码似乎没问题,所以它可能是输入问题。 – 2013-03-14 13:19:03