N
Niklas Magnusson
I want to Return Objects to clients using Webservice. I have attached
samplecode below. (It is very simplified)
But it doesn´t work very well because i understand that Hashtables can´t be
serialized to XML because of the IDictionary interface. The thing is that we
have alot of Bussiness objects built this way. Have i missed something, is
there a workaround ?
<Serializable()> Public Class Order
Private ht As New Hashtable()
Public OrderID As Long
Public Sub AddOrderRow(ByVal OrderRow As OrderRow)
ht.Add(ht.Count + 1, OrderRow)
End Sub
Public Function OrderRow(ByVal Index As Long) As OrderRow
Return ht(Index)
End Function
Public Function OrderRows() as Hashtable
Return ht
End Function
End Class
<Serializable()> Public Class OrderRow
Public tDate As Date
Public lItemID As Long
Public sComent As String
End Class
<WebService(Namespace:="http://tempuri.org/")> _
Public Class Service1
Inherits System.Web.Services.WebService
<WebMethod()> Public Function GetOrder(ByVal OrderID As Long) As Order
Dim Order As New Order()
Return Order
End Function
End Class
samplecode below. (It is very simplified)
But it doesn´t work very well because i understand that Hashtables can´t be
serialized to XML because of the IDictionary interface. The thing is that we
have alot of Bussiness objects built this way. Have i missed something, is
there a workaround ?
<Serializable()> Public Class Order
Private ht As New Hashtable()
Public OrderID As Long
Public Sub AddOrderRow(ByVal OrderRow As OrderRow)
ht.Add(ht.Count + 1, OrderRow)
End Sub
Public Function OrderRow(ByVal Index As Long) As OrderRow
Return ht(Index)
End Function
Public Function OrderRows() as Hashtable
Return ht
End Function
End Class
<Serializable()> Public Class OrderRow
Public tDate As Date
Public lItemID As Long
Public sComent As String
End Class
<WebService(Namespace:="http://tempuri.org/")> _
Public Class Service1
Inherits System.Web.Services.WebService
<WebMethod()> Public Function GetOrder(ByVal OrderID As Long) As Order
Dim Order As New Order()
Return Order
End Function
End Class