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 🙂
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.
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:
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.
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!!!
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. 😉
Harshu K Gaonjur