You are creating a Windows Communication Foundation (WCF) service that implements operations in a RESTful manner.
You need to add a delete operation. You implement the delete method as follows:
void DeleteItems(string id);
You need to configure WCF to call this method when the client calls the service with the HTTP DELETE operation. What should you do?
A.
Add the WebInvoke(UriTemplate=”/Items/{id}”, Method=”DELETE”) attribute to the operation
B.
Add the HttpDelete atribute to the operation
C.
Replace the string parameter with a RemovedActivityAction parameter
D.
Replace the return type with RemovedActivityAction.
Explanation:
Advanced Web Programming
(http://msdn.microsoft.com/en-us/library/bb472541(v=vs.90).aspx)Example:
[ServiceContract]
public interface ICustomerCollection
{
[OperationContract]
[WebInvoke(Method = “POST”, UriTemplate = “”)]
Customer AddCustomer(Customer customer);[OperationContract]
[WebInvoke(Method = “DELETE”, UriTemplate = “{id}”)]
void DeleteCustomer(string id);[OperationContract]
[WebGet(UriTemplate = “{id}”)]
Customer GetCustomer(string id);[OperationContract]
[WebGet(UriTemplate = “”)]
List<Customer> GetCustomers();[OperationContract]
[WebInvoke(Method = “PUT”, UriTemplate = “{id}”)]
Customer UpdateCustomer(string id, Customer newCustomer);
}