Solved

Consuming wcf service from MVC Application

Posted on 2013-12-18
1
1,376 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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

735 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