Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Exchange a DataContract between HOST and CLIENT - WCF

Posted on 2011-10-05
1
Medium Priority
?
287 Views
Last Modified: 2012-05-12
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
0
Comment
Question by:milani_lucie
1 Comment
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 2000 total points
ID: 36921209
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
While working on Silverlight and WCF application, I faced one issue where fault exception occurred at WCF operation contract is not getting propagated to Silverlight client. So after searching net I came to know that it was behavior by default for s…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question