News:

SQL Table To C# Entity Model ConverterEntity Model (Class Properties) to SQL Table ConverterIf you encounter any trouble visiting our site, please contact us.

Advertisement

Looking for job. Try JobLoader- First ever job search engine in Bangladesh. All open bd jobs now a single mouse click away.

;
[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 http://localhost:8000/HelloService. Which code segment should you use?

  1. WebServiceHost svcHost = new WebServiceHost(typeof(HelloService)); 
    svcHost.AddServiceEndpoint(typeof(IHelloService), new WebHttpBinding(WebHttpSecurityMode.None), "http://localhost:8000/HelloService");
    return svcHost;
  2. Uri baseAddress = new Uri("http://localhost:8000"); 
    WebServiceHost svcHost = new WebServiceHost(typeof(HelloService), baseAddress);
    svcHostAddServiceEndpoint(typeof(IHelloService), new WebHttpBinding(WebHttpSecurityMode.None), "HelloService");
    return svcHost;
  3. WebServiceHost svcHost = new WebServiceHost(new HelloService()); 
    svcHost.AddServiceEndpoint(typeof(IHelloService), new WebHttpBinding(WebHttpSecurityMode.None), "http://localhost:8000/HelloService");
    retumn svcHost;
  4. Uri baseAddress = new Uri("http //localhost 8000/"); 
    WebServiceHost svcHost = new WebServiceHost(new HelloService(), baseAddress); svcHost.AddServiceEndpoint(typeof(IHelloService), new WebHttpBinding(WebHttpSecurityMode.None), "HelloService");
    retumn svcHost;
Answer: Answer is d
Further Reading:

Eliminate A and C, because there is no overload for WebServiceHost constructor that takes only one argument. Choose D over B because of the need of a single endpoint. D provides a singleton instance.Useful resources, WebServiceHost Constructor, WebServiceHost.AddServiceEndpoint

comments powered by Disqus
Advertisement

BCS Preparation now even more easy. ReadBD is the place where you can find all kind of resources to be successful in BCS,Bank,Islami Bank exam and interview.

Looking for job. Try JobLoader- First ever job search engine in Bangladesh. All open bd jobs now a single mouse click away.

;