views:

330

answers:

1

UPDATE: It looks like this same question has gone unanswered on the Adobe forums.

I have a C# web service exposed via WCF. Some of the exposed operations take/return abstract types. When I use the client stubs generated by Flex Builder 3, I construct the derived types and pass them as parameters to the web service call. This all appears to work correctly, but on the server side I get an exception saying that it cannot construct an abstract type. Looking at the SOAP message that is sent I see that the instance type attribute is not present, and any derived-class specific properties are not included.

For example if a class 'Apple' derives from an abstract class 'Entity', and I create an instance of Apple and pass it to an operation GetModificationDate(Entity), I am seeing the following snippet in the message sent to the server:

<Entity>
   <EntityProperty1>foo</EntityProperty1>
   <EntityProperty2>bar</EntityProperty2>
</Entity>

What I expect:

<Entity xsi:type="Apple">
   <EntityProperty1>foo</EntityProperty1>
   <EntityProperty2>bar</EntityProperty2>
   <AppleProperty1>test</AppleProperty1>
</Entity>

I am aware that the default WCF serializer does not properly mark classes as abstract in the WSDL, as per this question, but type inheritance is properly described and so polymorphic behavior is expected (and works in .NET, Silverlight, and Java Axis2 clients I've created.)

So is there a way to make Flex send the correctly typed message?

A: 

I am facing same problem ... did any one ever got the solution to this problem?

kay kay
Nope. We implemented a horrible workaround where for the specific operations that used derived types we hand constructed the SOAP messages at runtime. Yuck.Also, we have since re-test this scenario with Flex 4, and there is a worse problem. Derived types that are present in the WSDL but never used explicitly in any operations will not have code generated for them. We have since switched to Silverlight and everything works great.
Matt Z