我的 wcf 应用程序 IService1.cs 中有这样的类和接口(interface)
[ServiceContract]
public interface IService1
{
[OperationContract]
string insertValues(empInfo objInfo);
}
[DataContract]
public class empInfo
{
string _organizationName = string.Empty;
string _organizationAddr = string.Empty;
int? _totalemp;
}
在 Service1.svc.cs 中,我已经实现了该接口(interface)。
public class Service1 : IService1
{
public string insertValues(empInfo objInfo)
{
.....
}
}
然后我创建了一个空的 mvc4 客户端应用程序来使用这个 wcf 服务。
我已经添加了 ServiceReference,现在它作为 ServiceReference1 出现在服务引用文件夹中。然后我这样做了
1. 创建了一个名为 Defalut1controller 的 Controller 。
2.在这个 Controller 中,我尝试添加以下行
ServiceReference1.Service1Client proxy = new ServiceReference1.Service1Client();
在 ActionResult 中。但无法获取 ServiceReference1 字。当我像这样更新我的服务时出现它的(ServiceReference1)
来自 -
string insertValues(empInfo objInfo);
- 至 - string insertValues(string objInfo);
现在我已经构建了这个 wcf 应用程序,并在我的客户端 mvc4 应用程序中更新了服务引用。现在
ServiceReference1.Service1Client proxy = new ServiceReference1.Service1Client();
行已启用。
我已经尝试使用 .net Web 应用程序来使用相同的内容,我可以毫无问题地做,我错过了 mvc4,请帮忙。提前致谢..
最佳答案
感谢stackoverflow,我得到了答案。
这是解决方案:
它也对我有用。
关于asp.net-mvc - 在 mvc 4 中使用 wcf 服务的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16435229/