ReadLine();
sh.Close();
}
}
}
The AccountManager class is then run in a service host
(ServiceHost), which is available at the speci?¬?ed endpoint to
service incoming requests.
Naturally, a client must be written to call the service. The client
sets up a WCF channel to the service:
CardSpace and Windows Communication Foundation 255
using System;
using System.ServiceModel;
namespace BankClient
{
class Program
{
static void Main(string[] args)
{
ChannelFactory<
BankServices.AccountManager > cnFactory =
new ChannelFactory<
BankServices.AccountManager >("bankClient");
BankServices.AccountManager chn =
cnFactory.CreateChannel();
Console.WriteLine(chn.GetBalance());
}
}
}
Address information about where the service can be reached
and which contact and binding to use is set in a client con?¬?guration
?¬?le (app.con?¬?g):
name="bankClient"
address="
HTTP://bankingserver:9001/BankServices/GetBalance()"
contract=" BankServices. IBalance"
binding="wsHttpBinding"
bindingCon?¬?guration="bankBinding">
Obviously missing from this example is security. As is, anybody
can access the GetAccount interface. Fortunately, adding
CardSpace is easy.
Pages:
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383