2

我在 Windows Server 2008 R2 上有一个 WCF。我有一个 SSL 证书。

使用 IE,http URL 工作正常(我得到我的数据),但使用 Https 我有 400 错误请求。

在我的 wcf 的 web.config 下面:

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

<bindings>
  <basicHttpBinding>
    <binding name="TransportSecurity">
      <security mode="Transport">
        <transport clientCredentialType="None" />
      </security>
    </binding>    
  </basicHttpBinding>      
</bindings>

<behaviors>
  <endpointBehaviors>

    <behavior name="ServiceRequestResourcesAspNetAjaxBehavior">
      <webHttp defaultOutgoingResponseFormat="Json" />      
    </behavior>

    <behavior name="ServiceRequestResourcesAspNetAjaxBehaviorHttps">          
    </behavior>

  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="ServiceRequestResourcesBehaviors">
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="true" />          
    </behavior>        
  </serviceBehaviors>
</behaviors>

<services>
  <service behaviorConfiguration="ServiceRequestResourcesBehaviors" 
           name="BaseSite.ServiceRequestResources">

   <endpoint address="" 
             behaviorConfiguration="ServiceRequestResourcesAspNetAjaxBehaviorHttps" 
             binding="basicHttpBinding" 
             bindingConfiguration="TransportSecurity"
             contract="BaseSite.ServiceRequestResources" />

    <endpoint address="" 
              behaviorConfiguration="ServiceRequestResourcesAspNetAjaxBehavior" 
              binding="webHttpBinding" contract="BaseSite.ServiceRequestResources" />

  </service>      
</services>

4

2 回答 2

4

经过大量测试,它正在工作。我需要在webHttpBinding而不是配置绑定部分basicHttpBinding,但我不知道为什么。

在我的绑定部分下方:

<bindings>
    <webHttpBinding>
        <binding name="TransportSecurity">
            <security mode="Transport">
                <transport clientCredentialType="None" />
            </security>
        </binding>
    </webHttpBinding>
</bindings>
于 2013-02-07T14:52:32.750 回答
0

对于您的部分,您是否尝试过为 HTTPS 添加端点,如下所示:

<services>
    <service behaviorConfiguration="ServiceRequestResourcesBehaviors" 
        name="BaseSite.ServiceRequestResources">

        <endpoint address="" 
          behaviorConfiguration="ServiceRequestResourcesAspNetAjaxBehaviorHttps" 
          binding="basicHttpBinding" 
          bindingConfiguration="TransportSecurity"
          contract="BaseSite.ServiceRequestResources" />

        <endpoint address="" 
          behaviorConfiguration="ServiceRequestResourcesAspNetAjaxBehavior" 
          binding="webHttpBinding" contract="BaseSite.ServiceRequestResources" />

        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
    </service>      
</services>
于 2013-02-05T15:38:29.023 回答