Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I have problem when I parsing inputstream from http

 
Auttapol Pipatpatama
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Solution
Servlet ===================================================
InputStream xmlStream = req.getInputStream();
APIRCRInterface apicrInterface = new APIRCRInterface();
String xmlRet = apicrInterface.process(xmlStream);

Java App (Use DOM4J)=======================================
in class APIRCRInterface
String xmlIn = getStreamStr(ips);
Document doc = DocumentHelper.parseText(xmlIn);

Method getStreamStr use transform inputstream to string.
When I call DocumentHelper.parseText(xmlIn); I get error
org.dom4j.DocumentException: Error on line -1 of document : Premature end of file. Nested exception: Premature end of file.

I print xmlIn "<?xml version="1.0" encoding="UTF-8"?><request id="0000000001" command="RECONNECT"><msisdn>865634408</msisdn></request>"

How I resolve this problem?
 
Auttapol Pipatpatama
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I test inside app it fine but when I call by request it's not work.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic