Webservice expose a complex type to the client in wsdl

1k views Asked by At

I have (to make things easy) 2 classes 1) abstract class A 2) inherited class B from A.

now i'm using a method "callMethod(A argument)" which is exposing my abstract class in the wsdl.

But the problem is that on the client side i want to be able to know if A is B or something else. And i want to be able to reach the Class B which is not available since it's not in wsdl.

I've tried KnownTypeAttribute and ServiceKnownTypeAttribute, but i'm not being able to getting it to work.

Now of course i can create a dummy method that uses a parameter of type B, and thus resulting in class B being exposed in WSDL, but that's unprofessional.

Any idea? Thanks a lot

1

There are 1 answers

3
Jon Egerton On

I've faced the same problem, and the only thing I found was to have a method that exposed the type (albeit I needed one in the long run).

The problem is that the wsdl has to contain the type in order that the properties of B are known on client side, otherwise you cannot ever use B client side. The wsdl for B will include the fact that it inherits A.

In otherwords on client side your object really is a A - as only public properties are serialized there's no difference between an A or a B if the webmethod passes an A.