简体   繁体   中英

Webservice expose a complex type to the client in wsdl

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM