You are creating a Windows Communication Foundation service by using Microsoft .NET Framework 3.5. You write the following code segment. (Line numbers are included for reference only.)
01 Uri baseAddress=
02 new Uri (?http://localhost:8000/ExamService?);
03 Uri mexAddress=new Uri(“”);
04 ServiceHost serviceHost=new ServiceHost(typeof( 05 ExamService), baseAddress);
06 ServiceMetadataBehavior smb=
07 serviceHost.Description.Behaviors.
08 Find<ServiceMetadataBehavior>();
09 if (smb != null)
10 {
12 }
13 else
14 {
15 smb=new ServiceMetadataBehavior();
16 serviceHost.Description.Behaviors.Add(smb);
17 }
18 smb.HttpGetUrl=mexAddress;
When you browse to the base address of the service, you receive the following message:
“Metadata publishing for this service is currently disabled.” You debug the code and discover that the ServiceMetadataBehavior behavior was previously nonexistent. You need to enable metadata publishing. What should you do?
A.
Delete lines 15 and 16.
B.
Modify the code segment at line 03 in the following manner.
Uri mexAddress=new Uri(“/service”);
C.
Insert the following code segment at line 11.
smb.HttpGetEnabled=true;
D.
Insert the following code segment at line 19.
smb.HttpGetEnabled=true;
Explanation:
The typical error message you receive if HttpGetEnabled is not set to true is “Metadata publishing for this service is currently disabled.”. Therefore, setting this value to true either in the Web.config file or programmatically should resolve this error as is indicated in answer choice D.