我不知道该怎么办了.一切似乎都是正确的;输入输出.
回应是:
11:10:34,922 INFO [STDOUT] printing out the input stream <?xml version="1.0" encoding="UTF-8" standalone="yes"?><Response> <Method name="XML/Release/New" time="2013-04-23T15:10:35.1446238Z"> <ResponseStatus>100</ResponseStatus> </Method> </Response> finished printing out the input stream 11:10:34,922 INFO [STDOUT] got the unmarshaller 11:10:34,925 ERROR [PRNDataAccessUtil] Caught an error: javax.xml.bind.UnmarshalException - with linked exception: [org.xml.sax.SAXParseException: Premature end of file.] : null
代码:
try { out = connection.getoutputStream(); ByteArrayOutputStream bos = PRNPostNewsReleaseUtil.createNewsReleaseXml(newsRelease); bos.writeto(out); JAXBContext context = JAXBContext.newInstance(Response.class.getPackage().getName()); in = connection.getInputStream(); BufferedReader inp = new BufferedReader(new InputStreamReader(in)); System.out.println("printing out the input stream"); String line; while((line = inp.readLine()) != null) { System.out.println(line); } System.out.println("finished printing out the input stream"); Unmarshaller unmarshaller = context.createUnmarshaller(); response = (Response) unmarshaller.unmarshal(in); } catch (Exception ex) { log.error("Caught an error: " + ex + " : " + ex.getMessage()); return null; } finally { if (null != in) connection.disconnect(); }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。