The binding information de?¬?nes the requirements for
communicating with the service. Among other requirements, it
describes the transport that will be used (for example HTTP or
TCP) and the security requirements for calling the service.
Address, contract, and binding are often referred to as the ABC??™s
of a WCF service.
Using the IBalance interface described previously, let??™s take a
look at some server and client code for a Web service that supports
use of the interface. A class must be de?¬?ned that implements
the IBalance interface. In this example, the
AccountManager class performs that role.
This simple
example of a
CardSpace enabled
WCF service illustrates
how easily
CardSpace works
with WCF.
254 CardSpace Implementation
using System;
using System.ServiceModel;
namespace BankServices
{
class AccountManager : IBalance
{
public double GetBalance()
{
// add logic of retrieving the actual
// balance from a database
return 20000.00;
}
}
class Program
{
string serviceUri =
???HTTP://bankingserver:9001/BankServices???;
static void Main(string[] args)
{
ServiceHost sh=
new ServiceHost(typeof(AccountManager)
,
new Uri(serviceUri));
sh.Open();
//This keeps the service process running
// as Web service calls are received
// they will be serviced on
// other process threads
Console.
Pages:
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382