What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 3188 |  Welcome, Guest!   Register  Login
 Home > Coding Horrors > WCF > calling WCF in MVC3 ...
Mani5155

calling WCF in MVC3

 Coding Horror posted by: Mani5155 | Posted on: 4/12/2012 | Category: WCF | Views: 2981 | Level: Starter | Status: [Member] | Points: 75 | Alert Moderator   



  
/
// example of web service
public class Service1 : IService1
 {
        public string GetData( int value )
        {
            return string.Format( "You entered: {0}", value );
        }

        public CompositeType GetDataUsingDataContract( CompositeType composite )
        {
            if( composite == null )
            {
                throw new ArgumentNullException( "composite" );
            }
            if( composite.BoolValue )
            {
                composite.StringValue += "Suffix";
            }
            return composite;
        }
 }



//example in controller

public ActionResult Index()
    {
        SettingsModel config = null;

        // Set up a channel factory to use the webHTTPBinding
        using (WebChannelFactory serviceChannel =
            new WebChannelFactory(new Uri(baseServiceUrl )))
        {
            IChangeService channel = serviceChannel.CreateChannel();
            config = channel.GetSysConfig();
        }

        ViewBag.Message = "Service Configuration";

        return View(config);
    }




<iframe src="https://www.mcpvirtualbusinesscard.com/VBCServer/manivannanm/interactivecard"/>
Found interesting? Add this to:


About manivannan m

Experience:1 year(s)
Home page:http://www.dotnetfunda.com
Member since:Monday, April 09, 2012
Level:Starter
Status: [Member]
Biography:
>> Write Response - Respond to this post and get points

More Coding Horrors

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/25/2013 1:46:01 PM