我已经尝试了一切。我看过这里,找不到答案。所以我有一个接口
public interface IUserData
{
ExchangeVersion ExchangeVersion { get; }
string UserName { get; set; }
string EmailAddress { get; set; }
string Domain { get; set; }
string Password { get; set; }
Uri AutodiscoverUrl { get; set; }
Uri ExchangeUrl { get; set; }
}
具体类
[DataContract]
public class UserData : IUserData
{
public ExchangeVersion ExchangeVersion
{
get { return ExchangeVersion.Exchange2010; }
}
[DataMember]
public string EmailAddress
{
get;
set;
}
[DataMember]
public string Domain
{
get;
set;
}
[DataMember]
public string Password
{
get;
set;
}
public Uri AutodiscoverUrl
{
get;
set;
}
public Uri ExchangeUrl
{
get;
set;
}
[DataMember]
public string UserName
{
get;
set;
}
}
我有服务合同
[ServiceContract]
public interface IExchangeServiceWcf
{
[OperationContract]
//[WebInvoke(UriTemplate = "LoginToExchange", Method = "GET")]
[ServiceKnownType(typeof(UserData))]
bool LoginToExchange(IUserData userData);
}
我有一个服务参考,我在我的测试客户端程序中调用它
ServiceReference1.ExchangeServiceWcfClient client = new ServiceReference1.ExchangeServiceWcfClient();
bool rez;
IUserData user = new UserData();
user.UserName = "*****";
user.Password = "******";
user.Domain = "*******";
user.EmailAddress = "*********";
rez = client.LoginToExchange(user);
在 rez 行,出了点问题。我总是遇到异常:尝试序列化参数http://tempuri.org/:userData
时出错有什么问题?
非常感谢:)
答案 0 :(得分:0)
在您的界面上试试这个。
[ServiceContract]
[ServiceKnownType(typeof(UserData))]
public interface IUserData
{
ExchangeVersion ExchangeVersion { get; }
string UserName { get; set; }
string EmailAddress { get; set; }
string Domain { get; set; }
string Password { get; set; }
Uri AutodiscoverUrl { get; set; }
Uri ExchangeUrl { get; set; }
}