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バインディング(セッションを使用)を介して公開するには、このコントラクトが必要です。
私のケース(契約)ははるかに難しいので、両方の目的で1つの実装を使用するかどうかを理解し、webhttpbinding呼び出しとnettcpbinding呼び出しを何らかの方法で区別するか、エンドポイントごとに異なる実現を提供する必要があります。
前もって感謝します