我创建了一个简单的网络服务。 然后我创建了一个控制台主机,它必须通过 https url 托管服务..
这是我的配置:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service behaviorConfiguration="mexBehaviour" name="NuriServiceLibrary.NuriService">
<clear />
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="basicHttpBindingConfig"
contract="NuriServiceLibrary.iNuriService" listenUriMode="Explicit" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="https://192.168.....:8001/SecureConsole" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="mexBehaviour">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="basicHttpBindingConfig">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
</configuration>
这是我的 program.cs:
static void Main(string[] args)
{
ServiceHost host = new ServiceHost(typeof(NuriService));
host.Open();
foreach (Uri address in host.BaseAddresses)
{
Console.WriteLine("Listening on " + address);
}
Console.WriteLine("Press <Enter> to terminate Host.\n\n");
Console.ReadLine();
host.Close();
}
我通过以下方式创建了证书: 1. makecert.exe -sr LocalMachine -ss My -n CN=192.168..... -sky exchange -sk -pe 2.netsh http add sslcert ipport=192.168....:8001 certhash=(故意留下) appid={(故意留下)}
但问题是,我看不到我的 https 网页...我看到这个网站不可用... 有人有想法吗?
最佳答案
尝试添加 HttpsGetUrl属性为 <serviceMetadata>
并指定一个空字符串:
<serviceBehaviors>
<behavior name="mexBehaviour">
<serviceMetadata httpGetEnabled="false"
httpsGetEnabled="true"
httpsGetUrl="" />
</behavior>
</serviceBehaviors>
这将使服务元数据通过服务的 base address 可用。 :
https://localhost:8001/SecureConsole?wsdl
关于c# - wcf 为什么我看不到我的 https 站点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9684107/