org.xml.sax.SAXParseException: Content is not allowed in prolog

前端 未结 30 2361
别那么骄傲
别那么骄傲 2020-11-22 02:54

I have a Java based web service client connected to Java web service (implemented on the Axis1 framework).

I am getting following exception in my log file:

30条回答
  •  佛祖请我去吃肉
    2020-11-22 03:39

    Try with BOMInputStream in apache.commons.io:

    public static  T getContent(Class instance, SchemaType schemaType, InputStream stream) throws JAXBException, SAXException, IOException {
    
        JAXBContext context = JAXBContext.newInstance(instance);
        Unmarshaller unmarshaller = context.createUnmarshaller();
        Reader reader = new InputStreamReader(new BOMInputStream(stream), "UTF-8");
    
        JAXBElement entry = unmarshaller.unmarshal(new StreamSource(reader), instance);
    
        return entry.getValue();
    }
    

提交回复
热议问题