0
Answer

Not all Datacontract class appearing on client

Roy Keane

Roy Keane

14y
2.5k
1
Hello Experts,

I have just create my first WCF service and not surprisingly ran into some trouble. I Cannot see class "FaultException" on client but can see class "Composite Type"

By default whenever i create a new WCF application .net adds its default service to it which has a data contract called "Composite type". Now i have added another datacontract class in it but when i build it and update my client reference i cannot see this new data contract class on my client. althoug i can see composite type data contract.


Please advise. I am posting the code below


Imports System.Runtime.Serialization

<ServiceContract()> _
Public Interface IDocumentService

    <OperationContract()> _
    <FaultContract(GetType(FaultException))> _
      Function GetDocument(ByVal data As CompositeType) As Byte()

    <OperationContract()> _
    <FaultContract(GetType(FaultException))> _
    Function HelloWorld() As String

End Interface

<DataContract()> _
Public Class FaultException
    'This will carry any message that i will be hard coding in the code
    Private _customErrorMessage As String = String.Empty
    'This will carry the asp.net error which is generated from exception class
    Private _exceptionErrorMessage As String = String.Empty


    <DataMember()> _
    Public Property CustomErrorMessage() As String
        Get
            Return Me._customErrorMessage
        End Get
        Set(ByVal value As String)
            Me._customErrorMessage = value
        End Set
    End Property


    <DataMember()> _
    Public Property SystemException() As String
        Get
            Return Me._exceptionErrorMessage
        End Get
        Set(ByVal value As String)
            Me._exceptionErrorMessage = value
        End Set
    End Property

End Class

<DataContract()> _
Public Class CompositeType

    Private _docID As String = String.Empty
    Private _authKeySentByClient As String = String.Empty
    Private _authKey As String = System.Configuration.ConfigurationSettings.AppSettings("eDocsSecurekey").ToString()
    Dim fault As New FaultException()

    <DataMember(IsRequired:=True)> _
    Public Property DocumentID() As String
        Get
            Return Me._docID
        End Get
        Set(ByVal value As String)
            Me._docID = value
        End Set
    End Property

    <DataMember(IsRequired:=True)> _
    Public Property AuthenticationKeyByClient() As String
        Get
            Return Me._authKeySentByClient
        End Get
        Set(ByVal value As String)
            Try
                fault.CustomErrorMessage = "Invalid Authentication Key"
                If Not value = Me._authKey Then
                    Throw New FaultException(Of FaultException)(fault)
                Else
                    Me._authKeySentByClient = value
                End If
            Catch ex As Exception
                fault.SystemException = ex.Message.ToString()
                Throw New FaultException(Of FaultException)(fault)
            End Try
        End Set
    End Property
End Class


Massive thanks
Next Recommended Forum