Skip to main content

Windows Communication Foundation (WCF) Sample Application

Step 1:

First open Visual Studio and click File -> New -> Website, under that, select WCF Service and click OK if you don't want to change the name of the application.



Step 2:

Once you clik OK button, the WCF application will be added to your solution explorer as shown in the below image. Two default class files IService.cs and Service.cs will appear under App_Code folder. IService.cs is an Interface where only method names are declared and its definition must be coded in the file called Service.cs.





Step 3:

Now open IService.cs and Service.cs files to write the method and its definition. Remove unnecessary code which is supplied by default. I have created SampleMethod function, you can have other name instead.

 IService.cs file

Service.cs file








To your surprise, you are done with 50% of the work. But, this was just the creation of service, still we need to have the application that is capable enough to call the service. The prerequisite of doing such thing is, one has to publish the service. To make this happen, you can select Publish Website under Build menu. Browse the path where you would like to have the service to be published (compiled to be precise) and hit the OK button, as shown in the below image.




Step 4:

Now, its time to move a step furhter. As I told, you must call service to use its functionality, you are supposed to create another application (console application, or windows application), in our case for the sake of simplicity, I have chosen console application. So, just right-click the project label (Solution WCF Service ....) at the top of the solution explorer, and run down to the Add option, and select New Project. A new window will pop-up offering you to select the type of application you want to create. Select Console Application and click OK button.




Step 5:

After adding the Console Application to your solution explorer, you need to provide the service reference to it. So, right click and select Add Service Reference.




To get the path, clikc the Discover button, and .NET will find you out all the services you have incorporated till now. In our case there will be only one as shown in the Services column in the above image. Click OK and the reference is added.

Step 6:

Write the below code to call the service in Program.cs file.



Step 7:

Run the application. (Set the Console Application as StartUp project else you will end up with web page opened). You will see the black window where you can pass the argument.






By: Amit Chaudhary

Comments

Popular posts from this blog

Characteristics of a Good Programming Language

Till now there are many high level languages which are very popular, and there are others, which could not become so popular in-spite of being very powerful. There might be many reasons for the success of a language, but one obvious reason is the characteristics of the language. Several characteristics believed to be important with respect to making a programming language good are briefly discussed below. Simplicity A good programming language must be simple and easy to learn and use. For example, BASIC is liked by many programmers only because of its simplicity. Thus, a good programming language should provide a programmer with a clear, simple and unified set of concepts which can be easily grasped. It is also easy to develop and implement a compiler or an interpreter for a programming language that is simple. However, the power needed for the language should not be sacrificed for simplicity. The overall simplicity of a programming language strongly affects the readability of the pr...

Angular 4 and Firebase Authentication: Email/Password

In our  previous  article we saw how to create authentication module using Google identity provider. Now we will see how to implement Email and Password authentication using Firebase. We will use Bootstrap form to create intuitive user interface for sign-up and login using Email and Password. Step 1: Create signUp component. ng generate component signUp Step 2: Create custom form in sign-up.component.html file. The result of above code: Step 3: Add two functions for creating the user and login using Email and Password in src/app/providers/AFAuth.ts file. Step 4: Call createUserWithEmailAndPassword function in service from sign-up.component.ts. Step 5: Update routing configuration in app.module.ts  to include signUp component. Step 6: Update Login form to have Bootstrap form. The result of the above code. Step 7: Enable Email/Password component in Firebas...

Angular 4 and Firebase Authentication: Setup

If you have come to this article, it means you are keen to learn new technology and that too Firebase. I love Firebase because it provides all basic but important features of any web application. Take for example, authentication, which is cumbersome and risky if not implemented with utmost care. And when we have the integration of Angular and Firebase, it becomes a lot easier for a developer to build such crucial modules in less time with minimal efforts. In this article we will create a simple Angular application using Firebase. I am going ahead with the understanding that you know the benefits of Firebase and have little knowledge about it. There are plenty of posts out on the web if you are behind. Step 1: Install Angular CLI (if not installed). npm install -g angular-cli Step 2: Create new Angular 4 project. By default now angular CLI will create Angular 4 project so you need not fret. ng new firebase-authentication Step 3: Check whether the ne...