2014-02-13 34 views
-1

我正在更新從VB到C#的Web服務。這是一個WCF服務。 Web服務實現2個接口。 當我將Web服務添加到測試應用程序時,只能訪問其中一個接口。 當我嘗試從第二個接口調用方法時,方法簽名無法識別。添加2個接口的Web服務

這工作在VB中,我希望我可以在C#中做同樣的事情。 這是Web服務類的實現:

PayService接口:

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應用程序可見?

謝謝。

+0

這是一個WCF服務? –

+1

不,沒有告訴我們你是如何實現的*調用*這個web服務,我們都不會幫助你。我們不是通靈,對不起:) – nvoigt

+0

對不起...我添加了更多細節。這是足夠的信息嗎? –

回答

0

檢查了這一點:https://stackoverflow.com/a/720389/487940

你基本上要到2個接口組合成一個單一的接口,像這樣:

public interface IMyInterface : IInterface1, IInterface2 
+0

該鏈接非常好。第二個答案的鏈接解釋瞭如何使用2個接口爲同一服務提供多個端點。如果我能做到這一點,那就是我需要的。下面是評論和鏈接:單個ListenUri上的多個端點:http://msdn.microsoft.com/en-us/library/aa395210.aspx –

+0

這對我來說不起作用,因爲我有一個名字相同的方法兩個界面,但不同的方法簽名......參見上面的參數列表。它看起來像我將不得不使用多個端點實現。 –