3

我在访问 https 站点中的 Web 服务时遇到了错误。我认为这是一个配置错误,因为它正在寻找一个 https 绑定。

这是 Web 服务的 web.config:

<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<services>
  <service name="WebService.ListViewWebService" behaviorConfiguration="WebService.ListViewWebServiceBehavior">
    <endpoint address=""
              behaviorConfiguration="WebService.ListViewWebServiceAjaxBehavior"
              binding="webHttpBinding"
              contract="WebService.IListViewWebService"/>
    <endpoint address="https://win-d741qhlbivf:13241/services/DPT/_vti_bin/DPT.WebService/ListViewWebService.svc"
              behaviorConfiguration="WebService.ListViewWebServiceAjaxBehavior1"
              binding="webHttpsBinding"
              contract="WebService.IListViewWebService2"/>
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />         
  </service>
</services>
<bindings>
    <basicHttpBinding>
        <binding name="webHttpBinding">
            <security mode="None" />
        </binding>
        <binding name="webHttpsBinding">
            <security mode="Transport" />
        </binding>
    </basicHttpBinding>
</bindings>
<behaviors>
  <endpointBehaviors>
    <behavior name="WebService.ListViewWebServiceAjaxBehavior">
      <webHttp/>
    </behavior>

  </endpointBehaviors>
  <serviceBehaviors>
    <behavior name="WebService.ListViewWebServiceBehavior">
      <serviceDebug includeExceptionDetailInFaults="true"/>
      <serviceMetadata httpGetEnabled="true" />
    </behavior> 

  </serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>

我在这里先向您的帮助表示感谢。

另外,我不确定这是否与问题有关,但托管在云环境中的 Web 应用程序...我需要为此进行特殊配置吗?...

再次感谢..

4

3 回答 3

0

此配置将响应 HTTP 和 HTTPS 中的请求,请注意端口是不同的,并且必须与主机的期望相匹配(在这种情况下,它恰好是 iis)

<appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
    <compilation debug="true" />

        <customErrors mode="Off"/>
    </system.web>



<system.serviceModel>
    <serviceHostingEnvironment minFreeMemoryPercentageToActivateService="0" />

    <services>
        <service name="KPIGetter_Library.KPIGetter">

            <endpoint address="" 
                    behaviorConfiguration="restfulBehaviour"
                    binding="webHttpBinding" 
                    bindingConfiguration="webHttpBindingWithJsonP"
                    contract="KPIGetter_Library.IKpiGetter" />


            <endpoint address="" 
                    behaviorConfiguration="restfulBehaviour"
                    binding="webHttpBinding" 
                    bindingConfiguration="webHttpsBindingWithJsonP"
                    contract="KPIGetter_Library.IKpiGetter" />

            <host>
                <baseAddresses>
                    <add baseAddress="http://hodbd05:8000/kpigetter" />
                    <add baseAddress="https://hodbd05:8001/kpigetter" />
                </baseAddresses>
            </host>
        </service>
    </services>

    <behaviors>
        <endpointBehaviors>

            <behavior name="restfulBehaviour">
                <webHttp/>
            </behavior>
        </endpointBehaviors>

        <serviceBehaviors>
            <behavior>
                <serviceDebug includeExceptionDetailInFaults="true" />
            </behavior>
        </serviceBehaviors>
    </behaviors>

    <protocolMapping>
        <add binding="webHttpBinding" scheme="http" />
    </protocolMapping>

    <bindings>
        <webHttpBinding>
                <binding name="webHttpBindingWithJsonP" crossDomainScriptAccessEnabled="true">
                     <security mode="None" />
                </binding>

                <binding name="webHttpsBindingWithJsonP" crossDomainScriptAccessEnabled="true">
                     <security mode="Transport" />
                </binding>
        </webHttpBinding>

    </bindings>
</system.serviceModel>

于 2014-02-12T17:31:38.677 回答
0

我的教程之一将帮助您:

http://netpl.blogspot.com/2010/05/how-to-programmatically-configure-ssl.html

本教程从声明性配置开始,然后展示如何以编程方式创建绑定/端点。

于 2012-06-17T13:57:44.590 回答
0

一个重要的问题是您应该为启用 ajax 的 WCF 服务使用 webHttpBinding 而不是 basicHttpBinding。

在这里可以找到一个简单的工作示例:Scott 在 asp.net 上的博客

于 2014-06-26T15:33:52.373 回答