I am just getting up to speed with the Cairngorm architecture and have been struggling with this problem for a while. I have got to the point where I am getting a response from my web service call that has the data in that I expect but I cannot seem to get it to deserialize into the object that I need.

The code (I have used IResponder rather than the cairngorm Responder here as suggested during an earlier post here  )

        public function result( data:Object ):void
        {
             var event:ResultEvent = data as ResultEvent;
            
             var testString:String = "";
             for each(var thing:Object in event.result)
             {
                 testString += " " + thing + " ";
             }
             //test alert 1
             Alert.show(testString);
             //test alert 2
             Alert.show("event.result.Id = " + event.result.Id + ", event.result.Name = " + event.result.Name);
            
             var tObj:TestObj = event.result as TestObj;
             Alert.show("TestObj.Id = " + tObj.Id);
            
        }
The test alerts print out:
    test 1: Graham 1
    test 2:
"event.result.Id = 1, event.result.Name = Graham

The subsequent line throws an exception:

TypeError: Error #1034: Type Coercion failed: cannot convert mx.utils::[EMAIL PROTECTED] to HASAW.ClientApp.Model.TestObj.

The object that I am trying to create from the results looks like this:

    public class TestObj implements ValueObject
    {
       
        public var Id:int;
        public var Name:String;
        public function TestObj()
        {
            Id = 0;
            Name = "";
        }
    }


I have tried various implementations and can't get the web service response to cast to TestObj. To be honest, I wouldn't have thought that it should cast to TestObj but I have followed all of the code samples for Cairngorm and they all do it like this.

I am using .NET for the web service which may be an issue as the samples don't. It is returning the following SOAP in event.result.body

  <?xml version="1.0" encoding="utf-8" ?>
-     <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"     xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
-         <GetTesterResponse xmlns="">
-             <GetTesterResult>
                  <Id>1</Id>
                  <Name>Graham</Name>
          </GetTesterResult>
      </GetTesterResponse>
      </soap:Body>
  </soap:Envelope>

I know I could manually populate the object with the values but the objects I will be deserializing in the application are much more complex than this which would make a manual approach a pain.

Thanks in advance...

Graham
__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





YAHOO! GROUPS LINKS




__,_._,___

Reply via email to