SoapInclude Attribute
In case of webservice programming you can allow SoapInclude Attribute on your webmethod to make sure that the specific type gets passed by... You use this attribute on your webmethod when in normal circumstances that type would not get passed...
For instance, if you have a class inheriting for a base class and a member is declared of the type base class and later instantiated as derieved, then the derieved class will not get passed across in that scenario on your webmethod you would apply this attribute...
Look at the example below...
<WebMethod(), SoapInclude(GetType(Circle)), XmlInclude(GetType(Circle))> _
Public Function ReturnSomething(ByVal key As String) As Shape
If (key = "Circle") Then
Dim circl As Shape = New Circle()
circl.area = 2
Return circl
End If
End Function
<Serializable()> _
Public Class Shape
Public area As Double
End Class
<Serializable()> _
Public Class Circle
Inherits Shape
Public radius As Double
End Class
No comments:
Post a Comment