Click here to Skip to main content
13,000,636 members (55,825 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hello everyone,

first of all I am new to WCF. That is the basic problem to my problem, I know!

I want to make a call to my WCF service and in that works OK.
What I want is that each call to the Service contains a filled LoginUser object.

    public class LoginUser
        public string UserName { get; set; }
        public string Password { get; set; }

In my Interface I state:
BLL.LoginUser LoginUser { [OperationContract] get; [OperationContract]set; }

In my service class I have:
public BLL.LoginUser LoginUser { [OperationBehavior]get; [OperationBehavior]set; }

In the client I get 2 methods (get_LoginUser() ans set_LoginUser()) but I want to see a property.

I tested with these methods and I can set the values for UserName and Password with the method, but when calling the next method my Loginuser object is NULL again.

That is why I want to have a property to set and that in the next call the LoginUser object still has the data.

I do not want to add the object of LoginUser as a parameter in the WCF call or is that the only option?

I instantiate my call to the service as:
srPersonal.IStatistics sc = new srPersonal.StatisticsClient();

I then want to do a
srPersonal.BLL.LoginUser lu = new srPersonal.BLL.LoginUser();
lu.UserName = "hi";
lu.Password = "*****";
sc.LoginUser = lu;
var result = sc.GetMyData();

What do I have to change?
Posted 24-Aug-12 4:01am
Updated 24-Aug-12 4:05am
Himanshu Yadav 28-Aug-12 1:24am
Update yr service by right clicking on service.and u will get the property.
digimanus 28-Aug-12 15:00pm
thank you, it works now 28-Aug-12 21:10pm
thanks, it's my problem too.
digimanus 28-Aug-12 15:18pm
thanks for your information. Will read it

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

WCF don't allow properties on interfaces. The 'get' and 'set' will work as a methods, but not as a property.

In your case, this will work:
ServiceReference1.IService1 proxy = new ServiceReference1.Service1Client();
ServiceReference1.LoginUser lu =
    new ServiceReference1.LoginUser() { UserName = "hi", Password = "****" };
var result = proxy.get_UserLogin();

You could do a regular basic authentication. It is some work, but it is a better way to handle user name and passwords.
RaisKazi 28-Aug-12 16:37pm
Nice troubleshoot and solution. My 5!
Wonde Tadesse 28-Aug-12 21:19pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170624.1 | Last Updated 28 Aug 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100