Note that there are some explanatory texts on larger screens.

plurals
  1. POsending request with generic data type from FlashBuilder4 to wcf service
    text
    copied!<p>I've got a wcf service set up on the server which is supplying data to a flex project built using Flashbuilder4. I've used the webservice introspection feature to generate the DTOs and service proxies. One of the DTOs has a property of type Object. The contents of this generic object will vary based on certain conditions but will always be another complex object. Creating and populating the vo in FB4 goes smoothly but when the object is serialised it looks like this:</p> <pre><code>&lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt; &lt;SOAP-ENV:Body&gt; &lt;tns:GetC xmlns:tns="EP2ProblemDemo1"&gt; &lt;tns:anyObj&gt; &lt;tns:Property1&gt;yo!&lt;/tns:Property1&gt; &lt;tns:Property2&gt;yo! yo!&lt;/tns:Property2&gt; &lt;/tns:anyObj&gt; &lt;/tns:GetC&gt; &lt;/SOAP-ENV:Body&gt; &lt;/SOAP-ENV:Envelope&gt; </code></pre> <p>Where you might notice the anyObj property is missing any sort of type information despite referencing an object of type ClassB:</p> <pre><code>public class ClassA { public string Property1; } public class ClassB : ClassA { public string Property2; } </code></pre> <p>The anyObj argument for GetC is missing something like the following:</p> <p>xsi:type="tns:ClassB" xmlns:tns="EP2ProblemDemo1"</p> <p>Which in turn produces an error when the wcf service tries to decode the message. I think the service is interpreting the contents of anyObj as an array which cannot be implicitly converted to a base object?</p> <p>When setting the anyObj argument (of type Object) to an instance of ClassB it seems that the type information is lost. Is this correct behaviour? I was under the impression that even though you may set a superclass variable to reference one of it's subclasses the type information of the subclass should be retained and therefore also included in the serialised representation of that object.</p> <p><strong>EDIT</strong> It seems like the FlashBuilder4 serializer strips out concrete type and namespace info from a property of type Object when sending back to the wcf service which then cannot deserialize what looks to it like an array. Also, when importing a WSDL file in FB4, VO inheritance is lost as they ultimately extend EventDispatcher in order to be bindable.</p> <p><strong>SOLUTION</strong> My Solution was to change tack and move towards Remoting with AMF, implemented in .NET using FluorineFX<a href="http://www.fluorinefx.com/" rel="nofollow">FluorineFX official website</a> which works beautifully and has the pleasant side effect of lower bandwidth consumption due to data being transmitted as byte array.</p> <p>I believe WebORB<a href="http://www.themidnightcoders.com/products.html" rel="nofollow">WebORB official site</a> can also be used to implement AMF in .net too but I've not tried it yet.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload