Scenario
Ultimate Lottery
and Gaming (ULG) wants to build a WCF application that allows the client
application at the ticket vendor to retrieve winning number of a given lottery
draw.
Task 1:
Create a WCF
service that exposes a method called GetWinningNo that takes a string parameter
and returns an object of type Draw. Use the following two partially completed
classes:
public class Draw
{
public string Id { get; set; }
public int [] WinningNo { get; set; }
public double PoolAmt { get; set; }
}
public class LottoSrv
{
Dictionary<string, Draw>
drawList = new Dictionary<string, Draw>();
public LottoSrv()
{
int [] w1 = { 1, 2, 3,
4, 5, 6, 7 };
drawList.Add("649-29jun16",
new
Draw(){Id="649-29jun16",WinningNo = w1, PoolAmt=1000000});
drawList.Add("649-25jun16",
new Draw()
{ Id = "649-25jun16", WinningNo = w1, PoolAmt = 1200000 });
}
public Draw GetWinningNo(string
drawId)
{
return drawList[drawId];
}
}
Note:
GetWinningNo() is the method that needs to be exposed to the client.
Task 2:
Host the service
that you created in Task 1, in a console application.
Task 3:
Create client that
consumes the service exposed by the Host in Task 2. Use the partially completed
code given below:
static void Main(string[] args)
{
Draw d1 = client.GetWinningNo("649-25jun16");
Console.Write("ID:
{0} \nPool Amount: {1} \nWinning No: ", d1.Id, d1.PoolAmt );
foreach (var item in
d1.WinningNo)
{
Console.Write(item + " ");
}
Console.ReadLine();
}
Test to ensure
that the solution works as shown below:
Comments
Post a Comment