我已成功創建WCF self-hosted HTTP
Web服務。我使用webserviceHost
來創建此服務。我沒有對web.config
文件進行任何更改。這裏是我的代碼:如何使用HTTPS訪問WCF WebServiceHost端點?
Instance.cs:
[OperationContract, WebInvoke(Method = "GET", UriTemplate = "/getstatus/", ResponseFormat = WebMessageFormat.Json)]
bool getstatus();
service.cs:
public bool getstatus()
{
return true;
}
BindingWS.cs
void bindservice()
{
try
{
m_running = true;
// Start the host
m_serviceHost = new WebServiceHost(typeof(Swiper.cs), new Uri(http://localhost:8083"));
ServiceEndpoint ep = m_serviceHost.AddServiceEndpoint(typeof(Instace.cs), new WebHttpBinding(), "");
m_serviceHost.Open();
while (m_running)
{
// Wait until thread is stopped
Thread.Sleep(SleepTime);
}
// Stop the host
m_serviceHost.Close();
}
catch (Exception e)
{
Console.WriteLine(e.Message);
if (m_serviceHost != null)
{
m_serviceHost.Close();
}
}
}
上面的代碼工作正常在運行Htpp
WCF
。但我怎麼轉換成HTTPS
。我關注這麼多的博客,但沒有收到任何東西。可以做到嗎?
只是改變地址? 'new Uri(https:// localhost:8083「)' – 2013-02-18 11:36:26
不,因爲有很多事情要做'證書'。 – 2013-02-18 11:43:25