4 Replies Latest reply on Mar 10, 2008 3:29 PM by bitwyse

    How to create value objects from xml

    bitwyse Level 1
      I am receiving xml back from my web service ( e4x ). I am trying to figure out how to create a value object without having to manually fetch each value in the value objects constructor. I am using introspecton in my Java web service to do this. Is there such a thing in Action Script?

      Anyone done this before that can share some code???? Any help would be very much appreciated.
        • 1. Re: How to create value objects from xml
          Gaurav J Adobe Employee
          You can specify results format on the webservice as e4x. I think you need not create a value object, you can directly access all data using the XML class.

          Take a look at http://livedocs.adobe.com/flex/2/docs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDo cs_Parts&file=00001912.html

          Thanks,
          Gaurav
          • 2. Re: How to create value objects from xml
            bitwyse Level 1
            Thanks for the reply Guarav.

            However, I am using Cairngorm in a rather sizable application. I'm having problems retrieving data from my web service with resultType="object" thus I'm trying "e4x". I need to convert the resulting xml into a value object so I can use them throughout my application.

            If you or anyone knows a way to do that easily I would appreciate the help.
            • 3. Re: How to create value objects from xml
              ntsiii Level 3
              To do this dynamically, that is, without knowing the structure of the returned data, would result in a nested structure of dynamic objects, same as what Flex does if you do not specify the result format.

              Such a value object would not provide the performance gains that a strongly typed object will. It would also be difficult to navigate and to specify data elements. And it would not be bindable.

              In fact, why do you want value to build objects at all? Why not just use the XML nodes directly? What advantage are you looking for from the value objects.

              XML is easy to navigate, and IS bindable.

              Tracy
              • 4. Re: How to create value objects from xml
                bitwyse Level 1
                That's twice now I've heard that. lol.
                I am using Cairngorm and I suppose out of ignorance perhaps, I am using VO's. So my web service would return an Object Proxy and I have some code that could create objects dynamically from the results. The objects had to be simple of course and now they are becoming more complex thus the need to change to e4x instead of objects.

                So now I am trying to convert the xml result into the desired VO to be used throughout the rest of the application. I'm not sure how to use Cairngorm without the VO's they are tied to everything. Are you familiar with the architecture? Your thoughts?