1

我有以下 WCF 配置文件在 HTTP 下完美工作,但不知何故这在 HTTPS 下不起作用。有谁知道那里出了什么问题?我该如何解决?

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>

  <system.serviceModel>




    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />

    <bindings>
      <!-- if using basicHttpBinding, wsHttpBinding section should be commented -->
      <wsHttpBinding>
        <binding name="wsHttpBindingConfig">
          <security mode="None">
            <transport  clientCredentialType="None" proxyCredentialType="None" />
            <message clientCredentialType="None" negotiateServiceCredential="False" algorithmSuite="Default"/>
          </security>
        </binding>
      </wsHttpBinding>
    </bindings>



    <services>
      <service name="SEWebService.Service1" behaviorConfiguration="SEWebService.Service1Behavior">

        <!-- basicHttpBinding is SOAP-based Service, it sends data in plain text, but it supports maximum types of clients.
        It supports Soap 1.1, lower version of .Net Client, like .Net 1.1 -->
        <!--
        <endpoint address="basic" binding="basicHttpBinding" contract="SearchApi.ISearchApi"/>
         -->

        <!--wsHttpBinding is SOAP-based Service, it sends encrypted data by default, but it needs supporting WS-* specification clients and
        at least .Net3.0 or higher version
        By default  wsHttpBinding uses Windows authentication, we need to turn it off by using bindingConfiguration-->
        <endpoint address="ws" binding="wsHttpBinding" contract="SEWebService.IService1" bindingConfiguration="wsHttpBindingConfig" >
        </endpoint>

        <!-- webHttpBinding is non-SOAP HTTP services, here webHttpBinding register REST to be a Restful WCF Service
        It uses [WebGet] or [WebInvoke] to map an Http Request to a WCF operation-->
        <endpoint address="" binding="webHttpBinding" contract="SEWebService.IService1" behaviorConfiguration="REST">
          <!--Upon deployment, the following identity element should be removed or replaced to reflect the identity under which the deployed service runs. 
          If removed, WCF will infer an appropriate identity automatically.-->
          <identity>
            <dns value="localhost"/>
          </identity>
        </endpoint>


        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>

      </service>
    </services>


    <behaviors>
      <serviceBehaviors>

        <behavior name="SEWebService.Service1Behavior">

          <useRequestHeadersForMetadataAddress>
            <defaultPorts>
              <add scheme="http" port="80" />
              <add scheme="https" port="443" />
            </defaultPorts>
          </useRequestHeadersForMetadataAddress>
          <!-- To avoid disclosing metadata information, set the value below to false before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="REST">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
    </behaviors>

  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
  </system.webServer>
  <connectionStrings>
    <add name="DbConnectionString" connectionString="nitial Catalog=Smart_Web_Service;uid=SmartWebService_User;pwd=73E;Connect Timeout=10; pooling=true;" providerName="System.Data.SqlClient" />
  </connectionStrings>
</configuration>
4

1 回答 1

0

查看您的配置文件

1)mexHttpBinding改为mexHttpsBinding

<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>

2) 改成httpGetEnabledhttpsGetEnabledserviceMetadata

<serviceMetadata httpsGetEnabled="true"/>

3) 启用传输级安全性

<security mode="Transport">

另请查看这篇文章以供参考。

于 2013-09-18T05:08:38.777 回答