0

我已经尝试过谷歌以及其他关于 SO 的帖子,到目前为止我所尝试的都没有解决我的问题。

我以为就是答案。没有骰子。我还阅读了 SO 上的大多数帖子,其中提到了我收到的相同错误消息,例如this

我的网站是安全的,https。我有 3 个 WCF 服务来处理我在此站点上运行的异步 ajax 内容。当我尝试访问任何这些服务时,我收到此错误:

找不到与绑定 WebHttpBinding 的终结点的方案 http 匹配的基地址。注册的基地址方案是 [https]。

我的配置:

<behaviors>
    <endpointBehaviors>
        <behavior name="ajaxBehavior">
            <enableWebScript />
        </behavior>
    </endpointBehaviors>
    <serviceBehaviors>
        <behavior name="ajaxAsynchBehavior">
            <serviceMetadata httpsGetEnabled="true" />
            <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
     </serviceBehaviors>
</behaviors>  
<bindings>
    <webHttpBinding>
        <binding name="webBinding">
            <security mode="Transport" />
        </binding>
    </webHttpBinding>
</bindings>
<services>
    <service name="MyApp.Web.Services.CascadingList">
        <endpoint address="" behaviorConfiguration="ajaxAsynchBehavior"
                    binding="webHttpBinding" bindingConfiguration="webBinding" contract="MyApp.Web.Services.CascadingList" />
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
        <host>
            <baseAddresses>
                <add baseAddress="https://[domain]/MyApp/Services/CascadingList.svc" />
            </baseAddresses>
        </host>
    </service>
    <service name="MyApp.Web.Services.AutoComplete">
        <endpoint address="" behaviorConfiguration="ajaxAsynchBehavior"
                    binding="webHttpBinding" bindingConfiguration="webBinding" contract="MyApp.Web.Services.AutoComplete" />
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
        <host>
            <baseAddresses>
                <add baseAddress="https://[domain]/MyApp/Services/AutoComplete.svc" />
            </baseAddresses>
        </host>
    </service>
    <service name="MyApp.Web.Services.Validation">
        <endpoint address="" behaviorConfiguration="ajaxAsynchBehavior"
                    binding="webHttpBinding" bindingConfiguration="webBinding" contract="MyApp.Web.Services.Validation" />
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
        <host>
            <baseAddresses>
                <add baseAddress="https://[domain]/MyApp/Services/Validation.svc" />
            </baseAddresses>
        </host>
    </service>
</services>

我应该可以访问“ https://[domain]/MyApp/SubmitNew.aspx ”并且级联列表应该可以工作。

目前,“父”列表显示“[方法 500]”,子列表保持禁用状态。

当我点击“SubmitNew”页面时,我的服务器的事件日志显示“发件人信息:System.ServiceModel.Activation.HostedHttpRequestAsyncResult/51442863 异常:System.ServiceModel.ServiceActivationException:无法激活服务'/MyApp/Services/CascadingList.svc'由于编译期间出现异常。异常消息是:找不到与绑定 WebHttpBinding 的端点的方案 http 匹配的基地址。注册的基地址方案是 [https]。 "

如果我直接导​​航到“ https://[domain]/MyApp/Services/CascadingList.svc ”,我也会收到上述错误。


更新

这发生在我们的生产服务器上。在我加入公司之前很久就建立了带有 SSL 证书的安全站点。我刚刚在安全站点下为我的新 Web 应用程序添加了一个新的虚拟目录。

在 IIS 中:

Secure Web Applications (has SSL cert)
    MyApp
    WebApp1
    WebApp2

我修复了我的配置(上图)以使用正确的行为配置。

-- 2012.04.24 13:15 CDT --

当我将配置更改为此(如下)时,我收到此错误:“ System.ServiceModel.ServiceActivationException:由于编译期间出现异常,无法激活服务'/MyApp/Services/CascadingList.svc'。异常消息是:有没有名为 'ajaxAsynchBehavior' 的端点行为"

<serviceBehaviors>
    <behavior name="ajaxAsynchBehavior">
        <serviceMetadata httpsGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
</serviceBehaviors>

<services>
    <service name="MyApp.Web.Services.CascadingList">
        <endpoint address="" behaviorConfiguration="ajaxAsynchBehavior"
                    binding="basicHttpBinding" bindingConfiguration="ajaxBinding" contract="MyApp.Web.Services.CascadingList" />
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
        <host>
            <baseAddresses>
                <add baseAddress="https://[domain]/MyApp/Services/CascadingList.svc" />
            </baseAddresses>
        </host>
    </service>
    .
    .
    .
