Rob,

Thanks for your response. I have the feeling some of the restlet functionality is really working for me now. But still some problems remain...

I tried your suggestion and inserted the line like so:
           ...
           Response response = new Client(Protocol.HTTP).get(uri);
           DomRepresentation document = response.getEntityAsDom();

           // Use XPath to find the interesting parts of the data structure
           response.getEntity().write(System.out);
           String expr = "/ResultSet/Result/Title";
           for (Node node : document.getNodes(expr)) {
               System.out.println(node.getTextContent());
           }
           ...

To find that the xml response text has extraneous characters before and after (see below for the run log).

o) What subsystem generates these characters?

o) I find it strange that this apparently affects the value the variable document holds, because the earlier [Fatal Error] message is no longer there. An exception is still thrown at the same line as before though (For (Node node : document.getNodes(expr)) {).

o) I also puzzled by the fact that the uri is reported invalid. Is the yahoo server telling me or is this a restlet request/client message? When I copy/paste the uri in my browser I get more text as a response.

o) If possible, can you send me your eclipse project so I can try to have no problems ;-)

Again, any help is appreciated.

Kind regards,
--Aadjan

Run log (after inserting response.getEntity().write(System.out);):

[Session started at 2007-09-28 17:14:26 +0200.]
Sep 28, 2007 5:14:28 PM com.noelios.restlet.http.StreamClientHelper start
INFO: Starting the HTTP client
151 <?xml version="1.0" encoding="UTF-8"?>
<Error xmlns="urn:yahoo:api">
       The following errors were detected:
<Message>invalid value: uri - http://api.search.yahoo.com/WebSearchService/V1/webSearch?appid=restbook&query=bootsmade</Message>
</Error>
<!-- ws01.search.re2.yahoo.com uncompressed/chunked Fri Sep 28 08:14:32 PDT 2007 -->

0


Exception in thread "main" java.lang.NullPointerException
   at Example2_1b.main(Example2_1b.java:50)
--------------- [end log]
Rob Heittman wrote:
The XML parser in use is complaining about whitespace or characters
appearing before the <?xml version="1.0"?> statement.  I just ran the
example on my OS X 10.4 machine and did not have trouble, though I'm
using Eclipse and not Xcode.

Can you insert something like

  response.getEntity().write(System.out);

to spot anything wrong with the XML you are getting from Yahoo (or
whatever server you are hitting, if you've changed the example to be
a client of something else?)

- Rob


----- Original Message ----- From: "Aadjan van der Helm" <[EMAIL PROTECTED]> To: [email protected] Sent: Thursday, September 27, 2007 4:23:56 PM (GMT-0500) America/New_York Subject: Trying to run book example2_1a Dear list, I'm evaluating the restlet framework to see if we can use it to create clients for our restful image server. It's been a while since I was actively coding in java and it took a while to get an xcode project (I'm on osx 10.4.10) into a shape to get the book examples to compile and run. Now I've worked that out up to a point that eg. example 2_1a compiles but generates a runtime error: [Fatal Error] :1:1: Content is not allowed in prolog. It dies in the loop to iterate over the requested items in the document. // Use XPath to find the interesting parts of the data structure String expr = "/ResultSet/Result/Title"; for (Node node : document.getNodes(expr)) { System.out.println(node.getTextContent()); } Any clues what is going wrong? Thanks in advance, --Aadjan Run log: [Session started at 2007-09-27 22:08:45 +0200.] Sep 27, 2007 10:08:47 PM com.noelios.restlet.http.StreamClientHelper start INFO: Starting the HTTP client [Fatal Error] :1:1: Content is not allowed in prolog. Exception in thread "main" java.lang.NullPointerException at Example2_1a.main(Example2_1a.java:46) java has exited with status 1.

Reply via email to