我有公開返回一個複雜類型作爲它的返回類型的函數WCF服務中構建一種DataContracts。這個響應類型又包含另一個由我定義的複雜對象。我正在爲我的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兩側。
你爲什麼不嘗試一下通過創建一個測試客戶端? – decyclone 2012-08-16 15:06:13