A class named TestService implements the following interface. [ServiceContract] public
interface lTestService { [OperationContract] DateTime GetServiceTime; } TestService is
hosted in an ASP.NET application. You need to modify the application to allow the
GetServiceTime method to return the data formatted as JSON. It must do this only when the
request URL ends in /ServiceTime. What should you do?
A.
Add this attribute to the GetServiceTime method [WebGet( ResponseFormat=
WebMessageFormat.Json, UriTemplatee=”/ServiceTime”)] Create a new svc file named
JsonVersion.svc with the following content. <%@ ServiceHostService”TestService’
Factorye=“System.ServiceMode.ActivationWebServiceHostFactory” %>
B.
Add this attribute to the GetServiceTime method. [WebGet(UriTemplate =
(Uson)/ServiceTime”)] Create a new .svc file named Jsonversion svc with the following
content <%@ServiceHostServicee”TestService” Factory=”System
ServiceModel.ActivationWebServiceHostFactory” %>
C.
Add this attribute to the GetServiceTime method. [WebInvoke(Method = “GET’,
UriTemplate “/ServiceTime”, ResponseFormat = WebMessageFormat.Json)] In the
web.config file, configure TestService in the system.serviceModel/services collection as
follows. <service namez“TestService”> <endpoint address=”/ServiceTime”
contract=”TestService” bindinge”webHttpBinding” /> </service>
D.
Add this attribute to the GetServiceTime method. [Weblnvoke(MetMode”POST”)] In the
web.config file, add this element to system.serviceModel/behaviors/endpointBehaviors.
<behavior namee”Json”> <enableWebScript/> </behavior> In the web.config file, configure
TestService in the system.serviceModel/services collection as follows <service
namez“TestService”> <endpoint address”/ServiceTime” contracts“TestService”
behaviorConfiguration=”Json” bindingz”webHttpBinding”/> </service>