Wednesday, 29 May 2013

Create WCF Service and Host in IIS with SSL Certificate

Step 1: New project => Select WCF in left pane => serivce name =>hit Ok buton

Step 2:
write the simple method to Get the GetCustomerName as fig shown below

    public interface IService1
        string GetCustomerName(string CustomerName);
        // TODO: Add your service operations here
Step 3:

implement the GetCustomerName method in Service1.cs file by inheriting IService1.cs
as usal fig shown below.

 public class Service1 : IService1
        /// <summary>
        /// Get the Customer Name
        /// </summary>
        /// <param name="CustomerName"></param>
        /// <returns>string as Customer Name</returns>
        public string GetCustomerName(string CustomerName)
            return string.Format("Customer Name is: {0}",CustomerName);

Step 4: Provide the endpoints in web.Config file in System.serviceModel tag

Step 5: Create dummy Self signed certificate

Step 6: Add Web Site in IIS

Step 7: after publishing add service reference in your .net application
Step 8: it's asking self signed certificate hit on yes
Step 9: Finally consume the wcf proxy in your console application
Step 10: Finally we got a Result from wcf service.

No comments:

Post a Comment