【发布时间】:2011-12-09 09:10:22
【问题描述】:
我正在通过 SvcUtil.exe 更新我的 wcf 服务引用。 命令如下:
SvcUtil.exe http://localhost:50886/Service1.svc /n:*,ClassLibrary2.ServiceReference1 /o:Service References\ServiceReference1\Reference.cs /ct:System.Collections.Generic.List`1, mscorlib, Version=2.0.0.0, Culture =中性,PublicKeyToken=b77a5c561934e089 /config:app.config
而我的wcf代码如下:
================================================ ===============
namespace WcfService1
{
[ServiceContract]
[ServiceKnownType(typeof(Dictionary<string, string>))]
public interface **IService1**
{
[OperationContract]
string GetData(int value);
// TODO: Add your service operations here
[OperationContract]
string Hello(string value);
}
}
namespace WcfService1
{
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class Service1 : IService1
{
public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}
public string Hello(string value)
{
return string.Format("You entered: {0}", value);
}
}
}
我在名为 ClassLibrary1 的类库项目中使用此服务。当我通过 Visual Studio 更新此服务时,在 Reference.cs 中我得到以下声明:
[System.ServiceModel.ServiceContractAttribute(ConfigurationName="**ServiceReference1.IService1**")]
public interface IService1
但是当我通过 svcutil 更新服务时,我得到以下语句:
[System.ServiceModel.ServiceContractAttribute(ConfigurationName="**ClassLibrary2.ServiceReference1.IService1**")]
public interface IService1
区别在于配置名称。我不明白应该在 svcutil 中使用哪个命令将配置名称设置为 ServiceReference1.IService1 ?
请帮忙。
【问题讨论】:
标签: svcutil.exe