我的解決方案中有2個控制檯應用程序。這是我的WCF服務:WCF中的傳輸安全性
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
namespace TransportSecTaulty
{
[ServiceContract]
public interface ITestService
{
[OperationContract]
void CallMe(string message);
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
namespace TransportSecTaulty
{
public class TestService : ITestService
{
public void CallMe(string message)
{
Console.BackgroundColor = ConsoleColor.Green;
Console.Write(message);
Console.BackgroundColor = ConsoleColor.Black;
}
}
}
這是我這是我的託管WCF服務的應用程序的app.config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="TransportSecTaulty.TestService">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="serviceConfig" contract="TransportSecTaulty.ITestService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="https://localhost:8734/Design_Time_Addresses/TransportSecTaulty/TestService/" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="serviceConfig">
<security mode="Transport">
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
</configuration>
我的服務可以正常啓動,沒有任何問題。然而,當我嘗試在我的客戶端添加服務引用我得到這個錯誤:
There was an error downloading 'https://localhost:8734/Design_Time_Addresses/TransportSecTaulty/TestService/'.
The underlying connection was closed: An unexpected error occurred on a send.
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
An existing connection was forcibly closed by the remote host
Metadata contains a reference that cannot be resolved: 'https://localhost:8734/Design_Time_Addresses/TransportSecTaulty/TestService/'.
An error occurred while making the HTTP request to https://localhost:8734/Design_Time_Addresses/TransportSecTaulty/TestService/. This could be due to the fact that the server certificate is not configured properly with HTTP.SYS in the HTTPS case. This could also be caused by a mismatch of the security binding between the client and the server.
The underlying connection was closed: An unexpected error occurred on a send.
Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
An existing connection was forcibly closed by the remote host
If the service is defined in the current solution, try building the solution and adding the service reference again.
我無法瀏覽我的役的瀏覽器。然而,同樣的事情在http上完美工作。問題只出現在https中。
任何想法可能是錯誤的?