Solved

Consuming wcf service from MVC Application

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

While working on Silverlight and WCF application, I faced one issue where fault exception occurred at WCF operation contract is not getting propagated to Silverlight client. So after searching net I came to know that it was behavior by default for s…
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.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 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