A Windows Communication Foundation (WCF) service uses the following service contract.
[ServiceContract]
public interface IService
{
[OperationContract]
string Operation1(string s);
}
You need to ensure that the operation contract Operation1 responds to HTTP POST requests.
Which code segment should you use?
A.
[OperationContract]
[WebInvoke(Method=”POST”)]
string Operation1(string s);
B.
[OperationContract]
[WebGet(UriTemplate=”POST”)]
string Operation1(string s);
C.
[OperationContract(ReplyAction=”POST”)]
string Operation1(string s);
D.
[OperationContract(Action=”POST”)]
string Operation1(string s);
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);
}
A