How to construct help page for inherited classes in WCF

33 Views Asked by At

I used [KnownType] attribute for inherited classes in my WCF webservice. My problem is that the help page on endpoint (.../WebServices/Gateway.svc/help/operations/GetMessages) shows just one of the inherited classes as example.

it shows as below:

{
    "Code":"String content",
    "Messages":[{
        "__type":"PhotoMessage:#ApplicationGateway",
        "KeyboardButtons":[{
            "BackGroundColor":"String content",
            "Text":"String content"
        }],
        "Caption":"String content",
        "Url":"String content"
    }]
}

the image of my WCF webservice help page

But I want it to show as below(have an example for each inherited Class):

{
    "Code":"String content",
    "Messages":[{
        "__type":"PhotoMessage:#ApplicationGateway",
        "KeyboardButtons":[{
            "BackGroundColor":"String content",
            "Text":"String content"
        }],
        "Caption":"String content",
        "Url":"String content"
    }]
}
{
    "Code":"String content",
    "Messages":[{
        "__type":"TextMessage:#ApplicationGateway",
        "KeyboardButtons":[{
            "BackGroundColor":"String content",
            "Text":"String content"
        }],
        "Text":"String content"
    }]
}

Does anyone know a way to add this feature to WCF webservice help page?

my classes are as below:

Message class :

[DataContract]
[KnownType(typeof(PhotoMessage))]
[KnownType(typeof(TextMessage))]
public abstract class Message
{
    [DataMember]
    public KeyboardButton[] KeyboardButtons { set; get; }
}

TextMessage class :

[DataContract]
public class TextMessage : Message
{
    [DataMember]
    public string Text { set; get; }
}

PhotoMessage class :

[DataContract]
public class PhotoMessage:Message
{
    [DataMember]
    public string Url { set; get; }
    [DataMember]
    public string Caption { set; get; }
}

And What My Endpoint Return is :

[DataContract]
[KnownType(typeof(PhotoMessage))]
[KnownType(typeof(TextMessage))]
public class WebServiceOutputGetMessages
{
    [DataMember]
    public Message[] Messages { set; get; }
    [DataMember]
    public string Code { set; get; }
}
0

There are 0 best solutions below