We have a situation where we would like to just serialize the base class
when passing it to a webservice.
For example, assume we have the following serialization classes:
<XmlRoot("BaseR ecord")> _
Public Class BaseRecord
<XmlAttribute() > _
Public ID As Integer
End Class
<XmlRoot("SubCl assRecord")> _
Public Class SubClassRecord
Inherits BaseRecord
<XmlAttribute() > _
Public ExtraData As String
End Class
Also assume that I have two web methods:
<WebMethod()> _
Public Sub SaveBaseRecord( record As BaseRecord)
End Sub
<WebMethod()> _
Public Sub SaveSubClassRec ord(record As SubClassRecord)
End Sub
This all works fine unless I try to pass a SubClassRecord to SaveBaseRecord.
In that case, the full SubClassRecord class is serialized.
For example, calling SaveBaseRecord with a SubClassRecord instance produces
the following XML that is sent to the webservice:
<BaseRecord xsi:type="SubCl assRecord" ID="5" ExtraData="..." />
I'd like to be able to pass a SubClassRecord to SaveBaseRecord, but only
have it serialize the BaseRecord type:
<BaseRecord ID="5" />
Is there any way to force this?
Thanks,
Eric
when passing it to a webservice.
For example, assume we have the following serialization classes:
<XmlRoot("BaseR ecord")> _
Public Class BaseRecord
<XmlAttribute() > _
Public ID As Integer
End Class
<XmlRoot("SubCl assRecord")> _
Public Class SubClassRecord
Inherits BaseRecord
<XmlAttribute() > _
Public ExtraData As String
End Class
Also assume that I have two web methods:
<WebMethod()> _
Public Sub SaveBaseRecord( record As BaseRecord)
End Sub
<WebMethod()> _
Public Sub SaveSubClassRec ord(record As SubClassRecord)
End Sub
This all works fine unless I try to pass a SubClassRecord to SaveBaseRecord.
In that case, the full SubClassRecord class is serialized.
For example, calling SaveBaseRecord with a SubClassRecord instance produces
the following XML that is sent to the webservice:
<BaseRecord xsi:type="SubCl assRecord" ID="5" ExtraData="..." />
I'd like to be able to pass a SubClassRecord to SaveBaseRecord, but only
have it serialize the BaseRecord type:
<BaseRecord ID="5" />
Is there any way to force this?
Thanks,
Eric