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>
<soap:Body>
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
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
__,_._,___

