nerdexam
Microsoft

70-513 · Question #297

A Windows Communication Foundation (WCF) solution uses the following contract to share a message across its clients. (Line numbers are included for reference only.) 01 [ServiceContract] 02 public…

The correct answer is A. Add the following attribute to the TeamMessageService class, before line 10. See the full explanation below for the reasoning.

Question

A Windows Communication Foundation (WCF) solution uses the following contract to share a message across its clients. (Line numbers are included for reference only.) 01 [ServiceContract] 02 public interface ITeamMessageService 03 { 04 [OperationContract] 05 string GetMessage0; 07 [OperationContract] 08 void PutMessage(string message); 09) The code for the service class is as follows 10 public class TeamMessageService: ITeamMessageService 11 { 12 Guid key = GuicLNewGuidO; 13 string message = "Today's Message":

14 public string GetMessage() 15 { 16 return stringFormat("Message:{0} Key:{1}", message, Key); 17 19 public void PutMessage(string message) 20 { 21 thismessage = message; 22 } 23 ) The senvice is self-hosted. The hosting code is as follows. 24 ServiceHost host = 25 BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecuntyMode.None):

26 host AddServiceEndpoint( HMyApplication lTeamMessageService, binding, "http:/Ilocalhost: 12345w); 27 host Open0;) You need to ensure that all clients calling GetMessage will retrieve the same string, even if the message is updated by clients calling PutMessage What should you do?

Options

  • AAdd the following attribute to the TeamMessageService class, before line 10.
  • BAdd the following attribute to the TeamMessageService class, before line 10.
  • CPass a service instance to the instancing code in line 24, as follows.
  • DRedefine the message string in line 13, as follows

How the community answered

(47 responses)
  • A
    70% (33)
  • B
    9% (4)
  • C
    4% (2)
  • D
    17% (8)

Community Discussion

No community discussion yet for this question.

Full 70-513 Practice