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 3 ■ EXPLORING THE WCF PROGRAMMING MODEL 79ramrameshreddy.blog.comListing 3-12. The App.config File for the Client CodeThere is an easier way to consume services without using the ChannelFactory. You cangenerate the proxies using the SvcUtil.exe utility. The SvcUtil.exe utility retrieves the metadata(WSDL) of the service, and based on that it will generate the proxy classes that can beused to call the service. In addition, it will make sure the contracts are generated as interfacesas well. Therefore, you can leave out the service contract and data contract you saw in Listing3-11. The following call to SvcUtil.exe generates a proxy class for use in your client (makesure your service is running):svcutil.exe http://localhost:8080/QuickReturnsThe utility will generate a proxy class based on the metadata of the service, which can beretrieved with the following URL:http://localhost:8080/QuickReturns?WSDLThe utility will generate a proxy class for you (the file will be named TradeService.cs, andthe configuration file is called Output.config). You can then simplify the client as shown inListing 3-13. Listing 3-14 shows the generated Output.config configuration file.Listing 3-13. Simplified Client Code Using the Proxy Generated by SvcUtil.exeusing System;using quickReturns;namespace QuickReturns.StockTrading.ExchangeService.Clients{class ExchangeServiceClientProxy{static void Main(string[] args){ramrameshreddyramrameshreddyTradeServiceProxy proxy = new TradeServiceProxy();

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

Saved successfully!

Ooh no, something went wrong!