11.07.2015 Views

y - Net Developer

y - Net Developer

y - Net Developer

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

amrameshreddy.blog.com72 CHAPTER 3 ■ EXPLORING THE WCF PROGRAMMING MODELramrameshreddy.blog.comListing 3-8. ServiceHost Instantiation Based on Configurationusing System;using System.ServiceModel;using QuickReturns.StockTrading.ExchangeService;using QuickReturns.StockTrading.ExchangeService.Contracts;namespace QuickReturns.StockTrading.ExchangeService.Hosts{class Program{static void Main(string[] args){Type serviceType = typeof(TradeService);ServiceHost host = new ServiceHost(serviceType);host.Open();}}}Console.WriteLine("Service started: Press Return to exit");Console.ReadLine();Listing 3-9 provides the App.config file of the service. You can find the TradeServicedefined with its endpoints. Please note the IMetadataExchange endpoint. You specify thisendpoint in order to allow consumers to retrieve the metadata (WSDL) of the service. If youwant to use either SvcUtil.exe or Add Service Reference in Visual Studio, you need to enablethe retrieval of metadata. The service is referring to a specific behaviorConfiguration calledserviceTypeBehaviors that sets some service-wide settings too. The service-wide settings areas follows:serviceMetadata: This allows you to set whether metadata may be retrieved for the service.You can set some additional attributes such as ExternalMetadataLocation, HttpEnabled,HttpsEnabled, HttpGetUrl, HttpsGetUrl, and MetaDataExporter. These are self-explanatory;please refer to the MSDN Help for more information.serviceDebug: These settings allow you to express whether you want to leak specificservice exception information and helpful HTML information pages for your servicesacross the service boundary. This should be disabled in production scenarios but can behelpful during development. You can set some additional attributes such asHttpHelpPageEnabled, HttpHelpPageUrl, HttpsHelpPageEnabled, HttpsHelpPageUrl, andIncludeExceptionDetailInFaults. These are self-explanatory; please refer to the MSDNHelp for more information.ramrameshreddyramrameshreddyWe have set httpGetEnabled for the metadata and httpHelpPageEnabled andincludeExceptionDetailInFaults because we need these in the remaining part of thissection and the following section.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!