Цитата:
Сообщение от surlac
Звучит очень подозрительно  . Ну да ладно...
Для этого пользуются штуками типа OpenAMF.
|
OpenAMF я пробовал ...
Только вот толи я не правильно прописал его ...
Толи я на яве не правильно его в АМФ конвертнул ...
Хотя все по инструкций сделал ...
С явы на яву понимает аррей коллекшн ...
А при приеме с флекса он ее как текси воспринимает ...
Но в принципе я и с явы на яву когда гонял оно как текст было ...
Но после распарсивания (приема с другой стороны) он обратно как аррей коллекшн становился ...
А во флексе не смог такого же результата добиться ?!
А blazeDS я тоже пробовал ...
Но он какой то казючий ...
Сыроватый ...
Думал сам дописать да исходники ссыльчатые ...
В общем я тут накидал что я хотел протестить ...
Вот исходники того класса на яве с которыми я тестировал ...

Код:
package kz.eitt.xcms.flex;
import java.io.*;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import flex.messaging.io.SerializationContext;
import flex.messaging.io.amf.Amf3Input;
import flex.messaging.io.amf.Amf3Output;
import javassist.bytecode.ByteArray;
import javax.xml.parsers.DocumentBuilderFactory;
import com.xcframework.tab.XTable;
public class testAMF {
public static void main(String[] args) {
try {
ArrayList al = new ArrayList();
al.add("One");
al.add("Two");
al.add("Thre");
al.add("Four");
al.add("Five");
al.add("Six");
al.add("Onere");
al.add("Twwero");
al.add("Tsdfghre");
al.add("Fosdfgur");
al.add("Fsdfgive");
al.add("Sisdfgx");
HashMap hm = new HashMap();
hm.put("field1", "value1");
hm.put("field2", "value2");
hm.put("field3", "value3");
hm.put("field4", "value4");
hm.put("field5", "value5");
hm.put("field6", "value6");
hm.put("field1", "value1");
hm.put("field2", "value2");
hm.put("field3", "value3");
hm.put("field4", "value4");
hm.put("field5", "value5");
hm.put("field6", "value6");
hm.put("field1", "value1");
hm.put("field2", "value2");
hm.put("field3", "value3");
hm.put("field4", "value4");
hm.put("field5", "value5");
hm.put("field6", "value6");
hm.put("field7", "value1");
hm.put("field8", "value2");
hm.put("field9", "value3");
hm.put("field10", "value4");
hm.put("field11", "value5");
hm.put("field12", "value6");
SerializationContext context = getSerializationContext();
TestBean testBean = new TestBean();
//testBean.setList(al);
//testBean.setMap(hm);
testBean.setString("test test test test test test");
ByteArrayOutputStream bout = new ByteArrayOutputStream();
//ByteArray bout = new ByteArray();
Amf3Output amf3Output = new Amf3Output(context);
amf3Output.setOutputStream(bout);
amf3Output.writeObject(testBean);
File f = new File("f.txt");
FileOutputStream to = new FileOutputStream(f);
bout.writeTo(to);
amf3Output.flush();
amf3Output.close();
System.out.println("testBean = " + testBean.toString().length());
System.out.println("amf3Output = " + amf3Output.toString().length());
System.out.println("string =" + testBean.getString());
//System.out.println("list =" + testBean.getList());
//System.out.println("map =" + testBean.getMap());
//InputStream bIn = new ByteArrayInputStream(bout.toByteArray());
File ff = new File("f.txt");
FileInputStream i = new FileInputStream(ff);
//ByteArrayInputStream bIn = new ByteArrayInputStream(bout.toByteArray());
//ByteArrayInputStream bIn = new ByteArrayInputStream(i);
Amf3Input amf3Input = new Amf3Input(context);
//amf3Input.setInputStream(bIn);
amf3Input.setInputStream(i);
TestBean o = (TestBean) amf3Input.readObject();
System.out.println("str eq = " + o.getString().equals(testBean.getString()));
//System.out.println("list eq = " + o.getList().equals(testBean.getList()));
//System.out.println("map eq = " + o.getMap().equals(testBean.getMap()));
System.out.println("string =" + o.getString());
//System.out.println("list =" + o.getList());
//System.out.println("map =" + o.getMap());
System.out.println("amf3Input = " + amf3Input.toString().length());
} catch (Exception e) {
e.printStackTrace();
}
}
public static SerializationContext getSerializationContext() {
//Threadlocal SerializationContent
SerializationContext serializationContext = SerializationContext.getSerializationContext();
/*
serializationContext.enableSmallMessages = true;
serializationContext.instantiateTypes = true;
//use _remoteClass field
serializationContext.supportRemoteClass = true;
//false Legacy Flex 1.5 behavior was to return a java.util.Collection for Array
//ture New Flex 2+ behavior is to return Object[] for AS3 Array
serializationContext.legacyCollection = false;
serializationContext.legacyMap = false;
//false Legacy flash.xml.XMLDocument Type
//true New E4X XML Type
serializationContext.legacyXMLDocument = false;
//determines whether the constructed Document is name-space aware
serializationContext.legacyXMLNamespaces = false;
serializationContext.legacyThrowable = false;
serializationContext.legacyBigNumbers = false;
serializationContext.restoreReferences = false;
serializationContext.logPropertyErrors = false;
serializationContext.ignorePropertyErrors = true;
*/
return serializationContext;
/*
97.
serializationContext.enableSmallMessages = serialization.getPropertyAsBoolean(ENABLE_SMALL_MESSAGES, true);
98.
serializationContext.instantiateTypes = serialization.getPropertyAsBoolean(INSTANTIATE_TYPES, true);
99.
serializationContext.supportRemoteClass = serialization.getPropertyAsBoolean(SUPPORT_REMOTE_CLASS, false);
100.
serializationContext.legacyCollection = serialization.getPropertyAsBoolean(LEGACY_COLLECTION, false);
101.
serializationContext.legacyMap = serialization.getPropertyAsBoolean(LEGACY_MAP, false);
102.
serializationContext.legacyXMLDocument = serialization.getPropertyAsBoolean(LEGACY_XML, false);
103.
serializationContext.legacyXMLNamespaces = serialization.getPropertyAsBoolean(LEGACY_XML_NAMESPACES, false);
104.
serializationContext.legacyThrowable = serialization.getPropertyAsBoolean(LEGACY_THROWABLE, false);
105.
serializationContext.legacyBigNumbers = serialization.getPropertyAsBoolean(LEGACY_BIG_NUMBERS, false);
106.
boolean showStacktraces = serialization.getPropertyAsBoolean(SHOW_STACKTRACES, false);
107.
if (showStacktraces && Log.isWarn())
108.
log.warn("The " + SHOW_STACKTRACES + " configuration option is deprecated and non-functional. Please remove this from your configuration file.");
109.
serializationContext.restoreReferences = serialization.getPropertyAsBoolean(RESTORE_REFERENCES, false);
110.
serializationContext.logPropertyErrors = serialization.getPropertyAsBoolean(LOG_PROPERTY_ERRORS, false);
111.
serializationContext.ignorePropertyErrors = serialization.getPropertyAsBoolean(IGNORE_PROPERTY_ERRORS, true);
112.
*/
}
}