<$BlogRSDUrl$>

Tuesday, September 28, 2004

VJs Tip Of The Day :SoapInclude Attribute 

This is from Vishal Joshi's dotnet tip on Dotnet User Group of Hyderabad

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...

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

_
Public Class Shape
Public area As Double
End Class

_
Public Class Circle
Inherits Shape
Public radius As Double
End Class

Vishal Joshi
Microsoft MVP .Net



Comments: Post a Comment

This page is powered by Blogger. Isn't yours?