BlazeDS 未将 Scala 类转换为 AMF
我是 Scala 和 BlazeDS 的新手。我正在尝试编写一个非常简单的应用程序,其中 flex 会调用一个名为 getBook 的方法,并且 Scala 服务返回一个 Book 对象。不涉及数据库。我所做的就是创建一个新的 Book 实例并将其返回。
我的问题是我没有在 Flex 上获得有效的 Book 对象作为响应。我在这里添加了代码。
Scala Book (scalaDemo.vo.Book.scala)
package scalaDemo.vo
case class Book (id:Long,name:String,authors:String)
Scala Service (scalaDemo.GreetingService.scala)
package scalaDemo
import scalaDemo.vo.Book
class GreetingService {
def sayHello = "Hello, World!"
def getBook (name:String):Book = new Book (10,name,"author")
}
Flex Side Book (vo.Book.as)
package vo
{
[RemoteClass(alias="scalaDemo.vo.Book")]
public class Book
{
public var id:Number;
public var name:String;
public var authors:String;
}
}
GreetingService.as
package services
{
import mx.rpc.AsyncResponder;
import mx.rpc.AsyncToken;
import mx.rpc.remoting.RemoteObject;
public class GreetingService
{
protected var ro : RemoteObject = new RemoteObject ("greetingService");
public function sayHello (responder:AsyncResponder) : void {
var token : AsyncToken = ro.sayHello();
token.addResponder(responder);
}
public function getBook (name:String,responder:AsyncResponder) : void {
var token : AsyncToken = ro.getBook(name);
token.addResponder(responder);
}
}
}
remoting-config.xml
<destination id="greetingService">
<properties>
<source>scalaDemo.GreetingService</source>
<scope>application</scope>
</properties>
</destination>
我已将 scala 类放置在 tomcat/webapps/blazeds 下/WEB-INF/classes (我正在使用 blazeds 交钥匙服务器)
请帮助我。
I'm new to Scala and BlazeDS. I am trying to write a very simple application where flex would call a method called getBook and the Scala service returns a Book object. There's no database involved. All I am doing is that I'm creating a new Instance of Book and returning it.
My problem is that I don't get a valid Book object on Flex as response. I'm including the code here.
Scala Book (scalaDemo.vo.Book.scala)
package scalaDemo.vo
case class Book (id:Long,name:String,authors:String)
Scala Service (scalaDemo.GreetingService.scala)
package scalaDemo
import scalaDemo.vo.Book
class GreetingService {
def sayHello = "Hello, World!"
def getBook (name:String):Book = new Book (10,name,"author")
}
Flex Side Book (vo.Book.as)
package vo
{
[RemoteClass(alias="scalaDemo.vo.Book")]
public class Book
{
public var id:Number;
public var name:String;
public var authors:String;
}
}
GreetingService.as
package services
{
import mx.rpc.AsyncResponder;
import mx.rpc.AsyncToken;
import mx.rpc.remoting.RemoteObject;
public class GreetingService
{
protected var ro : RemoteObject = new RemoteObject ("greetingService");
public function sayHello (responder:AsyncResponder) : void {
var token : AsyncToken = ro.sayHello();
token.addResponder(responder);
}
public function getBook (name:String,responder:AsyncResponder) : void {
var token : AsyncToken = ro.getBook(name);
token.addResponder(responder);
}
}
}
remoting-config.xml
<destination id="greetingService">
<properties>
<source>scalaDemo.GreetingService</source>
<scope>application</scope>
</properties>
</destination>
I have placed the scala classes under tomcat/webapps/blazeds/WEB-INF/classes (I am using blazeds turnkey server)
Please help me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的。这就是我出错的地方。对不起,BlazeDS。我没有责怪你。
这就是我在 Scala 中定义 Book 类的方式(错误的方式)
对于 BlazeDS 序列化的 Scala 对象,我们需要确保两件事。
@BeanProperty
var
下面是
scalaDemo.Book< 的正确定义/code> 我在问题中提到的。
Daniel C.Sorbal 感谢您的关注。现在我的下一个任务是让 Hibernate 与 Scala 对话。
Ok. This is where I went wrong. I'm sorry BlazeDS. I blamed you for nothing.
This was how I defined my Book Class in Scala (the wrong way)
For a Scala object to be serialized by BlazeDS we need to make sure of 2 things.
@BeanProperty
var
Here is the correct definition of
scalaDemo.Book
that I mentioned in my question.Daniel C. Sorbal thank you for you interest. Now my next task would be to get Hibernate talking to Scala.