Click here to Skip to main content
14,426,997 members
Rate this:
Please Sign up or sign in to vote.
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)

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 22-Aug-12 0:05am
v2
Rate this:
Please Sign up or sign in to vote.

Solution 1

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.
Rate this:
Please Sign up or sign in to vote.

Solution 2

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
OriginalGriff 5,098
Richard MacCutchan 1,789
phil.o 1,260
Patrice T 1,187
MadMyche 1,060



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