/* SERVICE CONTRACT */
[ServiceContract]
public interface IEntity
{
[OperationContract]
CustomerDetail GetCustomer(string entityID);
//string GetCustomer(string entityID);
[OperationContract]
List<CustomerDetail> GetCustomerList(List<string> entityIDList);
}
/* DATA CONTRACT */
[DataContract]
public class CustomerDetail
{
[DataMember]
public Customer customerDetail; //Customer is defined in the webservice i'm calling
}
/* Actual service contract implementation */
public CustomerDetail GetCustomer(string ID)
{
ThirdParty tpws = new ThirdParty();
var c = tpws.GetCustomerByCustomerID(ID);
CustomerDetail cd = new CustomerDetail();
999 cd.customerDetail = c[0];
return cd;
}
当我在VS2010中使用断点在上面标记为999的行上运行时,一切正常但返回无法在WCF测试客户端中显示任何内容 - 返回和错误 - 接收HTTP响应时发生错误。 。
答案 0 :(得分:0)
这只是猜测,但在“999”行之前停在调试器中并查看c
中的内容。我敢打赌c.Length == 0
。
答案 1 :(得分:0)
您是否已验证“客户”类型是否可序列化(是否使用DataContractAttribute,SerializableAttribute或类似文件修饰)?