Solved

Consuming wcf service from MVC Application

Posted on 2013-12-18
1
1,433 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

626 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