Microsoft 9GD00001 Computer Accessories User Manual


 
338 Microsoft Visual Studio 2010: A Beginner’s Guide
a Web application as the Web service client. However, this might not be possible if you
are deploying to a hosted server by a third-party Internet service provider where you
only have a single Web site. In that case, you have the additional option of adding a Web
service directly to an existing Web site.
To see how this works, create a new ASP.NET MVC Web site. Right-click the project,
select Add | New Item, and create a new WCF Service. What you’ll see is an interface
file, IService1.cs; an addressable service file; an implementation class, Service1.svc; and
Service1.svc.cs, which you can find under the Service1.svc branch. All of the information
you’ve learned previously in this chapter applies to coding a Web service that is part of the
Web application. You should know that this is an option if it fits your needs.
Summary
You’ve learned how to build a Web service, how to deploy the Web service, and how to
write a client that consumes the Web service. The discussion on creating the Web service
showed you how to define the Web service contract with an interface and applicable
attributes. You saw how to implement the service also. The deployment discussion
explained how to host a Web service with IIS and how to use the VS Publish Wizard for
deployment. You also saw how to write a client that creates a reference to a Web service
and writes code to communicate with the Web service.