Wcf Service Basic Part Three.

In part one we have seen how to create wcf service by using class library project . In this lesson we will discuss the classes ,wcf service we added into our project  and app.config file .In solution explorer side we have seen the Interface and the services are auto generated by the wcf service .



First thing we can see at top of the project is the name of the project then we can the see the properties section ,in this section the assembly  is defined  . After that we can see the reference file section . In this reference section we usually add the reference from other project and required namespace for our project . Then we have class1.cs file ,this file auto generated by the visual studio .
Then we have two class ,this is added we added the wcf service into our project . One class is contain the interface and the next class provides the implementation of the interface . 


  

As you can see the interface is decorated with Service Contract attributes and name of the interface is IStudentWcfService  . Inside the interface we have another attribute is called Operation Contract . In this operation contract we define methods , type of the method and parameters are expect by the method . For example .



As you can see the i passes a parameter type is string and named it id . The name of the method is DoWork and return type is void . Finally we need to provide the implementation of the interface as well .
As you can see from screen shot the method implementation is completed . In real tram we write the ado.net (C#), linq or VB etc    code to perform required operation .  Next session we will learn about the app.config file .

No comments:

Post a Comment