Connecting Your WCF To ASP.Net Website

Hello,

If you have been reading this tutorial from the beginning , you might know have idea whats this post will be on, if not, just have a quick look on the first post and follow the remaining posts. After we have created the wcf and enhanced its performance, now we would like to showcase the results in a real website. For today, we’ll connect our web service to a ASP.NET MVC 4 website but it is also possible to other website architecture.

Create Your ASP.NET Project

Fire up your visual Studio and create a new project based on Asp.Net MVC 4 or you can open the existing solution and add another new project. Thats up to you 🙂

Mvc_1
Creating MVC 4 Project

For the next step, I will be using a basic MVC 4 project and Razor as View Engine. Here also you can choose other type to define your project.

MVC_2
Define your template

Connecting Your Web Service

After creating your project, we have arrived at a crucial step, Don’t worry, if you have been following well, this will go as well.

You will need to make sure that your WCF Test Client is running. If you are stuck when trying to run your test client, refer to this post to guide you. Back your website project, Right-Click on your Project and navigate to Add -> Service Reference.

You will have another window pop up like below:

MVC_3
Add Service Reference

In the address textbox, you will have to add your wcf link. The latter appears in your WCF Test Client. Navigate to the test client, right – copy the link and paste in the address field.

MVC_4
WCF Test Client URL 

Once you have the url in the field  (e.g: http://localhost:7482/Service1.svc) , click on Go and you will notice Service1 is shown. You can either rename the namespace or leave it to the default. Click Ok to allow the connection. Make sure your WCF Test Client stays running all the time!!!

MVC_5
Service Reference Added

 

If you have successfully connected the web service to your website, it means that you only need to display the data from the wcf to the website. No trouble, I’ll show you in the next post which will be a short one. We will use bootstrap to make our website more interactive. 😉

Good Luck 

Kind Regards 

Harshu K Gaonjur

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s