can webmethods be polymorphic?

  • Thread starter Thread starter Manco
  • Start date Start date
M

Manco

Let's say I have a web-service that defines Web method:

void DoSomething(BaseType b);

let's day I have a DerivedType: BaseType. Can a web-service automatically
take a derived object base reference like a normal C# method would do? So
far I haven't been able to.
 
My guess is yes.
You can use a DerivedType where a BaseType is expected.
It's just an XML problem. When .NET Framework serialize your DerivedType, it
take all fields and save them in XML. Fields from BaseType are saved then
fields from DerivedType are saved.
XML had been done to let updating of schema without impacting existing app.
So, when the .NET Framework deserialize your DerivedType as a BaseType, it
will take in the XML the fields needs for BaseType and ignore others (those
from DerivedType).


Lionel.
 
Back
Top