具有TransportWithMessageCredentials的WCF Windows服务

时间:2019-01-18 08:35:15

标签: wcf windows-services wshttpbinding

我在IIS上托管了WCF服务,并且将wsHttpBinding与TransportWithMessageCredentials结合使用。它工作正常,但现在我必须准备Windows Service中托管的相同服务。我正在尝试使用相同的设置-wshttpbinding和TransportWithMessageCredentials。 我已经将这样的代码添加到我的配置文件中:

 <baseAddresses>
    <add baseAddress="https://xxx:9094"/>
    <add baseAddress="http://xxx:9095"/>
 </baseAddresses>

我可以使用http访问服务,但是当我尝试请求有关https地址的信息时,我收到了来自浏览器的响应“无法建立安全连接 加载页面后,与服务器的连接已重置。 无法显示请求的页面,因为无法确认所接收数据的真实性。请将此问题告知网站所有者。”

我应该对我的配置文件做些额外的事情还是解决问题?我可以通过IIS托管的端口9092通过https获得服务。

<?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <system.serviceModel>
        <services>
         <service behaviorConfiguration="BasicBehavior" name="xxx">
         <endpoint address="" behaviorConfiguration="EndpointBehavior"                     bindingConfiguration="WSBinding"
          binding="wsHttpBinding" name="KeyManager" contract="xxx" />
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="https://xxx:9094"/>
            <add baseAddress="http://xxx:9095"/>
          </baseAddresses>
        </host>
      </service>
    </services>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicBinding" sendTimeout="00:05:00">
          <readerQuotas maxStringContentLength="2147483647"/>
          <security mode="None"/>
        </binding>
      </basicHttpBinding>
      <wsHttpBinding>
        <binding name="WSBinding" sendTimeout="00:05:00" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
          <readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          <security mode ="TransportWithMessageCredential">
            <message clientCredentialType ="UserName"/>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="BasicBehavior">
          <serviceMetadata httpGetEnabled="true"httpsGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
          <serviceCredentials>
         <userNameAuthentication userNamePasswordValidationMode="Custom"   customUserNamePasswordValidatorType="Service.ServiceAuthenticator, Service"></userNameAuthentication>
            <clientCertificate>
              <authentication certificateValidationMode="ChainTrust"   revocationMode = "NoCheck" />
            </clientCertificate>
          </serviceCredentials>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="EndpointBehavior">
        </behavior>
      </endpointBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

0 个答案:

没有答案