Exchange a DataContract between HOST and CLIENT - WCF

Hi,

I have a service method like below:

Interface
=======

<OperationContract()> _
Function AddFunc(ByVal value1 As Integer, ByVal value2 As Integer) As Integer

Person.vb
========

<DataContract()> _
Public Class Person
    Private UserNameStr As String
    Private PasswordStr As String
    <DataMember()> _
    Public Property UserName() As String
        Get
            Return UserNameStr
        End Get
        Set(ByVal value As String)
            UserNameStr = value
        End Set
    End Property
    <DataMember()> _
    Public Property Password() As String
        Get
            Return PasswordStr
        End Get
        Set(ByVal value As String)
            PasswordStr = value
        End Set
    End Property
End Class

Implementation
============

Public Function AddFunc(ByVal value1 As Integer, ByVal value2 As Integer) As Integer Implements IAdd.AddFunc
          AddFunc = value1 + value2
          ' Accessing the PERSON object here
End Function

So my PERSON object is neither parameter to "AddFunc" function nor its return type. But I want this object to be available on CLIENT side when PROXY (AddProxy) was created. I am getting PROXY by adding service reference. Let me know is there any way that i can access this object at client side !

CLIENT
======

Sub Main()
        Using client As New AddProxy.AddClient
            Dim objPerson As New AddProxy.Person  'Error here (I cannot access Person class here as AddProxy.Person is NOT available)
            objPerson.UserName = "Mike"
            objPerson.Password = "Sam"
        End Using
End Sub

Thanks
milani_lucieAsked:
Who is Participating?
 
CodeCruiserCommented:
One option is to add a third dummy parameter of type person. You can make the parameter optional so your existing code would not need changing.

Another option is to add the parameter, generate the proxies and then remove the parameter and change proxy class manually.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.