问题是当 wcf 服务向客户端发送类对象列表时,这些值为空。任何帮助或指导表示赞赏。
我的服务接口是
IPswdService.cs
namespace GetPasswordsSvc
{
[ServiceContract]
public interface IPswdService
{
[OperationContract]
List<dbVal> GetData(int value);
}
[DataContract]
public class dbVal
{
public string Group;
public string Title;
public string Username;
} ;
}
GetPasswords.svc.cs
namespace GetPasswordsSvc
{
public class PswdService : IPswdService
{
public List<dbVal> GetData(int value)
{
List<dbVal> kpdata= (from entry in db.RootGroup.GetEntries(true)
select new dbVal
{
Group = entry.ParentGroup.Name,
Title = entry.Strings.ReadSafe("Title"),
Username = entry.Strings.ReadSafe("UserName"),
}).ToList();
List<dbVal> l = kpdata.ToList();
return l;
}
=======================================
WCF 客户端代码
SvcRef.PswdServiceClient wcfClient = new SvcRef.PswdServiceClient();
wcfClient.Open();
List<GetPasswords.dbVal> dbValues = wcfClient.GetData(0);
===============================================
客户端配置文件是
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IPswdService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://xxxxxxx:444/GetPasswords.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IPswdService" contract="SvcRef.IPswdService"
name="BasicHttpBinding_IPswdService" />
</client>
</system.serviceModel>