PrepAway - Latest Free Exam Questions & Answers

Which code segment should you insert at line 04?

You are developing a Windows Communication Foundation (WCF) REST service to provide access to a library book catalog.
The following code segment defines the service contract. (Line numbers are included for reference only.)

01 [ServiceContract()]
02 [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
03 public Class LibraryService
04 {
05 public Book GetBookByTitle(string title)
06 {
07 …
08 }
09
10 [WebGet(UriTemplate = “Book/{id}”)]
11 public Book GetBookById(string id)
12 {
13 …
14 }
15 }

Library patrons want the ability to search the catalog by title.
You need to ensure that the GetBookByTitle method is exposed as a service method.
Which code segment should you insert at line 04?

PrepAway - Latest Free Exam Questions & Answers

A.
[WebGet(UriTemplate = “Book/{title}”)]

B.
[WebGet(UriTemplate = “BookByTitle/{title}”)]

C.
[WebGet(UriTemplate = “Book/{titleToSearch}”)]

D.
[WebGet(UriTemplate = “{titleToSearch}”)]

Explanation:
AspNetCompatibilityRequirementsAttribute Class
Applied to a service to indicate whether that service can be run in ASP.NET compatibility code.

AspNetCompatibilityRequirementsMode Enumeration
Specifies whether a service runs, or can run, in a mode that is compatible with ASP.NET.
NotAllowed services must run in an application domain with ASP.NET compatibility mode set to false.
Allowed services can run in an application domain with ASP.NET compatibility mode set to true or false.
Required services must run in an application domain with ASP.NET compatibility mode set to true.

AspNetCompatibilityRequirementsMode Enumeration
(http://msdn.microsoft.com/en-us/library/system.servicemodel.activation.aspnetcompatibilityrequirementsmode.aspx)

One Comment on “Which code segment should you insert at line 04?


Leave a Reply