</services>

所以我把它改回:

<behaviors>
    <endpointBehaviors>
        <behavior name="ajaxBehavior">
            <enableWebScript />
        </behavior>
        <behavior name="clientBehavior" />
    </endpointBehaviors>
    <serviceBehaviors>
        <behavior name="ajaxAsynchBehavior">
            <serviceMetadata httpsGetEnabled="true" />
            <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
    </serviceBehaviors>
</behaviors>

<services>
    <service name="MyApp.Web.Services.CascadingList">
        <endpoint address="" behaviorConfiguration="ajaxBehavior"
                    binding="basicHttpBinding" bindingConfiguration="ajaxBinding" contract="MyApp.Web.Services.CascadingList" />
        <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
        <host>
            <baseAddresses>
                <add baseAddress="https://[domain]/MyApp/Services/CascadingList.svc" />
            </baseAddresses>
        </host>
    </service>
    .
    .
    .
</services>
4

3 回答 3

0

我将把答案归功于 dmusial(包括所有评论),但我想发布我的最终配置更改,以防万一这对其他人有利。

这篇文章还帮助我找到了解决方案。

<system.serviceModel>
    <behaviors>
        <endpointBehaviors>
            <behavior name="webScriptEnablingBehavior">
                <enableWebScript />
            </behavior>
            <behavior name="clientBehavior" />
        </endpointBehaviors>
        <serviceBehaviors>
            <behavior name="webScriptEnablingBehavior">
                <serviceMetadata httpsGetEnabled="true" />
                <serviceDebug includeExceptionDetailInFaults="false" />
            </behavior>
        </serviceBehaviors>
    </behaviors>
    <bindings>
        <webHttpBinding>
            <binding name="webBinding">
                <security mode="Transport" />
            </binding>
        </webHttpBinding>
        <wsHttpBinding>
            <binding name="customBinding" closeTimeout="00:01:00"
                openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="1048576" maxReceivedMessageSize="1048576"
                messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
                <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="true" />
                <security mode="None">
                    <transport clientCredentialType="None" />
                    <message clientCredentialType="None" negotiateServiceCredential="false" establishSecurityContext="false" />
                </security>
            </binding>
        </wsHttpBinding>
    </bindings>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
    <services>
        <service name="MyApp.Web.Services.CascadingList" behaviorConfiguration="webScriptEnablingBehavior">
            <endpoint address="" behaviorConfiguration="webScriptEnablingBehavior"
            binding="webHttpBinding" bindingConfiguration="webBinding" contract="MyApp.Web.Services.CascadingList" />
            <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
        </service>
        <service name="MyApp.Web.Services.AutoComplete" behaviorConfiguration="webScriptEnablingBehavior">
            <endpoint address="" behaviorConfiguration="webScriptEnablingBehavior"
            binding="webHttpBinding" bindingConfiguration="webBinding" contract="MyApp.Web.Services.AutoComplete" />
            <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
        </service>
        <service name="MyApp.Web.Services.Validation" behaviorConfiguration="webScriptEnablingBehavior">
            <endpoint address="" behaviorConfiguration="webScriptEnablingBehavior" binding="webHttpBinding" bindingConfiguration="webBinding" contract="MyApp.Web.Services.Validation" />
            <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
        </service>
    </services>
</system.serviceModel>
于 2012-04-25T12:14:38.917 回答
0

您的配置看起来不错,除了不会附加的服务行为,因为您没有在标签中添加behaviorConfiguration正确的名称。<service>但这不会导致您的错误。

您是否有机会使用 Visual Studio 内置 Web 服务器 (Cassini)?因为它看起来像你这样做,请记住它支持 HTTPS。这可能就是您收到错误的原因。尝试将您的站点部署到本地 IIS 服务器并检查它是否可以正常工作。您可以在此处查看如何在 IIS 7 上设置 https 开发网站。还有一件事,一旦您将站点部署到 IIS,请记住baseAddress标记将被忽略,但您的服务将可以通过其原始名称访问,即 CascadingList.svc(除非配置不同)。

于 2012-04-23T21:06:35.130 回答
0

我用这个配置解决了我的问题:

<system.serviceModel>
    <bindings>
        <webHttpBinding>
            <binding name="webBinding">
                <security mode="Transport">
                </security>
            </binding>
        </webHttpBinding>
    </bindings>
    <protocolMapping>
      <add binding="webHttpBinding" bindingConfiguration="webBinding" scheme="https" />
    </protocolMapping>
</system.serviceModel>
于 2016-01-15T16:41:17.097 回答