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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access