First open Microsoft Visual Studio 2012 with Administrative rights. The go to "File" -> "New" -> "Project".Select the "WCF Template" and then click on "WCF Service Library".Set the name field to "WcfServiceConfiguration" and framework to ".NET 4.5" and save it your preferred location.Rename the "IService.cs" to "IA.cs" and "Service.cs" to "A.cs".Replace the existing code of IA.cs with the code shown in the following image.Now replace the existing code of A.cs with the code shown in the image belowNow build this service to check that it does not contain any errors.In the example I will declare the baseAddress, endpoints etcetera programmatically so you can delete the tags from the App.Config file.Now I will create a Host Application to host this service.Right-click the existing solution and select "Add" -> "New Project" then select Console Application, name this project "Host".Add a reference to the System.ServiceModel dll and WcfServiceConfiguration dll that we have just built.Now replace the existing code with the following code shown in the image below:Set this Host Project as your startup project (right-click the host project and set as setup project) and press the F5 Key to run the host. If everything is fine you will see this command prompt:Now we can consume this service in two ways.FirstUsing ChannelFactoryAdd a new project to this existing solution and name it "ConsumerWithChannelFactory".Add a reference to the System.ServiceModel dll and WcfServiceConfiguration dll, replace the code of the existing Program.cs class with the following code shown in the image below.Run the Host Project and then run the ConsumerWithChannelFactory project to see the output like in the following image.The second way to consume this service is by using the ServiceModel Metadata Utility (svcutil.exe) to generate a proxy and a configuration file.Add a new project to the WcfServiceConfiguration solution and name it ConsumerWithSvcuUtil.Run the Visual Studio developer command prompt with administrative rights, run the host process first and then type the following command on the prompt to generate a proxy and a configuration file.After the generation of the files add them to the ConsumerWithSvcuUtil Project by clicking the project and select "Add" -> "Existing Item".Now type in the following code in the Program.cs file of the ConsumerWithSvcuUtil project as shown in the following image:Now run the Host; if its not already running then run the ConsumerWithSvcuUtil, if everything is "Ok" then it will look as in the following:Feel free to tell if I have missed something or many things and I hope this tutorial works fine for you.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: