|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
Exception using Web Service APIHi,
I'm trying to parse the content retrieved from with Dom4J to no avail. The exception in question is: Content is not allowed in prolog I've checked and it's pobably related to http://en.wikipedia.org/wiki/Byte_Order_Mark and should be solved by changing the encoding to ISO-8859-1 (instead of UTF-8). Can someone take care of this?
Code: public static Document readUrl(URL url) throws DocumentException { SAXReader reader = new SAXReader(); return reader.read(url);
} Junit: @Test public void testReadUrl() throws Exception { String url = "http://nemo.sonarsource.org/api/resources?resource=org.apache.maven:maven&depth=0&metrics=public_documented_api_density,violations,ncloc,tests";
assertNotNull("XML obtained from URL", server.readUrl(new URL(url))); } |
|
|
Re: Exception using Web Service APIHi Jose,
It's a good idea to check the Byte-Order Mark but that's not the problem. Indeed the file starts with 3C 3F 78, but UTF-8 BOM is EF BB BF. The problem may come from the response format. I'm not sure that your unit test parses XML. A XML file is returned when opening the URL from a browser, because the HTTP request header 'Accept' is set to ' text/html,application/xhtml+xml,application/xml'. But if you try the same URL with wget, JSON format is returned.I recommend you to force the XML format. Just add "format=xml" to the URL. Does it resolve your problem ? Simon ---------------------------------------- Simon Brandhof SonarSource.com twitter.com/SonarSource twitter.com/SimonBrandhof ---------------------------------------- On Fri, Nov 13, 2009 at 9:50 AM, Jose Noheda <jose.noheda@...> wrote: Hi, |
|
|
Re: Exception using Web Service APIIt did. Thank you!
Regards
On Fri, Nov 13, 2009 at 10:33 AM, Simon Brandhof <simon.brandhof@...> wrote: Hi Jose, |
| Free embeddable forum powered by Nabble | Forum Help |