假设我有这个简单的合同,我从 MS 示例中获取并进行了一些修改:
[ServiceContract(SessionMode = SessionMode.Allowed)]
public interface IService
{
[WebInvoke(Method = "POST", UriTemplate = "", ResponseFormat = WebMessageFormat.Xml,
RequestFormat = WebMessageFormat.Xml),
Description(
"Adds a customer to customers collection. The response Location header contains a URL to the added item.")]
[OperationContract]
Customer AddCustomer(Customer customer);
[WebInvoke(Method = "DELETE", UriTemplate = "{id}"),
Description(
"Deletes the specified customer from customers collection. Returns NotFound if there is no such customer.")
]
[OperationContract]
void DeleteCustomer(string id);
[WebGet(UriTemplate = "{id}"),
Description(
"Returns the specified customer from customers collection. Returns NotFo`enter code here`und if there is no such customer.")
]
[OperationContract]
Customer GetCustomer(string id);
[WebGet(UriTemplate = ""), Description("Returns all the customers in the customers collection.")]
[OperationContract]
List<Customer> GetCustomers();
[WebInvoke(Method = "PUT", UriTemplate = "{id}"),
Description("Updates the specified customer. Returns NotFound if there is no such customer.")]
[OperationContract]
Customer UpdateCustomer(string id, Customer newCustomer);
}
我需要这份合同通过 webhttp REST 和 nettcp 绑定(带有会话)公开。
我的案例(合同)要困难得多,所以我需要了解是否为两种目的都有一个实现,并以某种方式区分 webhttpbinding 调用或 nettcpbinding 调用,或者为每个端点提供不同的实现。
提前致谢