views:

47

answers:

1

I have some simple code:

   [DataContract]
   [KnownType(typeof(SpecialEvent))]
   public class Event
   {
     //data
   }

   [DataContract]
   public class SpecialEvent : Event
   {
     //data
   } 

   [ServiceContract]
   public interface IService
   {
        [OperationContract]
        List<Event> GetEvents();
   }

    [ServiceBehavior]
    public class Service : IService
    {
       public List<Event> GetEvents()
       {
           List<Event> events = new  List<Event>();
           events.Add(new Event());
           events.Add(new SpecialEvent());
           return events;
       }
    }

I know that it works fine in case wcf to wcf.

but what about interoperability?

is it generate standart wsdl and any client can use the service or no?

+1  A: 

Yes, this is interoperable. I have written a service that uses Known Types in a similar way and several third parties are calling that service from a variety of clients, including Java and PHP.

EDIT: WCFExtras

One thing I've learned is that not all non-WCF clients can understand WCF's default WSDL. The problem is that WCF splits its WSDL into several parts rather than using a single file. You can fix this by using something like WCFExtras to merge the WSDL back into a single file.

Damian Powell