Question 6


Question

Drag and Drop
You are developing a self-hosted WCF service that returns stock market information. The service must be discoverable by any client application. You need to build the service host. How should you build the host? (To answer, drag the appropriate code segments to the correct location or locations in the answer area. Each code segment may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.)

  • UdpDiscoveryEndpoint
  • DiscoveryEndpoint
  • ServiceBehaviorAttribute
  • ServiceDiscoveryBehavior
  • ServiceHost
  • ServiceHost
static void Main(string[] args)
{
Uri StockURI = new Uri("http://localhost:8733/StockTicker")
var mytype = typeof(StockTickerService);
using (
    host = new
      (mytype,StockURI))
      {
      host.AddServiceEndpoint(typeof(IStockTickerService), new WSHttpBinding(),"");
      host.Description.Behaviors.Add(new
        ());
        host.AddServiceEndpoint(new
          ());
          host.Open();
          Console.ReadLine();
          host.Close();
          }
          }

          Answer:

          • UdpDiscoveryEndpoint
          • ServiceBehaviorAttribute
          static void Main(string[] args)
          {
          Uri StockURI = new Uri("http://localhost:8733/StockTicker")
          var mytype = typeof(StockTickerService);
          using (
          • ServiceHost
          host = new
          • ServiceHost
          (mytype,StockURI))
          {
          host.AddServiceEndpoint(typeof(IStockTickerService), new WSHttpBinding(),"");
          host.Description.Behaviors.Add(new
          • ServiceDiscoveryBehavior
          ());
          host.AddServiceEndpoint(new
          • DiscoveryEndpoint
          ());
          host.Open();
          Console.ReadLine();
          host.Close();
          }
          }