【发布时间】:2012-10-07 03:34:02
【问题描述】:
这是我第一次使用 Visual Studio 和 C# 进行编程。我正在尝试创建 Web 服务,但我的 GetProduct 没有出现。
namespace GettingStartedHost
{
// NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in code, svc and config file together.
public class Service1 : IService1
{
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
public int GetProduct(int a, int b)
{
return a * b;
}
[ServiceContract]
public interface IService
{
[OperationContract]
int GetProduct(int a, int b);
[OperationContract]
string GetData(int value);
[OperationContract]
CompositeType GetDataUsingDataContract(CompositeType composite);
}
public CompositeType GetDataUsingDataContract(CompositeType composite)
{
if (composite == null)
{
throw new ArgumentNullException("composite");
}
if (composite.BoolValue)
{
composite.StringValue += "Suffix";
}
return composite;
}
}
}
当我按 CTRL-F5 启动测试服务器时,只显示 2 个方法。 GetProduct 不显示。怎么了?
【问题讨论】:
-
样本缺少
IService1的定义... -
您是否更新了客户端项目中的服务引用?
-
您能详细说明一下吗?我似乎无法让它工作
-
您必须填写我的姓名,您的回复才能显示在我的收件箱中;)我的意思是:您是否在您的客户项目中右键单击了您的服务参考并点击了
Update Service Reference?
标签: c# asp.net visual-studio-2010 wcf web-services