Don't get WCF with custom Class working RRS feed

  • Question

  • Hey

    I am starting with playing around with WCF. But I don't get it working. I can't see my Problem and this since a few days...

    So, I will explain in Detail, what I did so far.

    I created a blank ASP.NET Project (VS 2013)

    Within I created 2 files

    The first file is the Contract Interface

    mports System.ServiceModel
    Namespace DataClasses
        <ServiceContract> _
        Public Interface ITestService
            <OperationContract> _
            Function ReturnClass() As List(Of TestDataClass)
        End Interface
    End Namespace

    Ok, the second is the TestDataClass

    Imports System.Data.Services.Common
    Imports System.Runtime.Serialization
    Namespace DataClasses
        <Serializable> _
        <DataContract> _
        Public Class TestDataClass
            <DataMember> _
            Public Property Id As Long
            <DataMember> _
            Public Property Firstname As String
            <DataMember> _
            Public Property Lastname As String
        End Class
    End Namespace

    Ok. - The next Thing, I was doing is to create the "returning" information

    Imports System.ServiceModel.Web
    Namespace Proxy
        Public Class TestData
            Implements DataClasses.ITestService
            Public Function ReturnClass() As List(Of DataClasses.TestDataClass) Implements DataClasses.ITestService.ReturnClass
                Dim retList As New List(Of DataClasses.TestDataClass)
                retList.Add(New DataClasses.TestDataClass With {.Firstname = "My", _
     .Id = 2, _
     .Lastname = "Name"})
                Return retList
            End Function
        End Class
    End Namespace

    Ok - So far, as I understood, This should be all correct. (I hope)

    The next, I did was to add a WCF Data Service 5.6 file

    Within this file I changed the code to this:

    Imports System.Data.Services
    Imports System.Data.Services.Common
    Imports System.Linq
    Imports System.ServiceModel.Web
    Public Class DataModelWcf
        Inherits DataService(Of Proxy.TestData)
        ' This method is called only once to initialize service-wide policies.
        Public Shared Sub InitializeService(ByVal config As DataServiceConfiguration)
            config.SetEntitySetAccessRule("*", EntitySetRights.AllRead)
            'config.SetServiceOperationAccessRule("*", ServiceOperationRights.All)
            config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2
        End Sub
    End Class

    OK. - When I now test the Service by clicking on it and run in browser, I get the following:

    <?xml version="1.0" encoding="UTF-8" standalone="true"?>
    -<service xmlns="http://www.w3.org/2007/app" xmlns:app="http://www.w3.org/2007/app" xmlns:atom="http://www.w3.org/2005/Atom" xml:base="http://localhost:1523/DataModelWcf.svc/">

    OK - The Service itself runs. - But I don't get any "Operation". I can't see my failure. - I tested around for the last few days, but I don't have a Clou, what's wrong...

    I also added a Service into the config file (but don't think, that this will make some differences)

          <service name="WCF_Test.Proxy.TestData">
            <endpoint address="" contract="WCF_Test.DataClasses.ITestService" binding="basicHttpBinding"/>  
            <endpoint address="mex" contract="IMetadataExchange" binding="mexHttpBinding"/>
        <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />

    So, thanks for every Little hint to solve this.

    THX - Have  nice Weekend!

    Sunday, April 12, 2015 9:50 AM


All replies