WCF Service Returning Object with no properties
I'm learning how to access data on a DB using a WCF web service. My main issue I've run into is that when making a call for the result from the service, the return value is of type UniversityClass but no properties are available and I believe its real type is simply an object, therefore I have no access to any of its 'real' properties.
Heres a snippet of the class in my interface called 'Service1'
<ServiceContract()> Public Interface IService1 <OperationContract()> Function GetUniversity(ByVal universityID As Integer) As UniversityClass End Interface <DataContract()> Public Class UniversityClass Private _universityId As Integer Public Property UniversityID As Integer Get Return _universityId End Get Set(value As Integer) _universityId = value End Set End Property
and heres a preview of me making the call to the service to get the data
Dim client As New ServiceReference1.Service1Client Dim result As New ServiceReference1.UniversityClass Dim x = client.GetUniversityAsync(Integer.Parse(tbUniversityID.Text)) Dim r As WCFServiceExample.ServiceReference1.UniversityClass = Await x If x.IsCompleted Then result = x.Result End If tbResult.Text = result. _ _ _ _ '// ^ No properties accessible here even though it recognizes that result is of type UniversityClass
Upon inspecting ServiceReference1.UniversityClass I get taken to Referece.vb and notice that there is Partial Class UniversityClass which inherits object. I think perhaps that may be the reason why I don't have any access to the properties defined in my Service1 class because it thinks UniversityClass is an object with no type.
I've tried rebuilding all projects individually, rebuilding the solution and still nothing.
Would love some assistance with how to actually get an object of type UniversityClass to return from my service.
Any help would be greatly greatly appreciated!
Your client can't see the UniversityID because you haven't marked it as a data member:
<DataContract()> Public Class UniversityClass Private _universityId As Integer <DataMember()> Public Property UniversityID As Integer Get Return _universityId End Get Set(value As Integer) _universityId = value End Set End Property