2009-09-16 15 views
1

我有兩個ServiceContracts作爲接口實現。我只想導出其中的一個元數據。訣竅是兩個接口都由相同的類實現。因此,我不認爲我可以使用/ excludeTypes。回答時請包括示例語法。謝謝!如何使用svcutil.exe導出單個合同的元數據?

編輯:一位同事最近問我爲什麼這是必要的。之所以這樣,第一個 ServiceContract適用於REST服務,這對於導出元數據是沒有意義的。因此,我生成了兩個wsdl和xsd文件,僅僅因爲第二個文件名附加了「1」而可以區分。這使得工具變得困難,並且使輸出目錄更加混亂。

我已經添加了一個賞金來嘗試引起對此問題的興趣。

回答

2

我創建了一個服務合同類,實現2個接口,就像您所描述的那樣。

namespace NS 
{ 
    [ServiceContract] 
    public interface IREST 
    { 
     [OperationContract] 
     string WorldHello(string name); 
    } 

    [ServiceContract] 
    public interface IInterface 
    { 
     [OperationContract] 
     string HelloWorld(string name); 
    } 

    public class CI2 : IREST, IInterface 
    { 
     public string WorldHello(string name) 
     { 
      return "World Hello: " + name; 
     } 

     public string HelloWorld(string name) 
     { 
      return "Hello World: " + name; 
     } 
    } 
} 

正常運行時SvcUtil工具,我得到一個WSDL從2個接口的方法
當我運行SvcUtil工具與/ excludeType:艾力斯特例如,我只得到IInterface方法。

svcutil /excludeType:NS.IREST ci2service.exe 

您是否使用相同的配置?在這種情況下/excludeType的作品。

+0

完美的工作!我不知道爲什麼它沒有發生,我可以把*接口*放入/ excludeTypes。感謝您的幫助 - 獲得滿分! – GuyBehindtheGuy 2009-10-08 13:32:34

相關問題