我想在WPF應用程序內託管WCF服務,但我無法這樣做。在WPF應用程序中託管WCF服務
這裏是我的實現代碼:
ServiceHost host = null;
using (host = new ServiceHost(typeof(WcfJsonTransferRestService.apiService)))
{
host.AddServiceEndpoint(typeof(WcfJsonTransferRestService.IApiService), new WebHttpBinding(), "http://localhost:3300/api/endpoint1");
host.AddServiceEndpoint(typeof(WcfJsonTransferRestService.IApiService), new WebHttpBinding(), "http://localhost:3300/api/endpoint2");
host.AddServiceEndpoint(typeof(WcfJsonTransferRestService.IApiService), new WebHttpBinding(), "http://localhost:3300/api/endpoint3");
host.Open();
一切正常,運行良好,但該服務沒有啓動。
任何人都知道我的問題可能是什麼?
感謝
你有沒有嘗試單步執行調試器中的代碼?是否引發錯誤?事件查看器中是否有任何內容? – Tim
是的,一切都創造良好,但當我嘗試連接(使用高級REST客戶端),我得到一個錯誤,如果該服務沒有運行 – d199224
從您的發佈代碼,它看起來像你託管的SOAP服務 - REST是不同於肥皂。你嘗試過使用'WebHttpBinding'而不是'WSHttpBinding'嗎? – Tim