WCF 类在同名的不同服务合约中实现两个操作合约
我已经声明了两个服务合同,如下:
[ServiceContract]
public interface IContract1
{
[OperationContract]
double Add(int ip);
}
[ServiceContract]
public interface IContract2
{
[OperationContract]
double Add(double ip);
}
我有一个实现这两个合同的类。我为两个合约创建了两个端点。但我无法从客户端代码访问该服务。 当我尝试将服务引用更新为以下内容时,它显示一个大错误:
元数据包含无法解决的错误....没有端点侦听...等。
我知道您不能有两个同名的 OperationContract
但有可能吗不同服务合同中有两个操作合同名称相同但签名不同?
I have declared two service contracts as follows:
[ServiceContract]
public interface IContract1
{
[OperationContract]
double Add(int ip);
}
[ServiceContract]
public interface IContract2
{
[OperationContract]
double Add(double ip);
}
I have a class which implements these two contracts. I have created two endpoints for both contracts. But I'm not able to access the service from client code.
It displays a big error when I try to update the service reference as:
Metadata contains an error that cannot be resolved.... There was no endpoint listening at ... , etc.
I know that you can't have two OperationContract
s with the same name but is it possible to have two operation contracts in different service contracts with same name but different signature?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果一项服务实现了这两个合约,那么您应该为您的操作合约指定唯一的名称。
If one service implements both contracts then you should give unique names to your operation contracts.
您可以使用以下内容。
You can use the following.