The following is the interface that you want define.
[ServiceContract]
public interface IMyServiceContract
...{
[OperationContract]
string GetData(int value);
[OperationContract]
CompositeType GetDataUsingDataContract(CompositeType composite);
// TODO: Add your service operations here
}Now this is the consistent class for this interface.
public class Service1 : IMyServiceContract
...{
public string GetData(int value)
...{
return string.Format("You entered: {0}", value);
}
public CompositeType GetDataUsingDataContract(CompositeType composite)
...{
if (composite.BoolValue)
...{
composite.StringValue += "Suffix";
}
return composite;
}
}
本文定义了一个WCF服务接口IMyServiceContract,并提供了一致的Service1类实现该接口。服务包括两个操作:获取输入整数的字符串形式及使用数据契约进行数据处理。
1万+





