【发布时间】:2011-05-17 08:14:27
【问题描述】:
我有本教程中的简单应用程序:WCF 4 Getting Started Tutorial
如何实现一些加密? HTTPS(SSL?)之类的东西。
教程中的示例代码。
static void Main(string[] args)
{
// Step 1 of the address configuration procedure: Create a URI to serve as the base address.
Uri baseAddress = new Uri("http://localhost:8000/ServiceModelSamples/Service");
// Step 2 of the hosting procedure: Create ServiceHost
ServiceHost selfHost = new ServiceHost(typeof(CalculatorService), baseAddress);
try
{
// Step 3 of the hosting procedure: Add a service endpoint.
selfHost.AddServiceEndpoint(
typeof(ICalculator),
new WSHttpBinding(),
"CalculatorService");
// Step 4 of the hosting procedure: Enable metadata exchange.
ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
smb.HttpGetEnabled = true;
selfHost.Description.Behaviors.Add(smb);
// Step 5 of the hosting procedure: Start (and then stop) the service.
selfHost.Open();
Console.WriteLine("The service is ready.");
Console.WriteLine("Press <ENTER> to terminate service.");
Console.WriteLine();
Console.ReadLine();
// Close the ServiceHostBase to shutdown the service.
selfHost.Close();
}
catch (CommunicationException ce)
{
Console.WriteLine("An exception occurred: {0}", ce.Message);
selfHost.Abort();
}
}
【问题讨论】:
-
您如何托管 WCF 服务 - 使用 WCF 内置 TCP 或 HTTP 绑定,或通过 IIS 之类的东西?
-
本教程中的一切。
-
您应该首先了解您的服务使用什么配置,并能够在您的问题中描述它。我们为什么要阅读整个教程?
标签: c# wcf visual-studio-2010 ssl