开发者

MVC3 and WCF Cross site

.NET newbie here. I have an MVC3 web application EF 4.1 Code First and Data Entity Framework, works great. I am trying to create another WCF Service/Application that will run on a different IIS server than the MVC3 application. The objective is "Cross site commu开发者_开发技巧nication":

  1. MVC3 app saves data to local host database. "works"
  2. MVC3 app Sends data to another IIS that hosts the WCF.
  3. WCF service saves data to database that is identical to the one on the MVC3.
  4. WCF sends confirmation back to MVC if data has been saved or not.
  5. WCF does not have to be complex, simple will do, WCF REST / WCF Web etc.

I went through dozens of articles and video tutorials but its all about exposing the service within same project/site. i am trying to find an actual CODE SAMPLES to at least send the data from one server to another.

your help is greatly appreciated.


Once you have exposed your WCF service on some server all you have to do in your ASP.NET MVC 3 application is to add a Service Reference ... and point to the WSDL of the remote WCF service which will generate a strongly typed proxy class and add a bunch of config sections in your web.conig. Then simply call the service:

using (var client = new MyServiceClient())
{
    var result = client.SomeMethod();
}

Here's an article on MSDN which illustrates how WCF services could be hosted and consumed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