O'Reilly logo

Data-Driven Services with Silverlight 2 by John Papa

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a Silverlight-Enabled WCF Service

You can modify the sample application shown throughout this chapter to use a WCF web service instead of an ASMX web service. In this section, I will demonstrate a few of the differences in setting up a WCF web service and invoking it from a Silverlight 2 client application.

Creating the WCF Web Service

You can create WCF web services that Silverlight 2 clients can consume either by creating a WCF web service using the default WCF service file template, or by using a Silverlight-enabled WCF Service file template. A standard WCF service file template uses the wsHttpBinding binding. You must change this to basicHttpBinding for Silverlight 2 to be able to communicate with the WCF web service, because Silverlight 2 supports only basicHttpBinding. If a WCF web service is created using the Silverlight-enabled WCF Service file template, basicHttpBinding is set by default.

You can modify the EmailClient application to call a WCF web service. The first step is to create the new WCF web service. The sample code for this chapter contains an IIS web application running under Cassini, named WCFEmailService (an IIS website would also work). You can create a new WCF web service by right-clicking the WCFEmailService project’s node in the Project Explorer, choosing Add New Item, and selecting “Silverlight-enabled WCF Service”. Figure 5-11 shows the WCF web service being named EmailService.svc.

Figure 5-11. Creating EmailService.svc

Bindings

The Silverlight-enabled ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required