nerdexam
Microsoft

70-513 · Question #327

A Windows Communication Foundation (WCF) service implements the following contract. [ServiceContract] public interface IHelloService { [OperationContract(WebGet(UriTemplate="hello?name={name}"))]…

The correct answer is A. WebServiceHost svcHost = new WebServiceHost(typeof(HelloService)). See the full explanation below for the reasoning.

Question

A Windows Communication Foundation (WCF) service implements the following contract. [ServiceContract] public interface IHelloService { [OperationContract(WebGet(UriTemplate="hello?name={name}"))] string SayHello(string name); } The implementation is as follows:

public class HelloService: IHelloService { public string SayHello(string name) { return "Hello " + name; } } The service is self-hosted, and the hosting code is as follows:

WebServiceHost svcHost = CreateHost(); svcHost.Open(); Console.ReadLine(); svcHost.Close(); You need to implement CreateHost so that the service has a single endpoint hosted at Which code segment should you use?

Options

  • AWebServiceHost svcHost = new WebServiceHost(typeof(HelloService));
  • CWebServiceHost svcHost = new WebServiceHost(new HelloService());

How the community answered

(54 responses)
  • A
    78% (42)
  • C
    22% (12)

Community Discussion

No community discussion yet for this question.

Full 70-513 Practice