Returning DataTable objects with WCF service

This is a strange problem that I am having with WCF trying to send DataTable in the response. I have the following service contract in IService1.vb:

IService1.vb:

<ServiceContract()>
Public Interface IService1
<OperationContract()>
Function GetUserInformation() As UserInformation
End Interface


<DataContract> _


Public Class UserInformation
<DataMember> _
Public Property UserInfoTable() As DataTable
Get
Return m_UserInfoTable
End Get
Set(value As DataTable)
m_UserInfoTable = value
End Set
End Property
Private m_UserInfoTable As DataTable

Service1.svc.vb


Public Function GetUserInformation() As UserInformation Implements IService1.GetUserInformation
Dim oUserInformation As New DataConnection
Dim dtUserInformation As New UserInformation
dtUserInformation.UserInfoTable = oUserInformation.FillDataTable("[Basic].FetchBasicInformation")
Return dtUserInformation
End Function

While consume the service in application we call service like this.

Dim dtUserInformation As New DataTable
Try


Dim svrUserInfo = New ServiceReference.Service1Client()
Dim UserInfomation = New ServiceReference.UserInformation()

UserInfomation = svrUserInfo.GetUserInformation()

dtUserInformation = UserInfomation.UserInfoTable

If (dtUserInformation.Rows.Count > 0) Then
dxgUserInformation.ItemsSource = dtUserInformation
Else
dxgUserInformation.ItemsSource = Nothing
End If
Catch ex As Exception
DXMessageBox.Show(ex.InnerException.ToString())
End Try

Hold ON!!!!

Now the problem is start.. while consuming the service it showing error. its seems look like

Error:

An error occurred while receiving the HTTP response to http://localhost%3A8731/Design%5FTime%5FAddresses/DataProviderServiceLibrary/SapphireDataService/. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.
This is rather odd because the service is configured to use the wsHttpBinding, which I assume uses HTTP propocol. This error does not occur if I try calling the LoadDataTest() method!
So what I have done was put this table I have gotten from the database into a DataSet object and it worked! No errors or anything of the sort. BUT, the table that was returned in the DataSet was EMPTY. All the fields were Null and no data has been transfered/de-serialized properly

Solution
Its happen only because of table name for DataTable is empty, so this error keep on come around while consuming the service.

Just name the datatable like this.


Solution:
Public Function GetUserInformation() As UserInformation Implements IService1.GetUserInformation
Dim oUserInformation As New DataConnection
Dim dtUserInformation As New UserInformation
dtUserInformation.UserInfoTable = oUserInformation.FillDataTable("[Basic].FetchBasicInformation")
dtUserInformation.UserInfoTable.TableName = "Table1" /* Here is the solution. just give name for the table. It will solve your problem.*/
Return dtUserInformation
End Function

That’s it. Now run the application issue will solved.

Cheers!!

Do you have any issues to implement the above code please feel free to mail me