What is the KnownType attribute analog for XML Serialization?
Are there any analogs of KnownTypeAttribute but for XmlSerializerClass? How I can configure known types for asmx web services?
I created an .asmx web service. Now, client cannot serialize request to it. So, I want somethi开发者_运维百科ng like KnownTypesAttribute in order to specify which types serializer have to use.
I just had to add XmlIncludeAttribute to class which is used as input parameter of the web.service method. That makes client generate correct web reference and XmlSerializer will be abble serialize this class correctly.
<Xml.Serialization.XmlInclude(GetType(String()))> _
Public Class MssRequest
.........
You can pass an array of known types:
XmlSerializer xs = new XmlSerializer(typeof(MyType),
new Type[] {typeof(MyNestedType)});
In this setting:
public class MyType
{
public IMyInterface NestedType { // .... implemented by MyNestedType
精彩评论