Wcf Service Basic Part Seven



At previous session we learnt about choosing right binding for application  . In this session we will discuss  the code is auto generated when we created wcf service . When we create wcf project , we see two things one is interface and other one is implementation of the interface . Let see an example . when i created the  project 

namespace CompanyService
{
    [ServiceContract]
    public interface IMyCompanyPublicService
    {
      
        [OperationContract]
     string AddNewEmployee(string id, string name, string address, string city, string salary);

        [OperationContract]
        string Balance(AccountBalance accountBalance);
}
}

and I named it CompanyService as you can see from namespace . Then we have ServiceContract attributes , thants means which service will be contracted when we invoked wcf service . After that we have the modifier type is public then key word interface that means ,its a interface and name of the interface .I named it IMyCompanyPublicService. we have attributes is called OperationContract that means when we invoked the service first hit the [ServiceContract] attributes then its goes in  [OperationContract] and look for the method that clint want to invoke . In this case we have two method . Both method is type string . First method expect parameters like id , name , address etc and the parameters also type is string . But second method we are passing class . You can choose any one ,depends on your patrice .    

No comments:

Post a Comment