2013-03-14 116 views
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是空的...

我不知道是怎麼回事錯...

+0

您是否調試過代碼以查看哪行出錯? – 2013-03-14 13:13:47

+0

是的,它創建對象數據時似乎出錯 – Luc 2013-03-14 13:15:50

+0

你可能會發布資源,或者某種方式來訪問它們嗎?你的代碼似乎沒問題,所以它可能是輸入問題。 – 2013-03-14 13:19:03

回答

0

您確定其他XSD文件存在於提及的位置嗎?你是積極的,這個XSD方案實際上是「正確的」(例如,有預期的名稱空間和其他類型)?

+0

是的,多次檢查... – Luc 2013-03-14 13:06:33