2010-09-02 77 views
2

我有讀起來就像一個WCF服務合同:是否有可能在運行時爲Silverlight生成WCF異步服務合同?

[ServiceContract(Name = "DummyService") ] 
    public interface IDummyService { 

     [OperationContract] 
     void DoSomething(); 

     [OperationContract(Name = "SayHello")] 
     string SayHello(string message); 
    } 

WCF服務將Silverlight應用程序消耗。我正在尋找一種方法來消除手動編寫異步合約的需要,這樣我就可以通過ChannelFactory生成的代理來使用它。

我想寫一個專門的調用者類。樣品用法如下:

// create the invoker using the endpoint config and the existing sync contract 
var client = new ServiceInvoker<IDummyService>("LeyDummyService_Endpoint"); 

// invoke the desired service method set the callback, very similar to how 
// JQuery does AJAX calls... 
client.Invoke(dummyService => dummyService.SayHello("harley"), 
      (result) => MessageBox.Show(result)); 

有沒有人試過?這甚至有可能嗎?

回答

0

您是否嘗試過使用Svcutil?它將爲您構建所有的異步合約。

+1

不是一種選擇。我討厭爲那些異步契約編寫代碼,因此是個問題 – leypascua 2011-12-27 07:39:31

相關問題