Solved

Consuming wcf service from MVC Application

Posted on 2013-12-18
1
1,296 Views
Last Modified: 2014-01-02
Hi Experts,

I have a MVC4 SPA application  and have a reference to WCF service.Now we  modified the service to have a new  boolean property.I need to retrieve the boolen value from the WCF service to the razor view(index.cshtml) something like this (var Myflag='@......';). I have updated service reference and can see new boolean property in the 'Reference.cs' file under Service References folder.

Please let me know the steps involved ( like where to instantiate proxy class,how to  retrieve boolean value from WCF service to razor view etc) to achieve this.(if possible with sample code).

Thanks in Advance
0
Comment
Question by:ksd123
1 Comment
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 500 total points
ID: 39727564
You create the service proxy in the controller, call your method, and pass the result to the view. Something like:
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            // create proxy
            ServiceReference1.IService1 svc = new ServiceReference1.Service1Client();

            // call method
            bool value = svc.GetData(1);

            // return to view
            return View(value);
        }
        ....
    }

Open in new window

0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now