XStream Serialization for AS3

Hi All,
There's an XML serialization API for Java called XStream.
It's a nice, clean, easy-to-use, customizable tool for pushing xml
data into and out of a java servlet.
I'm about to write an ActionScript counterpart to read and
write strongly type actionscript classes to the same format. This
will provide seamless transfer of data between java and
actionscript.
My question to all of you is: has someone done this already,
is there something else out there that's similar that I should be
using instead, or at least modeling my solution on?
I'd be happy to share my solution once it's done if anybody
wants it.
Tim

RTFM please and don't guess. This is all described in the documentation.

Similar Messages

  • What is best MVC for AS3

    Hi fellows, what is best MVC for as3?
    current i am following hummingbird/robotlegs
    what is your practice? 

    I think you should try mvcexpress. It Inspired by pureMVC and roboleg but faster and simpler than both

  • Creating a custom serializer for SOAP

    Hi guys, i'm wondering if someone could help me. I'm trying to create a custom serializer for a class with SOAP and I'm geeting the following SOAPException:
    Fault Code = SOAP-ENV:Server.Exception:
    Fault String = org/apache/soap/util/xml/Serializer
    I'm able to deploy the service with no problems.
    I'm using a very simple example in which I'm only trying to get a Person class from the service. here is the deployment descriptor:
    <isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment" id="urn:PersonService">
      <isd:provider type="java"
                    scope="Application"
                    methods="getPerson">
        <isd:java class="app.PersonService" static="false"/>
      </isd:provider>
      <isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListener>
      <isd:mappings>
        <isd:map encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
                 xmlns:x="urn:person"
                 qname="x:person"
                 javaType="app.Person"
                 java2XMLClassName="app.PersonSerializer"
                 xml2JavaClassName="app.PersonSerializer"/>
      </isd:mappings> 
    </isd:service>here is the PersonService.java:
    package app;
    public class PersonService {
        /** Creates a new instance of GetPerson */
        public PersonService() {
        public Person getPerson() {
            return new Person("joe", "something");
    }here is the Person.java:
    package app;
    public class Person {
        public String firstName;
        public String lastName;
        /** Creates a new instance of Person */
        public Person() {   
        public Person(String firstName, String lastName) {
            this.firstName = firstName;
            this.lastName = lastName;
    }here is the PersonSerializer.java:
    package app;
    import java.io.IOException;
    import java.io.Writer;
    import org.apache.soap.encoding.soapenc.SoapEncUtils;
    import org.apache.soap.rpc.Parameter;
    import org.apache.soap.rpc.RPCConstants;
    import org.apache.soap.rpc.SOAPContext;
    import org.apache.soap.util.Bean;
    import org.apache.soap.util.StringUtils;
    import org.apache.soap.util.xml.DOMUtils;
    import org.apache.soap.util.xml.Deserializer;
    import org.apache.soap.util.xml.NSStack;
    import org.apache.soap.util.xml.QName;
    import org.apache.soap.util.xml.Serializer;
    import org.apache.soap.util.xml.XMLJavaMappingRegistry;
    import org.w3c.dom.Element;
    import org.w3c.dom.Node;
    public class PersonSerializer implements Serializer, Deserializer {
        /** Creates a new instance of PersonSerializer */
        public PersonSerializer() {
        public void marshall(String string, Class aClass, Object object, Object object0, Writer writer, NSStack nSStack, XMLJavaMappingRegistry xMLJavaMappingRegistry, SOAPContext sOAPContext) throws IllegalArgumentException, IOException {
            nSStack.pushScope();
            SoapEncUtils.generateStructureHeader(string, aClass, sOAPContext, writer, nSStack, xMLJavaMappingRegistry);
            writer.write(StringUtils.lineSeparator);
            Person person = (Person)object;
            String firstName = person.firstName;
            String lastName = person.lastName;
            xMLJavaMappingRegistry.marshall(string, String.class, firstName, "firstName", writer, nSStack, sOAPContext);
            writer.write(StringUtils.lineSeparator);
            xMLJavaMappingRegistry.marshall(string, Integer.class, lastName, "lastName", writer, nSStack, sOAPContext);
            writer.write(StringUtils.lineSeparator);
            writer.write("</" + sOAPContext + '>');   
            nSStack.popScope();
        public Bean unmarshall(String string, QName qName, Node node, XMLJavaMappingRegistry xMLJavaMappingRegistry, SOAPContext sOAPContext) throws IllegalArgumentException {
            Element root = (Element)node;
            Element childElement = DOMUtils.getFirstChildElement(root);
            Person target;
            try {
                target = (Person)Person.class.newInstance();
            } catch (Exception e) {
                throw new IllegalArgumentException("Problem instantiating bean: " + e.getMessage());
            while(childElement !=null) {
                Bean paramBean = xMLJavaMappingRegistry.unmarshall(string, RPCConstants.Q_ELEM_PARAMETER, childElement, sOAPContext);
                Parameter param = (Parameter)paramBean.value;
                String tagName = childElement.getTagName();
                if(tagName.equals("firstName")) {
                    target.firstName = (String)param.getValue();
                } else if(tagName.equals("lastName")) {
                    target.lastName = (String)param.getValue();
                childElement = DOMUtils.getNextSiblingElement(childElement);
            return new Bean(Person.class, target);
    }and finally here is the client app class that calls the service, the GetPersonClient.java:
    package app;
    import java.net.MalformedURLException;
    import java.net.URL;
    import org.apache.soap.Constants;
    import org.apache.soap.Fault;
    import org.apache.soap.SOAPException;
    import org.apache.soap.encoding.SOAPMappingRegistry;
    import org.apache.soap.rpc.Call;
    import org.apache.soap.rpc.Parameter;
    import org.apache.soap.rpc.Response;
    import org.apache.soap.util.xml.QName;
    public class GetPersonClient {
        /** Creates a new instance of GetPersonClient */
        public GetPersonClient() {
        public static void main(String[] args) {
            SOAPMappingRegistry registry = new SOAPMappingRegistry();
            PersonSerializer personSerializer = new PersonSerializer();
            // Map the types.
            registry.mapTypes(Constants.NS_URI_SOAP_ENC, new QName("urn:person", "person"), Person.class, personSerializer, personSerializer);
    // Build the call.
            Call call = new Call();
            call.setSOAPMappingRegistry(registry);
            call.setTargetObjectURI("urn:PersonService");
            call.setMethodName("getPerson");
            call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
            Response response;
            try {
               response = call.invoke(new URL("http://localhost:8090/soap/servlet/rpcrouter"), "");
            } catch (SOAPException e) {
                System.err.println("Caught SOAPException: " + e.getMessage());
                e.printStackTrace();
                return;
            } catch (MalformedURLException ex) {
                ex.printStackTrace();
                return;
            if (!response.generatedFault()) {
                Parameter parameter = response.getReturnValue();
                Person person = (Person)parameter.getValue();
                if ( person != null ) {
                    System.out.println( person.firstName + " " + person.lastName );
            } else {
                Fault fault = response.getFault();
                System.err.println("Generated fault: ");
                System.out.println("  Fault Code   = " + fault.getFaultCode());
                System.out.println("  Fault String = " + fault.getFaultString());
    }if someone could help me i would be grateful.
    cheers
    nmc

    Is the problem in your 'marshall' method? You seem to be using Integer.class instead of String.class for the 'lastName' parameter...

  • Idoc Serialization for Transactional data

    Hi All,
    1. Please let me know if you have done IDOC serialization for Transactional data.
    If so please let me know the steps.
    2. How do we use serialiazation using object types. If you have done this please let me know the steps for this too.
    Thanks for your help.
    Srikanth.

    Hi Srikanth,
    Follow the steps below to set up serialization using object types:
    1.       In the SAP menu choose ® IDoc Interface/ALE ® Development ® BAPI ® Serialization ® Serialization Using Business Objects ® Determine Supported Business Objects (transaction BD105). Enter all the business object types relevant for serialization.
    2.       In the SAP menu choose ® IDoc Interface/ALE ® Development ® BAPI ® Serialization ® Serialization Using Business Objects ® Assign Message Type to a Business Object (transaction BD104). Assign the message types relevant for serialization to each business object type.
    3.       In Customizing (IMG) activate the serialized distribution in both the sending and receiving systems:
    ALE Implementation Guide (transaction SALE)
    Modeling and Implementing Business Processes
    Master Data Distribution
    Serialization for Sending and Receiving Data 
    Serialization Using Business Objects
    Execute activities Activate Outbound Business Objects and Activate Inbound Business Objects. Set the Serialization flag for the required business object types.
    If you want to do serialization by message type then
    1. go to BD44 and create a serialization group and assign messages and the serial number to each.
    2. Run the program RBDSER01.
    Award points if useful,
    Aleem.

  • Can I enable pof serialization for one cache and other JAVA serialization

    I had coherence cluster with few cache , Is there any way i can enable pof serialization for one cache and other to use normal JAVA serialization

    839051 wrote:
    I had coherence cluster with few cache , Is there any way i can enable pof serialization for one cache and other to use normal JAVA serializationHi,
    you can control serialization on a service-by-service basis. You can specify which serializer to use for the service with the <serializer> element in the service-scheme element corresponding to the service in the scache configuration file.
    Be aware, though, that if you use Coherence*Extend, and the service serializer configuration for the proxy service does not match the serializer configuration of the service which you are proxying to the extend client then the proxy node has to de- and reserialize the data which it moves between the service and the client.
    Best regards,
    Robert

  • Switch statement for AS3  - Flash CS3

    Hey guys, I currently have a code of a switch statement for as1- as2.
    This is it:
    switch (int(Math.random() * 20))
        case 0:
            hint = "The total amount of confusion in this world remains constant. It just gets shifted around.";
            break;
        case 1:
            hint = "If you experience poor performance, adjust the quality settings in your preference menu option.";
            break;
        case 2:
            hint = "Anticipation of death is better than death itself.";
            break;
        case 3:
            hint = "At the core of all well-founded belief lies belief that is unfounded.";
            break;
        case 4:
            hint = "The problem with instant gratification is that it takes too long.";
            break;
        case 5:
            hint = "Never let your schooling interfere with your education.";
            break;
        case 6:
            hint = "Beware of geeks bearing gifs.";
            break;
        case 7:
            hint = "Collaboration is essential: It allows you to blame someone else.";
            break;
        case 8:
            hint = "Read my MIPs - no new VAXes.";
            break;
        case 9:
            hint = "Where is the sea, said the fish, as they swam through it.";
            break;
        case 10:
            hint = "You can safely blame any bugs on Aoedipus, who is too busy grinding battlegrounds to do QA on her own work.";
            break;
        case 11:
            hint = "Anything worth doing is worth overdoing.";
            break;
        case 12:
            hint = "There is more to life than increasing its speed.";
            break;
        case 13:
            hint = "Don\'t worry, this will take about as long as the time it takes to play a 2v2 match with 4 ret pallies.";
            break;
        case 14:
            hint = "There is nothing worse than the brilliant image of a fuzzy concept.";
            break;
        case 15:
            hint = "If you are not part of the solution, you are part of the precipitate.";
            break;
        case 16:
            hint = "Two wrongs don\'t make a right, but three lefts do.";
            break;
        case 17:
            hint = "The heresy of today is the logic of tomorrow.";
            break;
        case 18:
            hint = "It\'s not that life is so short, it\'s just that you\'re dead a really long time.";
            break;
        case 19:
            hint = "Those who love sausage, the law, and holy canon should never watch any of them being made.";
            break;
        case 20:
            hint = "What if there were no hypothetical questions?";
            break;
    } // End of switch
    hint = "HINT: " + hint;
    This code is for a dynamic tet with the var 'hint' (No ' ' )
    But in as3 there is no var and I am having trouble converting it to AS3 coding, can someone show me the correct conversion of the code to make it work with AS3. I will make the instance name 'hint'.
    Thank you ahead of time.

    In addition to what other guys said, if you still want to use switch it should be:
    switch (Math.round(Math.random() * 20)) - this will cover all the possible integers.
    Nevertheless, I believe using switch in this case is not as efficient and scalable as using, say, array.
    1. array index access is faster than switch.
    2. if you need to make additions, you will need to make additions in switch while with array you just need to add/subtract member
    3. if you will need to switch to a more dynamic model (say, getting hints from xml) - it will not be possible with switch
    4. you may need a greater degree of randmization (Math.random is not as random as one may think) in which case resorting/reordering array is much simpler and faster.
    So, I suggest you switch to the following code:
    var hints:Array = [];
    hints[0] = "Anticipation of death is better than death itself.";
    hints[1] = "Anything worth doing is worth overdoing.";
    hints[2] = "At the core of all well-founded belief lies belief that is unfounded.";
    hints[3] = "Beware of geeks bearing gifs.";
    hints[4] = "Collaboration is essential: It allows you to blame someone else.";
    hints[5] = "Don\'t worry, this will take about as long as the time it takes to play a 2v2 match with 4 ret pallies.";
    hints[6] = "If you are not part of the solution, you are part of the precipitate.";
    hints[7] = "If you experience poor performance, adjust the quality settings in your preference menu option.";
    hints[8] = "It\'s not that life is so short, it\'s just that you\'re dead a really long time.";
    hints[9] = "Never let your schooling interfere with your education.";
    hints[10] = "Read my MIPs - no new VAXes.";
    hints[11] = "The heresy of today is the logic of tomorrow.";
    hints[12] = "The problem with instant gratification is that it takes too long.";
    hints[13] = "The total amount of confusion in this world remains constant. It just gets shifted around.";
    hints[14] = "There is more to life than increasing its speed.";
    hints[15] = "There is nothing worse than the brilliant image of a fuzzy concept.";
    hints[16] = "Those who love sausage, the law, and holy canon should never watch any of them being made.";
    hints[17] = "Two wrongs don\'t make a right, but three lefts do.";
    hints[18] = "What if there were no hypothetical questions?";
    hints[19] = "Where is the sea, said the fish, as they swam through it.";
    hints[20] = "You can safely blame any bugs on Aoedipus, who is too busy grinding battlegrounds to do QA on her own work.";
    hint = hints[int(Math.random() * hints.length)];
    // OR
    hint = hints[Math.round(Math.random() * (hints.length - 1))];

  • What is serialization for

    i've been using java for about 6 months. but i still don't know deeply about java especially serialization. what's serialization and how to implement it in real case. In what situation serialization is used?

    Hi,
    Serialization is ment for object persistance... i.e, if you want to retain the object across multiple JVM's or if you want to store the object into a database/file/....... u need to serialize it... this can be done by implementing java.io.Serializable marker interface..
    An interface is called marker interface when it has no methods to implement.
    jogesh

  • Eval functionality for AS3?

    I have searched through the forums and the web on this topic
    but can't seem to find a solution that works for my situation. I
    used to use the eval function in AS2 to access methods and
    properties of dynamically named variables but it seems to be much
    different in AS3.
    A simple example :
    var number_of_records:int=10;
    var i:int = 1;
    do {
    // the next line is what i want to emulate in AS3
    eval(mydynamicvariable_+i)._alpha = 0
    i+=1;
    }while (i<=number_of_records);
    Below is a different example and actually pertains more to to
    my question than the above example.
    I am get variables from a text file. Got that part working.
    My variables are going to be put into an array and then used in a
    dataprovider for the datagrid component. Got the last part working
    too. Just having difficulty accessing my variables dynamically and
    then putting them in an array. First I just want to trace my
    variables and that is what i am having difficulty doing. I can
    trace them with hardcoding them but not dynamically.
    //////////////My data.txt file example is:
    number_of_records= 10
    &record_1=variable 1
    &first_name_1=this someones name 1
    &last_name_1=this is somones last name 1
    &details_1=just some text 1
    &record_2=variable 2
    &first_name_2=this someones name 2
    &last_name_2=this is somones last name 2
    &details_2=just some text 2
    //////////////.. and so on to 10 for this example..
    //////////////My data.txt file is loaded with the following
    code into flash CS3 using AS3
    var myURLLoader:URLLoader= new URLLoader();
    var myURLRequest:URLRequest = new URLRequest("data.txt");
    myURLLoader.dataFormat=URLLoaderDataFormat.VARIABLES;
    myURLLoader.load(myURLRequest);
    myURLLoader.addEventListener(Event.COMPLETE, dataOK);
    function dataOK(myevent1:Event):void{
    var
    number_of_records:int=myURLLoader.data.number_of_records;
    trace("data is loaded");
    trace("number_of_records="+number_of_records);
    var i:int = 1;
    do {
    //////////////THE CODE ON THE NEXT FEW LINES IS MY QUESTION
    //////////////THE SECOND HALF IS HOW I WOULD WRITE IT IN AS2
    TO DYNAMICALLY ACCESS THE VARIABLES
    trace(
    "record_"+i.toString()+"="+eval("myURLLoader.data.record_"+i));
    trace(
    "first_name_"+i.toString()+"="+eval("myURLLoader.data.first_name_"+i));
    trace(
    "last_name_"+i.toString()+"="+eval("myURLLoader.data.last_name_"+i));
    trace(
    "details_"+i.toString()+"="+eval("myURLLoader.data.details_"+i));
    i+=1;
    }while (i<=number_of_records);
    How do i trace those variables with a loop using AS3? I can
    then figure out how to put it into the array and to get the info
    into the datagrid. Hope that I have provided enough information
    about my problem and hope that it is a simple solution.
    Please help and thanks!

    Andrei1 your awesome. Thanks dude! That's exactly what I was
    looking for. I actually did something similar but my syntax was not
    correct. I tried :
    trace(
    "record_"+i.toString()+"="+myURLLoader.data.["record_"+i])
    ///with a period before the []
    obviously wrong. Thanks again.
    trace(
    "record_"+i.toString()+"="+myURLLoader.data["record_"+i])
    ///without the period was correct.

  • How come Flex Builder does not complain when semi-colons are omitted for AS3 statements?

    Hi, I was wondering why my flexbuilder3 plugin for eclipse does not complain when and if I leave off a semi-colon at the end of an AS3 statement.  Has anybody else experience this in their flex environments?
    What can I do to fix this; as this is very annoying.
    Thanks in advance!
    Tonté

    Hm...  I see.  Thank you all for your replies.  I didn't realize AS3 does not require semi-colons at the end of AS3 statement unless there is more than one statement on the line.  I will have to double check this for my self and report back.  I guess I can't shake my Java habbits.
    Thanks again!
    Happy Flexing!
    Tonté

  • How to check IDOC Serialization for custom idoc

    In one of my interfaces, we are receiving idocs ARTMAS, INFREC, COND_A and ZMD_ARTHIER in ECC system.Last one is customized one in which basically we have to assign one article to an article hierarchy. So this idoc will contain only article no, hierarchy id and node level in which article will be assigned.
    Now here we have to implement idoc serialization so that if ARTMAS in any case fails then INFREC, COND_A and ZMD_ARTHIER idocs should not be posted. We will be using RBDSER04 program for inbound processing.
    My concern is that whether we have to do any special coding for serialization check in custom function module for the last idoc ZMD_ARTHIER.
    If yes, please please let me know how to do handle that in custom inbound function module.
    Edited by: suman pandit on May 19, 2009 10:47 AM

    Hi,
    you need to create a serialization group (in customizing) and assign all the IDocs (in specific order) to this group incl. your custom IDoc.
    When data is transfered first a SERDAT01 IDoc will be sent, after this your IDocs have to follow in specific order. At last again a SERDAT01 follows and triggers the processing in the destination system.
    Regards,
    Kai

  • Why no Built in Behaviors for AS3?

    Why are there no built in behaviors for using AS3? I am
    trying to find a
    way to do basic interactions without needing to learn AS3.
    Just curious
    why it was removed.
    Thanks.

    Not allowed to speculate as to why or why not here --
    But in general, the unibody 17" was just released with the new battery -- Apple just did a 15" refresh in October 08 -- it won't get another major refresh for awhile -- and most likely in the next refresh, they too will have the built-in batteries...at least that is what Apple initially stated when they announced the 17" a few months ago was their plan eventually for the entire portable line.
    But those will be rolled out in the coming years, not right away.

  • B2B Support for AS3 protocol

    Hi,
    Is there any way of B2B supporting the AS3 proptocol since the AS3 uses a secure FTP for communication.
    The requirement is to be able to commincate to Trading Partner AS3 servers.
    Thank you,
    Shantanu Ghosh

    Raise an Enhancement Request with support and you should get an ETA on this. You may also mail across the customer details and requirements, to Ramesh ([email protected])
    Thanks,
    Anuj

  • How to use Avro Serialization for ASA input

    Hi There,
    I am trying to use Avro serialization format for Streaming Analytics input data. I am using Event Hub as my data source. Based on the answer to a similar question in this forum about CSV format, it seems like ASA expects header/schema information to
    be included with each event, rather than defined externally. So, each of my input events is a proper Avro Data File, with schema included followed by multiple binary records. I have tried to verify this format using the "Test" button in the Azure
    Streaming Portal. When I upload a file containing my Avro event, the portal returns "Unable to parse JSON" error. I have double checked that my input is indeed marked as Avro serialization and not JSON.
    Can you let me know what the expected Avro data format is? 
    Thanks,
    Dave

    Hi Mahith,
    I am now able to reproduce the FieldsMismatchError. I am attaching the log. Could you help debug this issue?
    Correlation ID:
    000593f0-4c05-412b-b096-2cf818bf6e9f
    Error:
    Message:
    Missing fields specified in create table. Fields expected: avgLight, avgOffLight, avgHum, avgLrTemp, avgBrLight, avgBrTemp, avgLrLight, avgOffHum, avgLrHum, avgOffTemp, avgBrHum, avgTemp, groupId, ts. Fields found: avgLight, avgOffLight, avgHum, avgLrTemp, avgBrLight, avgBrTemp, avgLrLight, avgOffHum, avgLrHum, avgOffTemp, avgBrHum, avgTemp, groupId, ts.
    Message Time:
    2015-01-15 00:28:59Z
    Microsoft.Resources/EventNameV2:
    sharedNode92F920DE-290E-4B4C-861A-F85A4EC01D82.hvac-input_0_c76f7247_25b7_4ca6_a3b6_c7bf192ba44a#0.output
    Microsoft.Resources/Operation:
    Information
    Microsoft.Resources/ResourceUri:
    /subscriptions/d5c15d24-d2ef-4443-ba7e-8389a86591ff/resourceGroups/StreamAnalytics-Default-Central-US/providers/Microsoft.StreamAnalytics/streamingjobs/hvac
    Type:
    FieldsMismatchError

  • I need to know when Adobe Connect will be upgraded to allow for AS3 scripting?

    I am using Adobe Captivate 4 still because I am developing content for Adobe Connect. My company is requiring that we all upgrade to Captivate 6. It won't work with Adobe Connect. Anyone out there know when Adobe is going to upgrade Adobe Connect to incorporate AS3 scripting so I that I can continue to use Captivate with Connect?

    Adobe Connect was changed to AS3 around Nov 2010, with the release of Connect 8. I recall that Connect 8.1 was the hard change, where AS2 applications would no longer work with the meeting room.

  • What is the setVariable syntax for AS3

    Hi,
    I am having issues with setting a variable in AS3 SWF playing inside a Dir12
    spriteObjRef.setVariable(variableName, newValue)
    In the context of ActionScript 3, this method is only supported on a Flash object, not on a
    spriteObjectRef.
    What would the Flash Object syntax be??
    Thanks,
    Jim

    Jusclark-Oracle wrote:
    What is the correct syntax for referencing a page item (P23_ID, for example) in a PL/SQL page process, after submit?
    See "About Referencing Session State" in the documentation.
    Within an anonymous block in an APEX page process, use the standard bind variable syntax:
    :P23_ID
    In general, use bind variable syntax when referencing session state values in SQL or DML:
    select
        ename
    into
        :p23_name
    from
        emp
    where
        empno = to_number(:p23_id);
    and obviously when assigning values to the item:
    :P23_ID := foo.nextval;
    PL/SQL function references v('p23_id') and nv('p23_id') [for number values] must be used to access values in stored program units called from APEX, although it's usually better to pass the values as parameters: foo(:p23_id).

Maybe you are looking for