[Lift] Re: Sending a XML message to a Lift server
Hello Jon, your code is giving me two errors in the last two lines. (fragment of Main.scala):52: error: ambiguous reference to overloaded definition, both method fromInputStream in object Source of type (java.io.InputStream)scala.io.Source and method fromInputStream in object Source of type (java.io.InputStream,String)scala.io.Source match expected type ? scala.io.Source.fromInputStream ^ (fragment of Main.scala):53: error: value getLines is not a member of java.io.InputStream (conn.getInputStream).getLines.mkString ^ two errors found !!! discarding script preamble !!! discarding script preamble Any suggestions? Thanks, GA On Oct 14, 2009, at 8:35 PM, jon wrote: oh, if you want to parse directly into xml replace Source.fromInputStream(conn.getInputStream).getLines.mkString with XML.load(conn.getInputStream) On Oct 14, 2:32 pm, jon jonhoff...@gmail.com wrote: this should work: def post(url:URL, toPost:String):String = url.openConnection match { case conn: HttpURLConnection = { conn.setRequestMethod(POST) conn.setDoOutput(true) conn.connect conn.getOutputStream.write(toPost.getBytes()) scala.io.Source.fromInputStream (conn.getInputStream).getLines.mkString } } On Oct 14, 2:22 pm, GA my_li...@me.com wrote: 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 userNameJose/userName firstNameJose/firstName lastNamePerez/lastName passworda/password emaila...@.com/email createdon10/12/2009/createdon createdbyJose/createdby updatedon10/12/2009/updatedon updatedbyJose/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 -~--~~~~--~~--~--~---
[Lift] Re: Sending a XML message to a Lift server
Guys, Dont use scala.io.Source its very broken under the hood in current versions of Scala (according to paulp). Its already fixed in the trunk of 2.8 however (again, according to paulp). Cheers, Tim On 15 Oct 2009, at 11:09, GA wrote: Hello Jon, your code is giving me two errors in the last two lines. (fragment of Main.scala):52: error: ambiguous reference to overloaded definition, both method fromInputStream in object Source of type (java.io.InputStream)scala.io.Source and method fromInputStream in object Source of type (java.io.InputStream,String)scala.io.Source match expected type ? scala.io.Source.fromInputStream ^ (fragment of Main.scala):53: error: value getLines is not a member of java.io.InputStream (conn.getInputStream).getLines.mkString ^ two errors found !!! discarding script preamble !!! discarding script preamble Any suggestions? Thanks, GA On Oct 14, 2009, at 8:35 PM, jon wrote: oh, if you want to parse directly into xml replace Source.fromInputStream(conn.getInputStream).getLines.mkString with XML.load(conn.getInputStream) On Oct 14, 2:32 pm, jon jonhoff...@gmail.com wrote: this should work: def post(url:URL, toPost:String):String = url.openConnection match { case conn: HttpURLConnection = { conn.setRequestMethod(POST) conn.setDoOutput(true) conn.connect conn.getOutputStream.write(toPost.getBytes()) scala.io.Source.fromInputStream (conn.getInputStream).getLines.mkString } } On Oct 14, 2:22 pm, GA my_li...@me.com wrote: 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 userNameJose/userName firstNameJose/firstName lastNamePerez/lastName passworda/password emaila...@.com/email createdon10/12/2009/createdon createdbyJose/createdby updatedon10/12/2009/updatedon updatedbyJose/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 -~--~~~~--~~--~--~---
[Lift] Re: Sending a XML message to a Lift server
Both errors are because you broke up the line before the parenthesis. - GAmy_li...@me.com wrote: Hello Jon, your code is giving me two errors in the last two lines. (fragment of Main.scala):52: error: ambiguous reference to overloaded definition, both method fromInputStream in object Source of type (java.io.InputStream)scala.io.Source and method fromInputStream in object Source of type (java.io.InputStream,String)scala.io.Source match expected type ? scala.io.Source.fromInputStream ^ (fragment of Main.scala):53: error: value getLines is not a member of java.io.InputStream (conn.getInputStream).getLines.mkString ^ two errors found !!! discarding script preamble !!! discarding script preamble Any suggestions? Thanks, GA On Oct 14, 2009, at 8:35 PM, jon wrote: oh, if you want to parse directly into xml replace Source.fromInputStream(conn.getInputStream).getLines.mkString with XML.load(conn.getInputStream) On Oct 14, 2:32 pm, jon jonhoff...@gmail.com wrote: this should work: def post(url:URL, toPost:String):String = url.openConnection match { case conn: HttpURLConnection = { conn.setRequestMethod(POST) conn.setDoOutput(true) conn.connect conn.getOutputStream.write(toPost.getBytes()) scala.io.Source.fromInputStream (conn.getInputStream).getLines.mkString } } On Oct 14, 2:22 pm, GA my_li...@me.com wrote: 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 userNameJose/userName firstNameJose/firstName lastNamePerez/lastName passworda/password emaila...@.com/email createdon10/12/2009/createdon createdbyJose/createdby updatedon10/12/2009/updatedon updatedbyJose/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 -~--~~~~--~~--~--~---
[Lift] Re: Sending a XML message to a Lift server
this should work: def post(url:URL, toPost:String):String = url.openConnection match { case conn: HttpURLConnection = { conn.setRequestMethod(POST) conn.setDoOutput(true) conn.connect conn.getOutputStream.write(toPost.getBytes()) scala.io.Source.fromInputStream (conn.getInputStream).getLines.mkString } } On Oct 14, 2:22 pm, GA my_li...@me.com wrote: 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 userNameJose/userName firstNameJose/firstName lastNamePerez/lastName passworda/password emaila...@.com/email createdon10/12/2009/createdon createdbyJose/createdby updatedon10/12/2009/updatedon updatedbyJose/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 -~--~~~~--~~--~--~---
[Lift] Re: Sending a XML message to a Lift server
oh, if you want to parse directly into xml replace Source.fromInputStream(conn.getInputStream).getLines.mkString with XML.load(conn.getInputStream) On Oct 14, 2:32 pm, jon jonhoff...@gmail.com wrote: this should work: def post(url:URL, toPost:String):String = url.openConnection match { case conn: HttpURLConnection = { conn.setRequestMethod(POST) conn.setDoOutput(true) conn.connect conn.getOutputStream.write(toPost.getBytes()) scala.io.Source.fromInputStream (conn.getInputStream).getLines.mkString } } On Oct 14, 2:22 pm, GA my_li...@me.com wrote: 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 userNameJose/userName firstNameJose/firstName lastNamePerez/lastName passworda/password emaila...@.com/email createdon10/12/2009/createdon createdbyJose/createdby updatedon10/12/2009/updatedon updatedbyJose/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 -~--~~~~--~~--~--~---
[Lift] Re: Sending a XML message to a Lift server
Checkout this: http://databinder.net/dispatch/About Easily the most rocking HTTP library in scala-land. Cheers, Tim On 14 Oct 2009, at 19:35, jon wrote: oh, if you want to parse directly into xml replace Source.fromInputStream(conn.getInputStream).getLines.mkString with XML.load(conn.getInputStream) On Oct 14, 2:32 pm, jon jonhoff...@gmail.com wrote: this should work: def post(url:URL, toPost:String):String = url.openConnection match { case conn: HttpURLConnection = { conn.setRequestMethod(POST) conn.setDoOutput(true) conn.connect conn.getOutputStream.write(toPost.getBytes()) scala.io.Source.fromInputStream (conn.getInputStream).getLines.mkString } } On Oct 14, 2:22 pm, GA my_li...@me.com wrote: 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 userNameJose/userName firstNameJose/firstName lastNamePerez/lastName passworda/password emaila...@.com/email createdon10/12/2009/createdon createdbyJose/createdby updatedon10/12/2009/updatedon updatedbyJose/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 -~--~~~~--~~--~--~---
[Lift] Re: Sending a XML message to a Lift server
On Wed, Oct 14, 2009 at 4:55 PM, Timothy Perrett timo...@getintheloop.euwrote: Checkout this: http://databinder.net/dispatch/About Easily the most rocking HTTP library in scala-land. Just about everything N8han touches rocks... wish I could get him to touch Lift. Cheers, Tim On 14 Oct 2009, at 19:35, jon wrote: oh, if you want to parse directly into xml replace Source.fromInputStream(conn.getInputStream).getLines.mkString with XML.load(conn.getInputStream) On Oct 14, 2:32 pm, jon jonhoff...@gmail.com wrote: this should work: def post(url:URL, toPost:String):String = url.openConnection match { case conn: HttpURLConnection = { conn.setRequestMethod(POST) conn.setDoOutput(true) conn.connect conn.getOutputStream.write(toPost.getBytes()) scala.io.Source.fromInputStream (conn.getInputStream).getLines.mkString } } On Oct 14, 2:22 pm, GA my_li...@me.com wrote: 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 userNameJose/userName firstNameJose/firstName lastNamePerez/lastName passworda/password emaila...@.com/email createdon10/12/2009/createdon createdbyJose/createdby updatedon10/12/2009/updatedon updatedbyJose/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 -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Surf the harmonics --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---