WebService and returning service data or array
I am trying to setup a web service that is called from a .NET compact framework application and returns all the services on a particular machine. I can get this to work by filling an ArrayList with the service name, then returning it to the client. However, there are multiple properties that I need to return such as status, etc. I guess my question boils down to how can I return an array from a web service.
Here is some of my code(webservice):
Begin Class
<WebMethod()> _
Public Function GetServices(ByVal inServer As String) As ArrayList
Dim services() As ServiceController
Dim srvlist As ServiceController
Dim RetArray As New ArrayList
Dim item As String
services = ServiceController.GetServices(inServer)
For Each srvlist In services
Dim ItemName As New SvcDataObj
ItemName.DispName = srvlist.DisplayName
ItemName.DispSrvName = srvlist.ServiceName
ItemName.DispState = srvlist.Status
Dim myTest As String = ItemName.ToString
RetArray.Add(ItemName)
Next
Return services
End Function
Public Structure SvcDataObj
Public DispName As String
Public DispSrvName As String
Public DispState As ServiceProcess.ServiceControllerStatus
End Structure
End Class
Client code:
Dim WiSESvc As New servername.Service1
WiSESvc.GetServices("server")
I should be able to set the WiSESvc.GetServices("server") to an object, then iterate through all the services but this does not work. Any help would be GREATLY appreciated!