08.01.2015 Views

Beginning Web Development, Silverlight, and ASP.NET AJAX

Beginning Web Development, Silverlight, and ASP.NET AJAX

Beginning Web Development, Silverlight, and ASP.NET AJAX

SHOW MORE
SHOW LESS

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

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

CHAPTER 7 ■ .<strong>NET</strong> 3.0: WINDOWS COMMUNICATION FOUNDATION 173<br />

CASSINI VS. IIS<br />

When you are developing with Visual Studio, if you create your web site or service using the file system,<br />

Visual Studio will launch the Cassini web server to allow you to test <strong>and</strong> debug your application. This<br />

will use a r<strong>and</strong>om port other than port 80, such as port 49906, as in the example in the “Creating the<br />

Address Service Client” section. When following along with the code in this section of this book (as well<br />

as any other book where Visual Studio <strong>and</strong> Cassini are being used), underst<strong>and</strong> that you are likely to<br />

have a different port, so your URL will be http://localhost:xxxxx, where xxxxx is the port that<br />

was r<strong>and</strong>omly assigned.<br />

When you deploy your application to a production web server running IIS, you’ll be using port 80.<br />

Remember to update proxies or any references to the correct port.<br />

The tool will respond with output like the following:<br />

Microsoft (R) Service Model Metadata Tool<br />

[Microsoft (R) Windows (R) Communication Foundation, Version 3.0.4506.30]<br />

Copyright (c) Microsoft Corporation. All rights reserved.<br />

Attempting to download metadata from<br />

'http://localhost:49906/FirstWCF/Service.svcwsdl'<br />

using WS-Metadata Exchange or DISCO.<br />

Generating files...<br />

C:\Program Files\Microsoft Visual Studio 8\VC\AddressService.cs<br />

C:\Program Files\Microsoft Visual Studio 8\VC\output.config<br />

As you can see, the files are generated in the current directory. You will add them to<br />

your new client next.<br />

You can use any type of application as a service client as long as you use this configuration<br />

information. If you’re building a Windows app, you add the information to your<br />

App.config; otherwise you add it to your <strong>Web</strong>.config. For this example, you’ll build a web<br />

client that takes the information back from the WCF service <strong>and</strong> renders it on a DataGrid.<br />

First, create the web application that implements the client using the File – New dialog.<br />

You’ll have a basic web application set up containing a Default.aspx page. You’ll need<br />

to add a <strong>Web</strong>.config file to the project. The easiest way to do this is to just run the application<br />

in debug mode, <strong>and</strong> Visual Studio will automatically generate a <strong>Web</strong>.config file for<br />

you.<br />

Next, you should copy the two files AddressService.cs <strong>and</strong> output.config to the directory<br />

that the new web site is implemented in, <strong>and</strong> add them to your project.

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

Saved successfully!

Ooh no, something went wrong!