11.07.2015 Views

y - Net Developer

y - Net Developer

y - Net Developer

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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

CHAPTER 5 ■ HOSTING AND CONSUMING WCF SERVICES 177ramrameshreddy.blog.comgenerates are the client proxy source code file and the application configuration file. Thesefiles are then merged into the client project. The SvcUtil.exe can generate both. For thisexample, the following command (it is all a single line despite what’s shown here) producesboth a proxy class and a configuration file:svcutil /config:app.config /out:"ExchangeService.cs" /language:csharp /n:*,SimpleClientWithProxy.ExchangeService "http://localhost/ExchangeService/➥ExchangeService.svc"■Caution For this to work, you need a running version of the Windows ServiceHost, or you have to changethe URL to point to any of the services hosted in IIS (a URL pointing to any of the .svc files discussed in thischapter). In addition, your service requires the metadataexchange endpoint, as described in Chapter 3. Thecode that comes with this chapter has the metadataexchange endpoint configured, but it is left out of theinline code in this chapter!The command is fairly self-explanatory. The /n switch indicates under which namespacethe generated proxy class should fall. The last parameter is the URL of the service endpointwhere schema information can be found. Note that the ?wsdl can be replaced by ?mex becauseSvcUtil.exe supports both methods of discovery. Further help is available by executingsvcutil.exe /? from the command prompt.The next step is to take the output files ExchangeService.cs and App.config and mergethem into the project. You can just add the first file, ExchangeService.cs, directly to the projectby choosing Add Existing Item from the Project menu in Visual Studio 2005.You need to add the second file as an application configuration (App.config) file to theproject. If the project does not already have an App.config file, you can add it by again choosingAdd Existing Item from the Project menu. If there is already an existing App.config, youneed to merge the section system.serviceModel, ensuring you take all the appropriate childelements.SummaryNow you know all about your alternatives in terms of hosting, you are able to build WCF applicationsand host them anywhere you like. In addition, you are now able to explain the benefitsof hosting in the most recent environment available, IIS 7.0 on Windows Vista or WindowsServer 2007 in combination with WAS. In the next chapter, you will learn about managing WCFservices. Of course, IIS 7.0 comes with several manageability features, but to gain insight intoWCF specifics that IIS 7.0 doesn’t know about, the next chapter will dive into this importanttopic. More advanced management features are required and delivered by WCF.ramrameshreddyramrameshreddy

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

Saved successfully!

Ooh no, something went wrong!