Click here to Skip to main content
15,032,967 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I am new to WCF. I wanted to created a simple desktop login application that connects to WCF service [Service is used to connect to SQL server and get requires data using Linq to Entities] and verifies wheather user existed or not. I have following the following things.

1) Created a WCF service with 1 function Named GetUserDetails(sting userName)

C#
public List<AuthenticationModel> GetUserDetails(string UserName)
        {

            RiverEntity RiverEntity = new RiverEntity();

            List<AuthenticationModel> users = (from p in RiverEntity.Users
                                               where p.UserName == UserName
                                               select new AuthenticationModel
                                               {
                                                   UID = (int) p.UID,
                                                   ULastName = p.ULName,
                                                   UFirstName = p.UFName,
                                                   UMiddleName = p.UMName,
                                                   UserDMID = p.UserDMID,
                                                   UserName = p.UserName,
                                                   Password = p.Pass,
                                                   Active = (bool) p.Active,
                                                   Role = (int) p.Role,
                                                   Practices = p.Practices,
                                                   RegisteredEmail= p.RegisteredEmail,
                                                   DynaIP = p.DynaIP,
                                                   LoggedInStatus = p.loggedInStatus,
                                                   AppID = p.AppID,
                                                   ResetPass = (bool) p.ResetPass
                                               }).ToList<AuthenticationModel>();

            return users;
        }



2) Added Linq to Entities for my DB

3) Created WPF application and added the service reference to my WPF client application.

By Using WCF test client i am able to get user details from Data base.

Now i wanted to do this from WPF. Can anybody explain me how to create proxy, call the above mentioned function and stores the retrived values into the WPF end properties.

Thanks in advance.

chowdary.
Posted
Updated 21-Aug-12 23:05pm
v2

Its pretty easy.
Since you have added service reference, you see the name of the reference, like ServiceReference1 (by default).
Then to use call the method, you need to create client object, i.e.
ServiceReference1Client clientObj = new ServiceReference1Client();

and then
var result = clientObj.GetUserDetails("your parameter");

Now, you can directly bind it to any object which takes the collection.
   
Comments
chowdary2005 22-Aug-12 3:11am
   
Hello Pramodh,

Thanks for the quick response. My service name is ThreeServiceRef which i have added.

I have added code like the following in command

ThreeServiceRef Clientobj = new ThreeServiceRef();

then it is showing error as

ThreeserviceRef is a 'namespace' which is used like 'type'

Kindly suggest.

chowdary.
pramod.hegde 22-Aug-12 3:20am
   
Off course it is a namespace. You can look into this namespace, where you find ThreeServiceRefClient class. Create the object of ThreeServiceRefClient class instead of ThreeServiceRef.
C#
ThreeServiceRef.YourClass obj = new ThreeServiceRef.YourClass();
var result = clientObj.GetUserDetails("your parameter");
   

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900