msbeal

I'm trying to build a WCF web service that passes up and back a dataTable. I built a DataContract to contain the dataTable like this:

<DataContract(), Serializable()> _

Public Class RequestInfo

<DataMember()> _

Public Table As System.Data.DataTable

<DataMember()> _

Public Stage As Integer

<DataMember()> _

Public Time As DateTime

End Class

My Interface is equally simple.

<ServiceContract(Namespace:="http://PresidentCommunicator/PresidentService")> _

Public Interface IPresidentService

<OperationContract()> _

Function HotelRequestPoll(ByVal req As RequestInfo) As RequestInfo

End Interface

In my client I then instantiate a RequesInfo object and try to set the DataTable member with an ordinary dataTable it balks. It wants me to only use a RequestInfoTable, what ever the heck that is.

reqInfo.Table = ordinaryDataTable

It says DataTable is fully supported by not be me. What am I doing wrong I am using my VS to reference my proxy client for the web service.


Re: Windows Communication Foundation (Indigo) Passing a DataTable to a Web Service??

Christian Weyer

Did you do a 'Add Service Reference...' or the old 'Add Web Reference...'






Re: Windows Communication Foundation (Indigo) Passing a DataTable to a Web Service??

msbeal

After 18 hours I got the dataset going back and forth (switched to a typed dataset) and now the simple Integer and Datetime of the RequestInfo gets wiped out by the time they hit the server. I set the int to 1 but it arrives at server as a 0. hmm. I'm going to bed while I have at least some success.

Here's the latest incarnate of the DataContract - see anything suspicious

<DataContract(), Serializable()> _

Public Class RequestInfo

Private _State As Integer = 0

<DataMember()> _

Public ReqDataSet As dsRequest

<DataMember()> _

Public Property Stage() As Integer

Get

Return _State

End Get

Set(ByVal value As Integer)

_State = value

End Set

End Property

'<DataMember()> _

'Public Stage As Integer 'neither of these work for the integer

<DataMember()> _

Public Time As DateTime

End Class






Re: Windows Communication Foundation (Indigo) Passing a DataTable to a Web Service??

Christian Weyer

How do you create and fill the data contracts - just trying to find out what is going wrong for you






Re: Windows Communication Foundation (Indigo) Passing a DataTable to a Web Service??

msbeal

In the client:

Dim reqIn As New RequestInfo

Dim reqOut As RequestInfo

reqIn.Time = DateTime.Now

reqIn.Stage = 1

reqIn.ReqDataSet = ds

Dim ws As New PresidentService1.PresidentServiceClient("BasicHttp")

ws.Open()

reqOut = ws.HotelRequestPoll(reqIn)

As I mentioned, the ds travels but I lose teh Stage and Time variables.

I'm wondering if the trouble is putting DataContract and Serializable together on the attributes

<DataContract(), Serializable()> _

Public Class RequestInfo

Private _State As Integer = 0

<DataMember()> _

Public ReqDataSet As dsRequest

<DataMember()> _

Public Property Stage() As Integer

Get

Return _State

End Get

Set(ByVal value As Integer)

_State = value

End Set

End Property

'<DataMember()> _

'Public Stage As Integer

<DataMember()> _

Public Time As DateTime

End Class

Thanks for the help.






Re: Windows Communication Foundation (Indigo) Passing a DataTable to a Web Service??

Christian Weyer

Can you send over your code to christian.weyer __AT__ thinktecture.com






Re: Windows Communication Foundation (Indigo) Passing a DataTable to a Web Service??

msbeal

Sure I can send my code but I've had a small break through. I had set the Int and the Date variables to have default values, 0 and nothing respectively. So reading through the help files I spotted a parameter to DataMember called IsRequired. So I did away with any default values and placed the new attributes on those members and now they do travel up to the service. Are you not suppose to give you variables initial values - did I miss that somewhere Here's the new working version. Is it possible when you include a Typed Dataset it can wipe out the little guys in the xml I also added the new const but I don't think that by itself fixed the problem.

<DataContract(), Serializable()> _

Public Class RequestInfo

Private _Stage As Integer

Private _MyTime As Date

<DataMember()> _

Public ReqDataSet As dsRequest

Public Sub New()

End Sub

'<DataMember()> _

'Public Stage As Integer

<DataMember(IsRequired:=True)> _

Public Property Stage() As Integer

Get

Return _Stage

End Get

Set(ByVal value As Integer)

_Stage = value

End Set

End Property

<DataMember(IsRequired:=True)> _

Public Property MyTime() As Date

Get

Return _MyTime

End Get

Set(ByVal value As DateTime)

_MyTime = value

End Set

End Property

End Class

In review, I got the dataset to bounce back and forth but the simple datatypes included in that class, int and date, wouldn't travel up to the service. I did discover I could re-set the Stage and MyTime variable at the service function and it returned fine.

Here's the function code at the server

<OperationContract()> _

Function GarageRetreivalPoll(ByVal ret As RequestInfo) As RequestInfo

The actual code at the server only returned the incoming RequestInfo obj

Public Function HotelRequestPoll(ByVal ret As RequestInfo) As RequestInfo Implements IPresidentService.HotelRequestPoll

return ret

End Function