I have a WCF Service which returns an Object-I. The Object-I is an collection of List,String X,List. my WCF service runs without any error and returns it but when i call this in my silverlight application, i can't read this object-I. Please Help Me
//WCF Service Interface
[ServiceContract]
public interface IUserConfiguration
{
[OperationContract]
userlistresponse GetUser();
}
[DataContract]
public class userlist
{
[DataMember]
public string UserID { get; set; }
[DataMember]
public string UserName { get; set; }
[DataMember]
public string Password { get; set; }
[DataMember]
public string User_Type { get; set; }
[DataMember]
public string Salutation { get; set; }
[DataMember]
public string First_Name { get; set; }
[DataMember]
public string Middle_Name { get; set; }
[DataMember]
public string Last_Name { get; set; }
[DataMember]
public int User_Level { get; set; }
[DataMember]
public string Address { get; set; }
[DataMember]
public string City { get; set; }
[DataMember]
public string State { get; set; }
[DataMember]
public string Pincode { get; set; }
[DataMember]
public string Landmark { get; set; }
[DataMember]
public string Landline1 { get; set; }
[DataMember]
public string Landline2 { get; set; }
[DataMember]
public string Landline3 { get; set; }
[DataMember]
public string Mobile { get; set; }
[DataMember]
public string Email { get; set; }
[DataMember]
public string Status { get; set; }
[DataMember]
public string Token { get; set; }
[DataMember]
}
[DataContract]
public class ErrorManager
{
public string Error_ID { get; set; }
public string Field { get; set; }
}
[DataContract]
public class userlistresponse
{
public List<userlist> usersdetails { get; set; }
public bool Flag { get; set; }
public List<ErrorManager> Error { get; set; }
}
//WCF Service Implementation
public userlistresponse GetUser()
{
userlistresponse ErrorUser = new userlistresponse();
try
{
DALUsersDetails DUD = new DALUsersDetails();
return DUD.GetUserDetails();
}
catch (Exception Ex)
{
ErrorUser.Error.Add(new ErrorManager {Error_ID = "SUR0000",Field = Ex.Message.ToString()});
ErrorUser.Flag = false;
}
return ErrorUser;
}
//DATA ACCESS LAYER Just Returns a List From DataBase
Everything works fine here.and the WCF Service can be called in Silverlight application and can use t开发者_运维问答he method.
//Silverlight Application
public Searchuser()
{
InitializeComponent();
UserConfigurationClient UserClient = new UserConfigurationClient();
UserClient.GetUserCompleted += new EventHandler<GetUserCompletedEventArgs>(UserClient_GetUserCompleted);
UserClient.GetUserAsync();
}
void UserClient_GetUserCompleted(object sender, Proto.UserReference.GetUserCompletedEventArgs e)
{
if (e.Result != null)
{
Proto.UserReference.userlistresponse user = new userlistresponse();
user = e.Result;//Its Just Returns a string.
if(user.flag == false)
//Here is the Problem- The Object User[userlistresponse] does not shows or exposes the member inside that object.
{
.......................//some code
}
}
}
If you use [DataContract]
for the class you should iclude [DataMember]
attribute for all properties which you don't want to skip be transfered.
精彩评论