WCF服务主机已打开-但浏览时出现ERR_CONNECTION_RESET

时间:2018-07-17 09:07:36

标签: c# wcf

我正在尝试使用控制台应用程序以https协议托管服务。

App.Config

<system.serviceModel>
    <client>
      <endpoint binding="customBinding" bindingConfiguration="encryptingBinding" contract="Something.ModuleService" name="clientConf" />
      <endpoint binding="customBinding" bindingConfiguration="WsManIncidentBinding" contract="IncidentAccess" name="WsManIncidentBinding_IncidentAccess" />
    </client>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
    <services>
      <service name="test.SomeName">
        <endpoint binding="customBinding" bindingConfiguration="encryptingBinding" contract="Something.ModuleService" />
      </service>
      <service behaviorConfiguration="API.Service1Behavior" name="test.API">
        <endpoint address="" binding="basicHttpBinding" bindingConfiguration="secureHttpBinding" contract="test.IAPI" />
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="API.Service1Behavior">
          <serviceMetadata httpsGetEnabled="True" />
          <serviceDebug includeExceptionDetailInFaults="True" />
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="web">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <bindings>
      <customBinding>
        <binding name="encryptingBinding">
          <!--  <messageEncryping /> -->
          <textMessageEncoding>
            <readerQuotas maxStringContentLength="2147483647" />
          </textMessageEncoding>
          <tcpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
            <connectionPoolSettings leaseTimeout="23:59:00" maxOutboundConnectionsPerEndpoint="10000" />
          </tcpTransport>
        </binding>
        <binding name="WsManIncidentBinding">
          <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16" messageVersion="Soap12WSAddressingAugust2004" writeEncoding="utf-8">
            <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          </textMessageEncoding>
          <httpsTransport manualAddressing="false" maxBufferPoolSize="524288" maxReceivedMessageSize="52428800" allowCookies="false" authenticationScheme="Basic" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" keepAliveEnabled="true" maxBufferSize="52428800" proxyAuthenticationScheme="Anonymous" realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false" useDefaultWebProxy="true" />
        </binding>
      </customBinding>
      <basicHttpBinding>
        <binding name="secureHttpBinding">
          <security mode="Transport">
            <transport clientCredentialType="None"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
  </system.serviceModel>

C#

var httpsUrl = "https://localhost:443/Service"
oServiceHost = New ServiceHost(GetType(API), New Uri(httpsUrl))                    
oServiceHost.Open()

httpsUrl应该是一个动态URL,在运行时会更改。

oServiceHost.Open()执行得很好,没有引发任何异常, oServiceHost.State设置为Opened

不幸的是,当尝试使用浏览器或SoapUi到达 https://localhost:443/Service 时-我遇到了ERR_CONNECTION_RESET错误,并且服务似乎没有运行。

0 个答案:

没有答案