wcf - 将 WCF RESTful 服务作为应用程序添加到经典 ASP 网站

标签 wcf ssl https

嗯。我们有一个在 Windows Server 2012 上的 IIS 8.5 上运行的遗留经典 asp 网站。网站启用了 http 和 https 协议(protocol)。最近我开发了一个独立的 WCF Web 服务并将其作为应用程序添加到我们的网站(具有不同的应用程序池)。 现在 WCF 可以很好地处理 http 协议(protocol),但不能处理 https。 Service.svc 使用 https 正常加载,但对于所有请求返回 400

这是我的 web.config

<system.web>
    <compilation targetFramework="4.5" />
    <customErrors mode="Off"/>
    <httpRuntime targetFramework="4.5" maxUrlLength="1000"/>
  </system.web>
   <system.serviceModel> 
    <services>
      <service name="KATProductFilter.Service1" behaviorConfiguration="mycorp.Callback.SecPayServiceBehavior">
         <endpoint address=""
                   binding="wsHttpBinding" bindingConfiguration="TransportBinding" 
                   contract="KATProductFilter.IService1"/>      
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />        
      </service>
    </services>
    <behaviors>
        <serviceBehaviors>
            <behavior name="mycorp.Callback.SecPayServiceBehavior">
                <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <bindings>
        <wsHttpBinding>
            <binding name="TransportBinding">
                <security mode="Transport">
                    <transport clientCredentialType="None" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true">  
        <baseAddressPrefixFilters> 
            <add prefix="https://www.knivesandtools.nl/filterssl"/> 
        </baseAddressPrefixFilters> 
    </serviceHostingEnvironment> 
  </system.serviceModel>

提前致谢

最佳答案

我解决了。端点的绑定(bind)必须是 webHttpBinding,它必须同时具有 bindingConfiguration 和 behaviorConfiguration,如下所示。

<system.serviceModel>
<bindings>
    <webHttpBinding>
        <binding name="TransportSecurity">
            <security mode="Transport">
                <transport clientCredentialType="None" />
            </security>
        </binding>
    </webHttpBinding>
</bindings>
<behaviors>
    <serviceBehaviors>
        <behavior name="test">
            <serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true"/>
            <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
        </behavior>
    </serviceBehaviors>
    <endpointBehaviors>
    <behavior name="katproductfilter_behavior">
        <dataContractSerializer ignoreExtensionDataObject="true" maxItemsInObjectGraph="2147483646"/>
        <webHttp/>
    </behavior>
    </endpointBehaviors>
</behaviors>
<services>
    <service name="KATProductFilter.Service1" behaviorConfiguration="test">
        <endpoint address="" binding="webHttpBinding" contract="KATProductFilter.IService1" bindingConfiguration="TransportSecurity" behaviorConfiguration="katproductfilter_behavior"/>
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
    </service>
</services>
<protocolMapping>
    <add binding="basicHttpsBinding" scheme="https"/>
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" minFreeMemoryPercentageToActivateService="0"/>

PS Ricardo 感谢您提供链接。

关于wcf - 将 WCF RESTful 服务作为应用程序添加到经典 ASP 网站,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32655418/

相关文章:

haskell - 使用 http-client-tls 连接到 Azure Datamarket 时管道损坏

wcf - WCF可靠 session 的目的是什么?

.net - 如何使用多个参数调用 RESTful WCF 服务方法?

json - Instagram 最新帖子 API 突然停止工作

德尔福。 socket 。仅在一个节点/MAC 地址上的 TIdHttp 套接字连接上访问被拒绝。必发API

node.js - 用于简单 nodejs webapp 的 greenlock-express

asp.net - 通过wcf服务通过邮寄方式消费表单数据

c# - 需要全面的 C# System.Threading.Tasks 示例

ssl - 正在处理 gke 证书管理器证书

http - 我的 golang 网络服务器是否需要以 root 用户身份运行才能支持 HTTPS/TLS?