Hello guys,

I have created a small web service in Lift. It has two services: One  
reads a row from a table in a database and the other writes one. To  
test the API I am writing a small client application in scala to read  
and write from the Lift API.
Since I am new to scala and lift, I am thinking the code in Java and  
writing in scala, and of course I am having some problems because of  
that.

When I read from the Lift service, the service answers correctly, but  
my client method reads one line and ends the loop. I believe that the  
syntax of my "for comprehension" is not correct. This is my reader code:

import java.net._
import java.io._

     def read {

         val url = new URL("http://localhost:8080/api/getPerson/myrow";)

         var connection = url.openConnection
         connection.setDoOutput(true);

         var in = new BufferedReader(new InputStreamReader 
(connection.getInputStream()));

         var incomingMsg = ""

         **************Loop with the problem***********
         for (decodedString <- in.readLine) {
           incomingMsg = incomingMsg + decodedString
         }

         in.close();

         println(incomingMsg)
     }

My second problem is when i try to send a message to the API i receive  
the following java error:

java.io.FileNotFoundException: http://localhost:8080/api/getPerson

The error happens when the method tries to read the answers from the  
API. This is the code:

     def send {
         val message =
         <root>
             <action></action>
             <person>
                 <userName>Jose</userName>
                 <firstName>Jose</firstName>
                 <lastName>Perez</lastName>
                 <password>aaaaa</password>
                 <email>a...@aaaa.com</email>
                 <createdon>10/12/2009</createdon>
                 <createdby>Jose</createdby>
                 <updatedon>10/12/2009</updatedon>
                 <updatedby>Jose</updatedby>
             </person>
         </root>

         val url = new URL("http://localhost:8080/api/getPerson";)

         var connection = url.openConnection
         connection.setDoOutput(true);

         var outgoingMsg = message.toString

         var out = new OutputStreamWriter(connection.getOutputStream());
         out.write("string=" + outgoingMsg);
         out.close();

        *******The error happens in the next line**********
         var in = new BufferedReader(new InputStreamReader 
(connection.getInputStream()));

         //        var decodedString = ""

         for (decodedString <- in.readLine)
         println(decodedString)
         in.close();
     }

Any ideas? and, by the way, are there scala packages to replace  
java.net and java.io?

Thanks in advance,

GA


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to