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

How to connect to a wcf service which is in another project.I want to connect to that that service method

This is the method in service

public class UserLoginService : IUserLoginService
{
public bool ValidateUser(CreateUserProfileArg createUserProfileArg)
{
bool Result = false;
// hxUserDTO userLoginArgs = null;
UserLoginArgs userLoginArgs = null;
if (createUserProfileArg != null)
{
// userLoginArgs = new hxUserDTO();
userLoginArgs = new UserLoginArgs();
userLoginArgs.UserId = createUserProfileArg.UserID;
userLoginArgs.Password = createUserProfileArg.Password;
userLoginArgs.UserType = createUserProfileArg.UserType;
userLoginArgs.GroupId = createUserProfileArg.GroupID;
}

Result = UserLoginController.ValidateUserCredentials(userLoginArgs);
return Result;
}


where CreateUserProfileArg is a class with some parameters

I need to call that method in my windows phone login page and that should return a Boolean value


How can I do it?
Posted

1 solution

Deploy the service in IIS and add reference to that service and then create a client object and call required methods.
Refer this link
consuming-wcf-service-in-windows-phone-application/
 
Share this answer
 
Comments
Member 8557048 9-Jan-14 22:18pm    
Yes I have added the service reference,but I cannot able to pass class object as an argument for this method.
Naz_Firdouse 10-Jan-14 0:42am    
can you post you code? How you are calling the service method at client side?
Member 8557048 10-Jan-14 1:56am    
I added the service reference
myHealthInfoWPhone.ServiceReference1.UserLoginServiceClient proxy = new myHealthInfoWPhone.ServiceReference1.UserLoginServiceClient();

and this is the service method
public class UserLoginService : IUserLoginService
{
public bool ValidateUser(CreateUserProfileArg createUserProfileArg)
{
bool Result = false;
// hxUserDTO userLoginArgs = null;
UserLoginArgs userLoginArgs = null;
if (createUserProfileArg != null)
{
// userLoginArgs = new hxUserDTO();
userLoginArgs = new UserLoginArgs();
userLoginArgs.UserId = createUserProfileArg.UserID;
userLoginArgs.Password = createUserProfileArg.Password;
userLoginArgs.UserType = createUserProfileArg.UserType;
userLoginArgs.GroupId = createUserProfileArg.GroupID;
}
Result = UserLoginController.ValidateUserCredentials(userLoginArgs);
return Result;
}
and when calling this method I am passing argument as class file which is declared in phone project
This is the class in service
[Serializable]
[DataServiceKey("PartitionKey", "RowKey")]
public class UserLoginArgs : hxTableEntity
{
public string Unique_ID;
public string UserId { get; set; }
public string Password { get; set; }
public ActorType UserType { get; set; }
public string GroupId { get; set; }
}

public enum ActorType
{
Call_Center = 0,
Patient = 1,
Doctor = 2
}

This is the code in windows phone
var loginArgs = new UserLoginArgs();

loginArgs.UserID = "";
loginArgs.Password = "";
loginArgs.UserType = myHealthInfoWPhone.Class_Files.ActorType.Doctor;
loginArgs.GroupID = "2";
myHealthInfoWPhone.ServiceReference1.UserLoginServiceClient proxy = new myHealthInfoWPhone.ServiceReference1.UserLoginServiceClient();

and I am unable to send that class name
Naz_Firdouse 10-Jan-14 2:10am    
Your service method expects an object of type CreateUserProfileArg
so create an object of that type at the client side instead of UserLoginArgs or else change the param type at service side so that both matches.


var loginArgs = new CreateUserProfileArg ();

loginArgs.UserID = "";
loginArgs.Password = "";
loginArgs.UserType = myHealthInfoWPhone.Class_Files.ActorType.Doctor;
loginArgs.GroupID = "2";
myHealthInfoWPhone.ServiceReference1.UserLoginServiceClient proxy = new myHealthInfoWPhone.ServiceReference1.UserLoginServiceClient();
proxy.ValidateUser(loginArgs );


Member 8557048 10-Jan-14 2:25am    
Yeah I did the same thing and call the method and passing the class instance as the argument

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



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