我有一个 wcf 服务,它公开了一个返回复杂类型作为其返回类型的函数。该响应类型又包含我定义的另一个复杂对象。我正在为我的 WCF 创建数据合同,并且想知道应该如何完成。我目前有这个(为了便于阅读,删除了一些属性):
功能
///<summary>
/// Interface to describe a cluster query WCF service.
///</summary>
[ServiceContract]
public interface IClusterQueryWcfService
{
/// <summary>
/// A method to retrieve the name of the necessary cluster table for a given zoom level, feature type and user type.
/// </summary>
/// <param name="zoom">Integer value representing zoom level</param>
/// <param name="featureType">The feature type string</param>
/// <param name="user">User name</param>
/// <returns>RwolTableType made up of table name and table type.(See documentation)</returns>
[OperationContract]
TableTypeResponse GetClusterTableForZoom(int zoom, string featureType, string user);
响应类型
/// <summary>
/// The data contract for a TableTypeResponse object
/// </summary>
[DataContract]
public class TableTypeResponse
{
/// <summary>
/// Property to manipulate the date and time of the method call.
/// </summary>
[DataMember]
public string DateTimeOfCall
{
get;
set;
}
/// <summary>
/// Property to get/set the StandardResponse type object included with a TableTypeResponse instance.
/// </summary>
[DataMember]
public StandardResponseType StandardResponse
{
get;
set;
}
}
嵌套类型
/// <summary>
/// Data contract for a StandardResponseType object
/// </summary>
[DataContract]
public class StandardResponseType
{
/// <summary>
/// Property to manipulate the date and time of the method call.
/// </summary>
[DataMember]
public string DateTimeOfCall
{
get;
set;
}
/// <summary>
/// Property to allow get and set of a message to provide more information to the user.
/// </summary>
[DataMember]
public string Message
{
get;
set;
}
}
此代码是否足以确保调用客户端知道初始响应类型中保存的标准响应类型的结构?我的意思是嵌套类型的数据契约实际上会被观察到吗?
我应该补充一点,我对使用数据合同还很陌生,因为我以前知道我有 .net 双方。