Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Consuming wcf service from MVC Application

Posted on 2013-12-18
1
Medium Priority
?
1,461 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 1500 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

Certified OpenStack Administrator Course

We just refreshed our COA course based on the Newton exam.  With 14 labs, this course goes over the different OpenStack services that are part of the certification: Dashboard, Identity Service, Image Service, Networking, Compute, Object Storage, Block Storage, and Orchestration.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
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…

660 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