【问题标题】:Method arguments not matching while implementing WCF service via a console application通过控制台应用程序实现 WCF 服务时方法参数不匹配
【发布时间】:2012-12-28 15:51:34
【问题描述】:

我正在尝试创建一个基本的WCF application 并使用Console Application 来调用该服务。我将service reference 添加到WCF Service 并在Console Application 中调用它为

ServiceName.Service s = new ServiceName.Service();
string str = string.empty;
str = s.GetData(10);  // here i get an argument overload mismatch error

WCF ServiceService.cs文件中,这个方法被定义为

public string GetData(int value)
{
    return string.Format("You entered: {0}", value);
}

为什么在这种情况下会出现参数重载不匹配错误?我是 WCF 的新手。我已将 WCF 服务添加为服务参考。

【问题讨论】:

  • intellisense 期望该方法的参数是什么?
  • 我猜 wcf 客户端将输入和输出参数包装在请求/响应类中。 stackoverflow.com/questions/1130032/…
  • 您使用的是什么版本的 Visual Studio 和 WCF?
  • 您是否将 WCF 服务配置为使用服务合同?
  • 我正在使用 VS 2008 。 Intellisense 给出 s.GetData(int value, bool valueSpecified)。是的,我将 WCF 配置为服务合同。

标签: c# .net wcf wcf-binding


【解决方案1】:

原来服务托管不正确。我重建了解决方案,并在重新托管 WCF service client 后运行良好。

参数对应于Service.cs中定义的参数

【讨论】:

    猜你喜欢
    • 2012-09-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多