Skip to main content

Posts

Showing posts with the label Exercise

WCF Review Exercise 2

1. Download and open the WCF application  here . 2. Enable message logging in the host application 3. In the client application, handle CommunicationException, TimeOutException, and FaultException in the correct order.  4.  Use finally block to check if the client channel has entered a faulted state if it has then the abort the client and create a new instance of the client if the client is required again. 5. Enable reliable session by changing the app.config of the service host project.  6.  In the service host project, create a custom service host class called NewProdSrvHost. 7.   Override OnOpening() method to add an endpoint with basicHttpBinding and to enable metadata so that M etadata is always enabled with one endpoint. 8. Update the service host project to use the custom host class created above. 9. Update client reference and test the whole application.  10 Save and submit as a single zip file. 

WCF Service Contracts

Create a WCF Service library project Open Visual Studio Select  File  >  New  >  Project Select  WCF Service Library  template under  Visual C# > WCF  templates Change the name to  ProductServiceLibrary  and click  OK Visual studio will add reference to System.ServiceModel and System.Runtime.Serialization and will add some files with sample code.  Delete IService1.cs and Service1.cs Add a new class called ProductService Add the following code.      [DataContract]     public class ProductReview     {         [DataMember]         public string Id { get; set; }         [DataMember]         public string ProductCode { get; set; }         [DataMember]         public string ProductName { get; set; }         [DataMember] ...

WCF Exercise

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 };...