wideman1926
asked on
Custom Serialization Issue
My remote method returns a java class and I'm trying to map that my flex class. The remote method isn't throwing an exception. That works fine, but on the flex end I get error message of: "faultCode:Server.Acknowle dge.Failed faultString:'Didn't receive an acknowledge message' faultDetail:'Was expecting mx.messaging.messages.Ackn owledgeMes sage, but received null'".
I made sure the classes on both ends are Externalizable. i mapped the flex class to the java class. Both sides read and write the correct data type. My swf does reference the class, so flex should be able to find it. i can't figure out why I'm getting the error message.
///////////Flex Class//////
package MyData
{
import flash.utils.IDataInput;
import flash.utils.IDataOutput;
import flash.utils.IExternalizabl e;
//[Bindable]
[RemoteClass(alias="com.ne tcsd.flex. datamodel. ChatRoomDa ta")]
public class ChatRoom implements IExternalizable
{
public var chatRoomId:String;
public var chatRoomName:String;
public function ChatRoom()
{
chatRoomId = "";
chatRoomName = "";
}
public function readExternal(input:IDataIn put):void{
chatRoomId = input.readUTF();
chatRoomName = input.readUTF();
}
public function writeExternal(output:IData Output):vo id{
output.writeUTF(chatRoomId );
output.writeUTF(chatRoomNa me);
}
}
}
////////////////Java Class///////////
package com.netcsd.flex.datamodel;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
public class ChatRoomData implements Externalizable {
private String chatRoomId;
private String chatRoomName;
public ChatRoomData(){
chatRoomId ="";
chatRoomName = "";
}
public String getChatRoomId(){
return chatRoomId;
}
public String getChatRoomName(){
return chatRoomName;
}
public void setChatRoomId(String id){
chatRoomId = id;
}
public void setChatRoomName(String name){
chatRoomName = name;
}
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
// Read in the server properties from the client representation.
chatRoomId = in.readUTF();
chatRoomName = in.readUTF();
}
public void writeExternal(ObjectOutput out) throws IOException{
out.writeUTF(chatRoomId);
out.writeUTF(chatRoomName) ;
}
}
I made sure the classes on both ends are Externalizable. i mapped the flex class to the java class. Both sides read and write the correct data type. My swf does reference the class, so flex should be able to find it. i can't figure out why I'm getting the error message.
///////////Flex Class//////
package MyData
{
import flash.utils.IDataInput;
import flash.utils.IDataOutput;
import flash.utils.IExternalizabl
//[Bindable]
[RemoteClass(alias="com.ne
public class ChatRoom implements IExternalizable
{
public var chatRoomId:String;
public var chatRoomName:String;
public function ChatRoom()
{
chatRoomId = "";
chatRoomName = "";
}
public function readExternal(input:IDataIn
chatRoomId = input.readUTF();
chatRoomName = input.readUTF();
}
public function writeExternal(output:IData
output.writeUTF(chatRoomId
output.writeUTF(chatRoomNa
}
}
}
////////////////Java Class///////////
package com.netcsd.flex.datamodel;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
public class ChatRoomData implements Externalizable {
private String chatRoomId;
private String chatRoomName;
public ChatRoomData(){
chatRoomId ="";
chatRoomName = "";
}
public String getChatRoomId(){
return chatRoomId;
}
public String getChatRoomName(){
return chatRoomName;
}
public void setChatRoomId(String id){
chatRoomId = id;
}
public void setChatRoomName(String name){
chatRoomName = name;
}
public void readExternal(ObjectInput in) throws IOException,
ClassNotFoundException {
// Read in the server properties from the client representation.
chatRoomId = in.readUTF();
chatRoomName = in.readUTF();
}
public void writeExternal(ObjectOutput
out.writeUTF(chatRoomId);
out.writeUTF(chatRoomName)
}
}
ASKER
I've never programmed in flex and am trying to get the communication up and running. If I want my flex class to be passable as parameter to a java function and my flex code to receive the corresponding java class, do I have to use IExternalizable or can I use AMF? Whatever the case is: how do I get java and flex to be able to receive each other's classes?
I will recommend transfer between client and server using Beans in this case you don't need to write special code in Java and Flex.
Remeber the rules of the bean.
your APIs/ Function must be public and containts setters and getters on JAVA side!!!
private String message;
public function getMessage():String{
return message;
}
public function void setMessage(value:String){
message = value;
}
In ActionScript you should map you java bean path in RemoteClass metatada
and implement setter/getter or use public variable
public var message;
or
private var _message:Stirng;
public function get message():String{
return _message;
}
public function set message(value:String):void {
_message = value;
}
Use BlazeDS library configure flex directory in Web-INI and you are set using RemoteObject in the Flex
Remeber the rules of the bean.
your APIs/ Function must be public and containts setters and getters on JAVA side!!!
private String message;
public function getMessage():String{
return message;
}
public function void setMessage(value:String){
message = value;
}
In ActionScript you should map you java bean path in RemoteClass metatada
and implement setter/getter or use public variable
public var message;
or
private var _message:Stirng;
public function get message():String{
return _message;
}
public function set message(value:String):void
_message = value;
}
Use BlazeDS library configure flex directory in Web-INI and you are set using RemoteObject in the Flex
ASKER
I'll give that a look and get back to you. Thanks.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
led me in the right direction
in your AS file if you want to use IExternalizable interface,
or you have to specify correct package path if you want to serialize by AMF
[RemoteClass(alias="com.netcsd.flex.datamodel.