【发布时间】:2014-02-13 18:02:19
【问题描述】:
我正在将 Web 服务从 VB 更新到 C#。这是 WCF 服务。 Web 服务实现了 2 个接口。 当我将 Web 服务添加到测试应用程序时,只能访问其中一个接口。 当我尝试从第二个接口调用方法时,无法识别方法签名。
这在 VB 中有效,我希望我可以在 C# 中做同样的事情。 这是网络服务类的实现:
支付服务接口:
namespace PayService
{
[ServiceContract (Namespace...)]
public interface IPayService
{
//Initiate a credit card authorization.
[OperationContract(IsOneWay = true)]
void Authorize(...12 arguments here...);
}
PayService2 接口:
namespace PayService2
{
[ServiceContract (Namespace...)]
public interface IPayService
{
//Initiate a credit card authorization.
[OperationContract(IsOneWay = true)]
void Authorize(...13 arguments here...);
}
public partial class PayService : IPayService, IPayService2
{
Authorize(...there are 12 arguments here)
Authorize(...there are 13 arguments here)
...more methods but they are not a problem.
}
调用应用程序只是一个用于测试 Web 服务的 Web 应用程序。
//Create instance of PayService
PayService.PayServiceClient payService = new PayService.PayServiceClient();
payService.Authorize(...12 arguments) //this one works fine
payService.Authorize(...13 arguments) //this one is not recognized
有谁知道为什么不是所有方法都在使用 PayService 的 Web 应用程序中可见?
谢谢。
【问题讨论】:
-
这是 WCF 服务吗?
-
不,如果不告诉我们您是如何实现调用此网络服务的,我们谁都无法帮助您。我们不是通灵者,抱歉:)
-
对不起...我添加了更多细节。这些信息够吗?
-
OperationContract 的想法有帮助吗? stackoverflow.com/a/5689054/404
-
我将 'Name=' 属性添加到 OperationContract 中,但 Web 应用程序仅识别其中一种 Authorize 方法。其次,我读到操作是由方法签名定义的,而不仅仅是方法名称。我可以有 2 个名称相同但签名不同的方法吗?
标签: c# web-services interface