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.

amrameshreddy.blog.com118 CHAPTER 4 ■ INSTALLING AND CREATING WCF SERVICESramrameshreddy.blog.comAt this point, click OK several times to dismiss the dialog boxes. The site should now beavailable through the URL http://localhost/Example04Web. However, you still need to check theversion of ASP.NET that is set for this site. If you have only .NET 2.0 installed—that is, .NET 1.1was never installed—there should be nothing else to do; however, it doesn’t hurt to just check.So, launch IIS Manager (Start ➤ Control Panel ➤ Administrative Tools ➤ Internet InformationServices). Once you see the Properties dialog box, click the ASP.NET tab, and thenswitch the version of ASP.NET using the drop-down list to the .NET 3.0–supported version,which is 2.0.50727 (the RTM version).■Tip If you don’t see this icon, then either you have limited access on the machine or IIS is not installed.Please ensure IIS is installed and you have the appropriate permissions.This example has one additional step—to provide access to resources known as anonymousrequests. Anonymous requests are any requests that have no identity or Windowsprincipals associated with the HTTP request.Click the Directory Security tab, and then click Edit under the Anonymous Access andAuthentication Control section of the dialog box. Ensure that the option Anonymous Access isenabled. This will allow the example to run without stepping into how to provide authenticationcredentials on the requests.Dismiss all open dialog boxes by clicking the OK buttons. At this point, you now have asolution directory with a child project that has, or will have, all its resources (source code filesand content) located in a directory of your choosing (that is, not in the default c:\inetpub\wwwroot directory).Now you’re ready to add the project to the solution you created earlier. In Visual Studio,select the solution in Solution Explorer, right-click, and then select Add ➤ New Web Site.At this point, ensure you select the .NET 3.0/WCF service template, set HTTP as the location,use the URL that was set on the folder alias using web sharing in Windows Explorer, andset the language of your choice. Click OK, and the Visual Studio .NET 3.0 template system createsa project starting point for your service, giving you a complete project.Notice that the project template leverages the special folder names for the application codeand application data. In the prior example, the source code was hosted directly in the *.svc file.The project shown here, which is generated from the .NET 3.0 template, has a distinct sourcedirectory along with a *.cs file that contains the interface and class implementation.■Tip In the real world, it’s best to separate the service interface (contract) and implementation types intotheir own assemblies (DLL), which translates to projects in Visual Studio. Having the structure as shown previouslyis a nice feature for ease of use, but from a physical separation perspective, it’s better to providedistinct assemblies for the tiers.ramrameshreddyramrameshreddyIf you look at the file system using Windows Explorer or using a command prompt andview the directory you started in, you’ll see the same set of files listed under the project inVisual Studio Solution Explorer.

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

Saved successfully!

Ooh no, something went wrong!