【问题标题】:WCF Web Service not able to connect using httpsWCF Web 服务无法使用 https 进行连接
【发布时间】:2021-09-28 23:18:18
【问题描述】:

现在已经拔了一个星期的头发,试图让一个现有的、工作的 Web 服务在 https 下工作。网络服务广告很好,而 在 https 下,但尝试通过客户端交互时失败。我有 阅读所有内容并尝试了许多 app.config 和 web 的组合 配置和需要更多的眼睛。这是我所拥有的。

App.Config

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

Web.Config

  <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>

错误返回

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

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

服务器堆栈跟踪:在 System.ServiceModel.Channels.HttpOutput.WebRequestHttpOutput.GetOutputStream() 在 System.ServiceModel.Channels.HttpOutput.Send(时间跨度超时)
在 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(字符串动作, Boolean oneway, ProxyOperationRuntime 操作, Object[] ins, Object[] 出局,TimeSpan 超时)在 System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall,ProxyOperationRuntime 操作)在 System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage 留言)

在 [0] 处重新抛出异常:在 System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg,IMessage retMsg)在 System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(消息数据& msgData,Int32 类型)在 IScanDocumentWcf.GetScanForms() 在 ScanDocumentWcfClient.GetScanForms()

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

内部异常:连接尝试失败,因为已连接 当事人在一段时间后没有正确回应,或建立 连接失败,因为连接的主机没有响应 195.168.2.145:443 在 System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) 在 System.Net.ServicePoint.ConnectSocketInternal(布尔连接失败, Socket s4, Socket s6, Socket&socket, IPAddress&地址, ConnectSocketState 状态、IAsyncResult asyncResult、Exception& 例外)

【问题讨论】:

    标签: c# https wcf-binding


    【解决方案1】:

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

    您可以查看下面的链接并找到一些有用的信息: WCF service not working when accessed over HTTPS and HTTP.

    谢谢。

    【讨论】:

      【解决方案2】:

      当我将服务名称更改为与合同相同的名称时,此问题已解决。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-08-03
        • 2013-01-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多