首页 > 解决方案 > WCF Web 服务无法使用 https 进行连接

问题描述

一个星期以来一直在努力让现有的工作网络服务在 https 下工作。Web 服务在 https 下广告正常,但在尝试通过客户端交互时失败。我已经阅读了所有内容并尝试了许多 app.config 和 Web 配置的组合,需要更多的关注。这就是我所拥有的。

应用程序配置

<?xml version="1.0" encoding="utf-8"?>

网络配置

  <system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<protocolMapping>
  <add scheme="http" binding="basicHttpBinding" bindingConfiguration="" />
  <add scheme="https" binding="basicHttpsBinding" bindingConfiguration="BasicHttpBinding_IScanDocumentWcf" />
</protocolMapping>
<diagnostics>
  <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" maxMessagesToLog="3000000" maxSizeOfMessageToLog="2000000" />
</diagnostics>
<bindings>
<basicHttpsBinding>
    <binding name="BasicHttpBinding_IScanDocumentWcf" maxReceivedMessageSize="2000000000" closeTimeout="01:00:00" openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00">
      <security mode="Transport">
        <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
        <message clientCredentialType="Certificate" algorithmSuite="Default" />
      </security>
    </binding>
</basicHttpsBinding>
</bindings>
<services>
  <service name="MySiteLibrary.Services.ScanDocumentWcf" behaviorConfiguration="serviceHttpsBehavior">
    <endpoint address="" binding="basicHttpsBinding" contract="MySiteLibrary.Services.IScanDocumentWcf" />       
  </service>
</services>

<behaviors>
  <serviceBehaviors>
    <behavior name="serviceFaultBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
    <behavior name="serviceHttpsBehavior">
      <serviceMetadata httpsGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>

</system.serviceModel>

返回错误

    There was no endpoint listening at https://webscan.MySite.com/ScanDocumentWcf.svc that could accept the

信息。这通常是由不正确的地址或 SOAP 操作引起的。有关更多详细信息,请参阅 InnerException(如果存在)。

服务器堆栈跟踪:在 System.ServiceModel.Channels.HttpOutput.Send(TimeSpan 超时)的 System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStream()
在 System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.SendRequest(消息消息,TimeSpan 超时)在 System.ServiceModel.Channels.RequestChannel.Request(消息消息,TimeSpan 超时)在 System.ServiceModel.Dispatcher.RequestChannelBinder.Request (消息消息,TimeSpan 超时)在 System.ServiceModel.Channels.ServiceChannel.Call(字符串操作,布尔单向,ProxyOperationRuntime 操作,Object[] 输入,Object[] 输出,TimeSpan 超时)在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage 消息)处的(IMethodCallMessage 方法调用、ProxyOperationRuntime 操作)

在 [0] 处重新抛出异常:在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) 在 IScanDocumentWcf.GetScanForms( ) 在 ScanDocumentWcfClient.GetScanForms()

内部异常:无法在 System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStream() 的 System.Net.HttpWebRequest.GetRequestStream() 的 System.Net.HttpWebRequest.GetRequestStream(TransportContext& context) 连接到远程服务器

内部异常:连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立连接失败,因为连接的主机在 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot) 未能响应 195.168.2.145:443 , SocketAddress socketAddress) 在 System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)

标签: c#httpswcf-binding

解决方案


Web 服务对使用 HTTP 还是 HTTPS 有很大影响。

您可以查看下面的链接并找到一些有用的信息: WCF 服务在通过 HTTPS 和 HTTP 访问时不起作用

谢谢。


推荐阅读