Thursday, April 16, 2015

How to Create a WCF Service library

  • Add the WCF Service library
  • Add the service host project to the solution

  • Add the  Business Objects class library to the solution
  • Add the Business Logic class library to the solution 
  • Add the Data Access layer class library to the solution 
  • Add the DTObjects class library to the solution
  • Add the DTOStudent  Class to the DTObjects project

    • Add the System.Runtime.Serialization as reference to the project 
    • Decorate the Data Contract as DTOStudent Class and add few properties and decorate it as data member



  •   Add the Student to the business object and add the class properties


  • Add BOAssembler class to the business logic and add StudentBusinesObjects Project  and DTOobjects project as references
  • Implement the AssembleStudentBO method to the BOAssembler class


  • Add DTOAssembler  class and Implement the AssembleStudentDTO method


  • Implement the Data Access layer
  • Add the connection string as the key of the web.configration file using the settings file modifications




  • Change the key name to student
  • if you open the web.config file you can see the changes what are made by adding the connection string key
  •  Add the  IDALDBConnection interface to the project and add the signatures
  • Add the DbConnection Class to the DAL and add the DbConnection and DbTransaction abstract class members to the DBConnection Class 

  •  Implement  the connection string method


  • implement the ExecuteNonQuery method

  • implement the Execute DataSet method



  • implement the business object Student class methods and add the constructor
    implement the add Student method 

  • implement the Get Student method 


  • Add the IStudentService Interface to Business Logic layer and add the two methods
  • implement the method in the StudentService class

  • Implement the IStudentManagementService interface to StudentServiceLibrary
  • Decorate the service as ServiceContract  and methods as OperationContract

  • Implementation of the StudentManagementService class


  • Implementation of the StudentServiceHost layer
  • Rename the SVC class to the StudenService and delete the cs class of the SVC file
  • Remove the CodeBehind tag and set the Service="StudentServiceLibrary.StudentManagementService"
  • Open the StudentServiceLibrary app.config file using the WCF editor and change the service name to StudentServiceLibrary.StudentManagementService.


  • Now Change the end point  basicHttpBinding contract property to the
    " StudentServiceLibrary.IStudentManagementService "


     
  • Now open the App.config file and copy the <services> tag element  and paste in to the Web.config file 


  • Now u can successfully  run the service


  • Add the student to the database and Get the all student add by the service 



No comments:

Post a Comment